Total Complexity | 4 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 31.25% |
1 | 1 | from plugin.sync.core.enums import SyncData, SyncMedia, SyncMode |
|
10 | 1 | class Watchlist(Lists): |
|
11 | 1 | data = [SyncData.Watchlist] |
|
12 | 1 | mode = SyncMode.Pull |
|
13 | |||
14 | 1 | @elapsed.clock |
|
15 | def run(self): |
||
16 | # Retrieve plex sections |
||
17 | p_sections, p_sections_map = self.sections() |
||
18 | |||
19 | # Retrieve playlist |
||
20 | p_playlists = dict(self.get_playlists()) |
||
21 | |||
22 | p_playlist = self.get_playlist( |
||
23 | p_playlists, |
||
24 | uri='trakt://watchlist/%s' % self.current.account.id, |
||
25 | title='Watchlist' |
||
26 | ) |
||
27 | |||
28 | if not p_playlist: |
||
29 | return |
||
30 | |||
31 | # Retrieve items from watchlist collections |
||
32 | t_list_items = self.get_items(SyncData.Watchlist, [ |
||
33 | SyncMedia.Movies, |
||
34 | SyncMedia.Shows, |
||
35 | SyncMedia.Seasons, |
||
36 | SyncMedia.Episodes |
||
37 | ]) |
||
38 | |||
39 | # Update (add/remove) list items |
||
40 | self.process_update( |
||
41 | SyncData.Watchlist, p_playlist, p_sections_map, |
||
42 | t_list_items=t_list_items |
||
43 | ) |
||
44 | |||
45 | 1 | def create_playlist(self, uri, name): |
|
46 | # Check if playlist creation is enabled |
||
47 | if self.configuration['sync.lists.watchlist.playlists'] is False: |
||
48 | log.info('No playlist found named %r ("Create playlist in plex" not enabled)', name) |
||
49 | return None |
||
50 | |||
51 | # Create playlist |
||
52 | return super(Watchlist, self).create_playlist(uri, name) |
||
53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.