Passed
Push — develop ( 08e1cf...7492d1 )
by Dean
02:39
created

StoppedHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
dl 0
loc 18
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 11 5
1 1
from plugin.scrobbler.core import SessionEngine, SessionHandler
2
3
4 1
@SessionEngine.register
5 1
class StoppedHandler(SessionHandler):
6 1
    __event__ = 'stopped'
7
8 1
    __src__ = ['pause', 'start', 'stop']
9 1
    __dst__ = ['stop']
10
11 1
    @classmethod
12
    def process(cls, session, payload):
13
        # Handle media change
14 1
        if cls.has_media_changed(session, payload) and session.state in ['start', 'pause']:
15
            yield 'stop', session.payload
16
17
        # Handle current media
18 1
        if session.state in ['start', 'pause']:
19 1
            yield 'stop', payload
20 1
        elif session.state == 'stop':
21
            yield None, payload
22