Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 23.53% |
1 | 1 | from plugin.sync.core.enums import SyncData, SyncMode, SyncMedia |
|
10 | 1 | class PersonalLists(Lists): |
|
11 | 1 | data = [SyncData.Personal] |
|
12 | mode = SyncMode.Pull |
||
13 | 1 | ||
14 | @elapsed.clock |
||
15 | def run(self): |
||
16 | # Retrieve plex sections |
||
17 | p_sections, p_sections_map = self.sections() |
||
18 | |||
19 | # Retrieve plex playlists |
||
20 | p_playlists = dict(self.get_playlists()) |
||
21 | |||
22 | # Retrieve trakt lists |
||
23 | t_lists = self.trakt[(SyncMedia.Lists, SyncData.Personal)] |
||
24 | |||
25 | if t_lists is None: |
||
26 | log.warn('Unable to retrieve liked lists') |
||
27 | return |
||
28 | |||
29 | # Process trakt lists |
||
30 | for _, t_list in t_lists.items(): |
||
31 | self.process(SyncData.Personal, p_playlists, p_sections_map, t_list) |
||
32 | |||
33 | def create_playlist(self, uri, name): |
||
34 | # Check if playlist creation is enabled |
||
35 | if self.configuration['sync.lists.personal.playlists'] is False: |
||
36 | log.info('No playlist found named %r ("Create playlists in plex" not enabled)', name) |
||
37 | 1 | return None |
|
38 | |||
39 | # Create playlist |
||
40 | return super(PersonalLists, self).create_playlist(uri, name) |
||
41 |
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.