Passed
Push — develop ( 850286...2f2c0e )
by Dean
03:07 queued 32s
created

Watchlist   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 31.25%
Metric Value
dl 0
loc 43
ccs 5
cts 16
cp 0.3125
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
B run() 0 29 2
A create_playlist() 0 8 2
1 1
from plugin.sync.core.enums import SyncData, SyncMedia, SyncMode
2 1
from plugin.sync.modes.pull.lists.base import Lists
3
4 1
import elapsed
5 1
import logging
6
7 1
log = logging.getLogger(__name__)
8
9
10 1
class Watchlist(Lists):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This class has no __init__ method.
Loading history...
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()
0 ignored issues
show
Bug introduced by
The Instance of Watchlist does not seem to have a member named sections.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Unused Code introduced by
The variable p_sections seems to be unused.
Loading history...
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,
0 ignored issues
show
Bug introduced by
The Instance of Watchlist does not seem to have a member named current.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
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:
0 ignored issues
show
Bug introduced by
The Instance of Watchlist does not seem to have a member named configuration.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
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