Пример #1
0
    def __init__(self):
        self.trakt_api = trakt.TraktAPI()
        self.pre_cache_initiated = False
        self.play_next_triggered = False
        self.trakt_id = None
        self.media_type = None
        self.offset = None
        self.media_length = 0
        self.current_time = 0
        self.args = {}
        self.playback_started = False
        self.playing_file = None
        self.AVStarted = False
        self.scrobbling_enabled = tools.getSetting(
            'trakt.scrobbling') == 'true'
        self.scrobbled = False
        self.original_action_args = ''
        self.smart_playlists = tools.getSetting('smartplay.playlistcreate')
        self.smart_module = None
        self.ignoreSecondsAtStart = int(
            tools.get_advanced_setting('video', 'ignoresecondsatstart'))
        self.ignorePercentAtEnd = int(
            tools.get_advanced_setting('video', 'ignorepercentatend'))
        self.playCountMinimumPercent = int(
            tools.get_advanced_setting('video', 'playcountminimumpercent'))

        self.min_time_before_scrape = int(tools.getSetting('playingnext.time')) + \
                                      int(int(tools.getSetting('general.timeout'))) + 20
        self.marked_watched = False
        tools.player.__init__(self)
Пример #2
0
    def traktStopWatching(self, override_progress=None):
        if not self.trakt_integration():
            return

        self.handleBookmark()

        if self.scrobbling_enabled and not self.scrobbled:
            post_data = self.buildTraktObject(
                override_progress=override_progress)
            try:
                scrobble_response = self.trakt_api.json_response(
                    'scrobble/stop', postData=post_data, limit=False)

                # Consider the scrobble attempt a failure if the attempt returns a None value
                if scrobble_response is not None:
                    self.scrobbled = True
            except:
                pass

            try:
                if post_data['progress'] >= 80:

                    if self.media_type == 'episode':
                        from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
                        TraktSyncDatabase().mark_episode_watched_by_id(
                            self.trakt_id)

                    if self.media_type == 'movie':
                        from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase
                        TraktSyncDatabase().mark_movie_watched(self.trakt_id)

            except:
                import traceback
                traceback.print_exc()
                pass

        elif not self.scrobbling_enabled and not self.marked_watched:
            if int(self.getWatchedPercent()) >= int(
                    tools.get_advanced_setting('video',
                                               'playcountminimumpercent')):
                if self.media_type == 'episode':
                    from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
                    TraktSyncDatabase().mark_episode_watched_by_id(
                        self.trakt_id)
                else:
                    from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase
                    TraktSyncDatabase().mark_movie_watched(self.trakt_id)