Passed
Push — beta ( 1d082f...70e2cb )
by Dean
02:56
created

RatingsHandler.get_operands()   F

Complexity

Conditions 9

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 72.7133

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 1
cts 13
cp 0.0769
rs 3
c 0
b 0
f 0
cc 9
crap 72.7133
1 1
from plugin.sync.handlers.core import MediaHandler
2
3
4 1
class RatingsHandler(MediaHandler):
0 ignored issues
show
Bug introduced by
The method build_action 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 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 get_action 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...
Bug introduced by
The method push 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...
5 1
    @staticmethod
6
    def get_operands(p_item, t_item):
7
        # Retrieve plex rating from item
8
        if p_item is not None:
9
            p_rating = p_item.get('settings', {}).get('rating')
10
        else:
11
            p_rating = None
12
13
        # Convert rating to integer
14
        if p_rating is not None:
15
            p_rating = int(p_rating)
16
17
        # Retrieve trakt rating from item
18
        if type(t_item) is dict:
19
            t_rating = t_item.get('rating')
20
        else:
21
            t_rating = t_item.rating if t_item else None
22
23
        # Convert trakt `Rating` objects to plain rating values
24
        if type(t_rating) is tuple:
25
            t_rating = tuple([
26
                (r.value if r else None)
27
                for r in t_rating
28
            ])
29
        else:
30
            t_rating = t_rating.value if t_rating else None
31
32
        return p_rating, t_rating
33