Пример #1
0
    def removePlaybackHistory(self, trakt_object):
        type = 'movie'
        multi_type = 'movies'

        if 'episodes' in trakt_object:
            type = 'episode'
            multi_type = 'episodes'

        progress = self.json_response('sync/playback/%s' % multi_type,
                                      limit=False)
        progress = [i for i in progress if i['type'] == type]
        progress = [
            i for i in progress if i[type]['ids']['trakt'] ==
            trakt_object[multi_type][0]['ids']['trakt']
        ]

        for i in progress:
            self.delete_request('sync/playback/%s' % i['id'])

        from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase
        TraktSyncDatabase().remove_bookmark(
            trakt_object[multi_type][0]['ids']['trakt'])

        tools.container_refresh()
        tools.trigger_widget_refresh()
        tools.showDialog.notification(tools.addonName, tools.lang(40295))
Пример #2
0
    def hideItem(self, trakt_object):
        from resources.lib.modules.trakt_sync.hidden import TraktSyncDatabase

        sections = ['progress_watched', 'calendar']
        sections_display = [tools.lang(40291), tools.lang(40292)]
        selection = tools.showDialog.select('{}: {}'.format(tools.addonName, tools.lang(40293)), sections_display)
        if selection == -1:
            return
        section = sections[selection]

        if trakt_object['item_type'] in ['season', 'show', 'episode']:
            trakt_object = {'shows': [{'ids': {'trakt': trakt_object['trakt_id']}}]}
        elif trakt_object['item_type'] == 'movie':
            trakt_object = {'movies': [{'ids': {'trakt': trakt_object['trakt_id']}}]}

        self.json_response('users/hidden/%s' % section, postData=trakt_object)

        if 'movies' in trakt_object:
            trakt_object = trakt_object['movies'][0]
            TraktSyncDatabase().add_hidden_item(trakt_object['ids']['trakt'], 'movie', section)
        if 'shows' in trakt_object:
            trakt_object = trakt_object['shows'][0]
            TraktSyncDatabase().add_hidden_item(trakt_object['ids']['trakt'], 'show', section)

        tools.container_refresh()
        tools.trigger_widget_refresh()
        tools.showDialog.notification(tools.addonName, tools.lang(40294) % sections_display[selection])
Пример #3
0
 def removeFromWatchlist(self, trakt_object):
     self.post_request('sync/watchlist/remove', postData=trakt_object)
     tools.container_refresh()
     tools.trigger_widget_refresh()
     tools.showDialog.notification(
         '{}: {}'.format(tools.addonName, tools.lang(40280)),
         tools.lang(40287))
Пример #4
0
 def removeFromList(self, trakt_object):
     lists = self.getLists()
     selection = tools.showDialog.select('{}: {}'.format(tools.addonName, tools.lang(40290)),
                                         [i['name'] for i in lists])
     selection = lists[selection]
     self.json_response('users/me/lists/%s/items/remove' % selection['ids']['trakt'], postData=trakt_object)
     tools.container_refresh()
     tools.trigger_widget_refresh()
     tools.showDialog.notification('{}: {}'.format(tools.addonName, tools.lang(40280)),
                                   tools.lang(40289) % selection['name'])
Пример #5
0
    def keepAlive(self):
        tools.kodi.sleep(5000)
        for i in range(0, 240):
            if self.isPlayingVideo(): break
            tools.kodi.sleep(1000)

        while self.isPlayingVideo():
            try:
                if not self.playback_started:
                    tools.kodi.sleep(1000)
                    continue

                if not self.playback_started:
                    self.start_playback()

                if self.offset is not None and int(
                        self.offset) != 0 and self.playback_resumed is False:
                    tools.log("Seeking %s seconds" % self.offset, 'info')
                    self.seekTime(self.offset)
                    self.offset = None
                    self.playback_resumed = True
                else:
                    self.playback_resumed = True

                try:
                    self.current_time = self.getTime()
                    self.media_length = self.getTotalTime()
                except:
                    pass

                if self.pre_cache_initiated is False:
                    try:
                        if self.getWatchedPercent() > 80 and tools.getSetting(
                                'smartPlay.preScrape') == 'true':
                            self.pre_cache_initiated = True
                            smartPlay.SmartPlay(
                                self.original_action_args).pre_scrape()
                    except:
                        pass

                if self.getWatchedPercent() > 80 and not self.scrobbled:
                    self.traktStopWatching()
                    tools.trigger_widget_refresh()

            except:
                import traceback
                traceback.print_exc()
                tools.kodi.sleep(1000)
                continue

            tools.kodi.sleep(3000)

        self.traktStopWatching()
Пример #6
0
    def markWatched(self, trakt_object, actionArgs, silent=False):
        response = self.json_response('sync/history', postData=trakt_object)

        if 'episodes' in trakt_object:
            if not silent:
                if not self.confirm_marked_watched(response, 'episodes'):
                    return
            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            trakt_object = trakt_object['episodes'][0]
            TraktSyncDatabase().mark_episode_watched_by_id(
                trakt_object['ids']['trakt'])
            from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase
            TraktSyncDatabase().remove_bookmark(trakt_object['ids']['trakt'])

        elif 'seasons' in trakt_object:
            if not silent:
                if not self.confirm_marked_watched(response, 'episodes'):
                    return
            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            show_id = actionArgs['trakt_id']
            season_no = trakt_object['seasons'][0]['number']
            TraktSyncDatabase().mark_season_watched(show_id, season_no, 1)

        elif 'shows' in trakt_object:
            if not silent:
                if not self.confirm_marked_watched(response, 'episodes'):
                    return
            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            trakt_object = trakt_object['shows'][0]
            TraktSyncDatabase().mark_show_watched(trakt_object['ids']['trakt'],
                                                  1)

        elif 'movies' in trakt_object:
            if not silent:
                if not self.confirm_marked_watched(response, 'movies'):
                    return
            from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase
            trakt_object = trakt_object['movies'][0]
            TraktSyncDatabase().mark_movie_watched(
                trakt_object['ids']['trakt'])
            from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase
            TraktSyncDatabase().remove_bookmark(trakt_object['ids']['trakt'])

        tools.showDialog.notification(
            '{}: {}'.format(tools.addonName, tools.lang(40280)),
            tools.lang(40282))
        if not silent:
            tools.container_refresh()
            tools.trigger_widget_refresh()
Пример #7
0
    def addToCollection(self, trakt_object):
        if 'movies' in trakt_object:
            self.post_request('sync/collection', postData=trakt_object)
            from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase
            trakt_object = trakt_object['movies'][0]
            TraktSyncDatabase().mark_movie_collected(trakt_object['ids']['trakt'])
        else:
            trakt_object = {'shows': [{'ids': {'trakt': trakt_object['show_id']}}]}
            self.post_request('sync/collection', postData=trakt_object)
            from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase
            TraktSyncDatabase()._sync_collection_shows()

        tools.container_refresh()
        tools.trigger_widget_refresh()
        tools.showDialog.notification('{}: {}'.format(tools.addonName, tools.lang(40280)), tools.lang(40284))
Пример #8
0
    def markUnwatched(self, trakt_object, actionArgs):

        response = self.json_response('sync/history/remove',
                                      postData=trakt_object)

        if 'episodes' in trakt_object:
            if not self.confirm_marked_unwatched(response, 'episodes'):
                return
            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            trakt_object = trakt_object['episodes'][0]
            TraktSyncDatabase().mark_episode_unwatched_by_id(
                trakt_object['ids']['trakt'])

        elif 'seasons' in trakt_object:

            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            if not self.confirm_marked_unwatched(response, 'episodes'):
                return
            show_id = actionArgs['trakt_id']
            season_no = trakt_object['seasons'][0]['number']
            TraktSyncDatabase().mark_season_watched(show_id, season_no, 0)

        elif 'shows' in trakt_object:
            from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase
            if not self.confirm_marked_unwatched(response, 'episodes'):
                return
            trakt_object = trakt_object['shows'][0]
            TraktSyncDatabase().mark_show_watched(trakt_object['ids']['trakt'],
                                                  0)

        elif 'movies' in trakt_object:
            from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase
            if not self.confirm_marked_unwatched(response, 'movies'):
                return
            trakt_object = trakt_object['movies'][0]
            TraktSyncDatabase().mark_movie_unwatched(
                trakt_object['ids']['trakt'])

        tools.showDialog.notification(tools.addonName + ': Trakt Manager',
                                      'Item marked as unwatched')
        tools.trigger_widget_refresh()
Пример #9
0
 def refresh_meta_information(self, trakt_object):
     from resources.lib.modules import trakt_sync
     trakt_sync.TraktSyncDatabase().clear_specific_meta(trakt_object)
     tools.container_refresh()
     tools.trigger_widget_refresh()
Пример #10
0
 def commonEndPlayBack(self):
     self.handleBookmark()
     self.traktStopWatching()
     tools.container_refresh()
     tools.trigger_widget_refresh()
Пример #11
0
 def onPlayBackEnded(self):
     if not self.scrobbled:
         self.traktStopWatching()
         tools.trigger_widget_refresh()
     pass