Passed
Push — master ( b25270...aeb165 )
by Dean
03:03
created

Movies.on_removed()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125
Metric Value
cc 1
dl 0
loc 3
ccs 1
cts 2
cp 0.5
crap 1.125
rs 10
1 1
from plugin.core.session_status import SessionStatus
2 1
from plugin.sync.core.enums import SyncData, SyncMedia, SyncMode
3 1
from plugin.sync.handlers.core import DataHandler, PushHandler, bind
4 1
from plugin.sync.handlers.watched.base import WatchedHandler
5
6 1
import logging
7
8 1
log = logging.getLogger(__name__)
9
10
11 1
class Base(PushHandler, WatchedHandler):
0 ignored issues
show
Bug introduced by
The method fast_pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method full which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method on_added which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method on_changed which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method on_removed which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
12 1
    def push(self, p_item, t_item, key, **kwargs):
13
        # Ensure item isn't currently being watched in plex
14
        if SessionStatus.is_watching(self.current.account.id, key):
15
            log.debug('Item %r is currently being watched, ignoring push watched handler', key)
16
            return
17
18
        super(Base, self).push(
19
            p_item, t_item,
20
            key=key,
21
            **kwargs
22
        )
23
24
25 1
class Movies(Base):
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...
Bug introduced by
The method fast_pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method full which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method on_changed which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
26 1
    media = SyncMedia.Movies
27
28 1
    @bind('added', [SyncMode.Full, SyncMode.Push])
29
    def on_added(self, key, guid, p_item, p_value, t_value, **kwargs):
30
        # Retrieve plex `view_count`
31
        p_settings = p_item.get('settings', {})
32
        p_view_count = p_settings.get('view_count', 0)
33
34
        log.debug('Movies.on_added(%r, ...) - p_view_count: %r, p_value: %r, t_value: %r', key, p_view_count, p_value, t_value)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (127/120).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
35
36
        if t_value:
37
            return
38
39
        self.store_movie('add', guid,
40
            p_item,
41
            watched_at=p_value
42
        )
43
44 1
    @bind('removed', [SyncMode.Full, SyncMode.Push])
45
    def on_removed(self, key, t_value, **kwargs):
0 ignored issues
show
Unused Code introduced by
The argument t_value seems to be unused.
Loading history...
46
        log.debug('Movies.on_removed(%r, ...)', key)
47
48
49 1
class Episodes(Base):
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...
Bug introduced by
The method fast_pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method full which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method on_changed which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method pull which was declared abstract in the super-class MediaHandler
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
50 1
    media = SyncMedia.Episodes
51
52 1
    @bind('added', [SyncMode.Full, SyncMode.Push])
53
    def on_added(self, key, guid, identifier, p_show, p_item, p_value, t_value, **kwargs):
54
        # Retrieve plex `view_count`
55
        p_settings = p_item.get('settings', {})
56
        p_view_count = p_settings.get('view_count', 0)
57
58
        log.debug('Episodes.on_added(%r, ...) - p_view_count: %r, p_value: %r, t_value: %r', key, p_view_count, p_value, t_value)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (129/120).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
59
60
        if t_value:
61
            return
62
63
        self.store_episode('add', guid,
64
            identifier, p_show,
65
            watched_at=p_value
66
        )
67
68 1
    @bind('removed', [SyncMode.Full, SyncMode.Push])
69
    def on_removed(self, key, t_value, **kwargs):
0 ignored issues
show
Unused Code introduced by
The argument t_value seems to be unused.
Loading history...
70
        log.debug('Episodes.on_removed(%r, ...)', key)
71
72
73 1
class Push(DataHandler):
74 1
    data = SyncData.Watched
75 1
    mode = SyncMode.Push
76
77 1
    children = [
78
        Movies,
79
        Episodes
80
    ]
81