示例#1
0
    def is_duplicate(cls, action):
        if action.event != 'scrobble/stop':
            return False

        # Retrieve scrobble duplication period
        duplication_period = Preferences.get('scrobble.duplication_period')

        if duplication_period is None:
            return False

        # Check for duplicate scrobbles in `duplication_period`
        scrobbled = ActionHistory.has_scrobbled(
            action.account, action.rating_key,
            part=action.part,
            after=action.queued_at - timedelta(minutes=duplication_period)
        )

        if scrobbled:
            log.info(
                'Ignoring duplicate %r action, scrobble already performed in the last %d minutes',
                action.event, duplication_period
            )
            return True

        return False
示例#2
0
    def is_duplicate(cls, action):
        if action.event != 'scrobble/stop':
            return False

        # Retrieve scrobble duplication period
        duplication_period = Preferences.get('scrobble.duplication_period')

        if duplication_period is None:
            return False

        # Check for duplicate scrobbles in `duplication_period`
        scrobbled = ActionHistory.has_scrobbled(
            action.account, action.rating_key,
            after=action.queued_at - timedelta(minutes=duplication_period)
        )

        if scrobbled:
            log.info(
                'Ignoring duplicate %r action, scrobble already performed in the last %d minutes',
                action.event, duplication_period
            )
            return True

        return False