Code Duplication    Length = 36-36 lines in 3 locations

Trakttv.bundle/Contents/Libraries/Shared/plugin/preferences/options/o_sync/idle_delay.py 1 location

@@ 12-47 (lines=36) @@
9
log = logging.getLogger(__name__)
10
11
12
class SyncIdleDelayOption(SimpleOption):
13
    key = 'sync.idle_delay'
14
    type = 'enum'
15
16
    choices = IDLE_DELAY_LABELS_BY_KEY
17
    default = SyncIdleDelay.M30
18
    scope = 'server'
19
20
    group = ('Advanced', 'Sync - Triggers')
21
    label = 'Idle delay'
22
    order = 131
23
24
    preference = 'sync_idle_delay'
25
26
    def on_database_changed(self, value, account=None):
27
        if value not in IDLE_DELAY_IDS_BY_KEY:
28
            log.warn('Unknown value: %r', value)
29
            return
30
31
        # Map `value` to plex preference
32
        value = IDLE_DELAY_IDS_BY_KEY[value]
33
34
        # Update preference
35
        return self._update_preference(value, account)
36
37
    def on_plex_changed(self, value, account=None):
38
        if value not in IDLE_DELAY_KEYS_BY_LABEL:
39
            log.warn('Unknown value: %r', value)
40
            return
41
42
        # Map plex `value`
43
        value = IDLE_DELAY_KEYS_BY_LABEL[value]
44
45
        # Update database
46
        self.update(value, account, emit=False)
47
        return value
48

Trakttv.bundle/Contents/Libraries/Shared/plugin/preferences/options/activity.py 1 location

@@ 10-45 (lines=36) @@
7
log = logging.getLogger(__name__)
8
9
10
class ActivityOption(SimpleOption):
11
    key = 'activity.mode'
12
    type = 'enum'
13
14
    choices = ACTIVITY_LABELS_BY_KEY
15
    default = ActivityMode.Automatic
16
    scope = 'server'
17
18
    group = ('Advanced', 'Activity')
19
    label = 'Method'
20
    order = 100
21
22
    preference = 'activity_mode'
23
24
    def on_database_changed(self, value, account=None):
25
        if value not in ACTIVITY_IDS_BY_KEY:
26
            log.warn('Unknown value: %r', value)
27
            return
28
29
        # Map `value` to plex preference
30
        value = ACTIVITY_IDS_BY_KEY[value]
31
32
        # Update preference
33
        return self._update_preference(value, account)
34
35
    def on_plex_changed(self, value, account=None):
36
        if value not in ACTIVITY_KEYS_BY_LABEL:
37
            log.warn('Unknown value: %r', value)
38
            return
39
40
        # Map plex `value`
41
        value = ACTIVITY_KEYS_BY_LABEL[value]
42
43
        # Update database
44
        self.update(value, emit=False)
45
        return value
46

Trakttv.bundle/Contents/Libraries/Shared/plugin/preferences/options/scrobble_duplication_period.py 1 location

@@ 12-47 (lines=36) @@
9
log = logging.getLogger(__name__)
10
11
12
class ScrobbleDuplicationPeriodOption(SimpleOption):
13
    key = 'scrobble.duplication_period'
14
    type = 'enum'
15
16
    choices = DUPLICATION_PERIOD_LABELS_BY_KEY
17
    default = ScrobbleDuplicationPeriod.H6
18
    scope = 'server'
19
20
    group = ('Advanced', 'Scrobble')
21
    label = 'Ignore duplicates for'
22
    order = 115
23
24
    preference = 'scrobble_duplication_period'
25
26
    def on_database_changed(self, value, account=None):
27
        if value not in DUPLICATION_PERIOD_IDS_BY_KEY:
28
            log.warn('Unknown value: %r', value)
29
            return
30
31
        # Map `value` to plex preference
32
        value = DUPLICATION_PERIOD_IDS_BY_KEY[value]
33
34
        # Update preference
35
        return self._update_preference(value, account)
36
37
    def on_plex_changed(self, value, account=None):
38
        if value not in DUPLICATION_PERIOD_KEYS_BY_LABEL:
39
            log.warn('Unknown value: %r', value)
40
            return
41
42
        # Map plex `value`
43
        value = DUPLICATION_PERIOD_KEYS_BY_LABEL[value]
44
45
        # Update database
46
        self.update(value, account, emit=False)
47
        return value
48