Пример #1
0
    def onDeckShows(self):
        hidden_shows = HiddenDatabase().get_hidden_items(
            'progress_watched', 'shows')
        trakt_list = trakt.json_response('sync/playback/episodes', limit=True)

        if trakt_list is None:
            return
        trakt_list = [
            i for i in trakt_list
            if i['show']['ids']['trakt'] not in hidden_shows
        ]
        trakt_list = sorted(
            trakt_list,
            key=lambda i: tools.datetime_workaround(i['paused_at'][:19],
                                                    format="%Y-%m-%dT%H:%M:%S",
                                                    date_only=False),
            reverse=True)
        filter_list = []
        showList = []
        sort_list = []
        for i in trakt_list:
            if i['show']['ids']['trakt'] not in filter_list:
                if int(i['progress']) != 0:
                    showList.append(i)
                    filter_list.append(i['show']['ids']['trakt'])
                    sort_list.append(i['show']['ids']['trakt'])

        sort = {'type': 'showInfo', 'id_list': sort_list}
        self.mixedEpisodeBuilder(showList, sort=sort)
        tools.closeDirectory('tvshows')
Пример #2
0
    def newShows(self):

        hidden = HiddenDatabase().get_hidden_items('recommendations', 'shows')
        datestring = datetime.datetime.today() - datetime.timedelta(days=29)
        trakt_list = database.get(
            trakt.json_response, 12,
            'calendars/all/shows/new/%s/30?languages=%s' %
            (datestring.strftime('%d-%m-%Y'), language_code))

        if trakt_list is None:
            return
        # For some reason trakt messes up their list and spits out tons of duplicates so we filter it
        duplicate_filter = []
        temp_list = []
        for i in trakt_list:
            if not i['show']['ids']['tvdb'] in duplicate_filter:
                duplicate_filter.append(i['show']['ids']['tvdb'])
                temp_list.append(i)

        trakt_list = temp_list

        trakt_list = [
            i for i in trakt_list if i['show']['ids']['trakt'] not in hidden
        ]

        if len(trakt_list) > 40:
            trakt_list = trakt_list[:40]
        self.showListBuilder(trakt_list)
        tools.closeDirectory('tvshows')
Пример #3
0
 def myRecentEpisodes(self):
     hidden_shows = HiddenDatabase().get_hidden_items('calendar', 'shows')
     datestring = datetime.datetime.today() - datetime.timedelta(days=13)
     trakt_list = database.get(
         trakt.json_response, 12,
         'calendars/my/shows/%s/14' % datestring.strftime('%d-%m-%Y'))
     if trakt_list is None:
         return
     trakt_list = [
         i for i in trakt_list
         if i['show']['ids']['trakt'] not in hidden_shows
     ]
     self.mixedEpisodeBuilder(trakt_list)
     tools.closeDirectory('episodes')
Пример #4
0
    def myNextUp(self, ):

        tv_database = TraktSyncDatabase()
        watched_shows = tv_database.get_watched_shows()
        hidden_shows = HiddenDatabase().get_hidden_items(
            'progress_watched', 'shows')

        watched_shows = [
            i for i in watched_shows if i['trakt_id'] not in hidden_shows
        ]
        watched_episodes = TraktSyncDatabase().get_watched_episodes()

        self._start_queue_workers()

        for show in watched_shows:
            self.task_queue.put(
                (self._get_next_episode_to_watch, (show, watched_episodes)),
                block=True)

        self._finish_queue_workers()

        if tools.getSetting('nextup.sort') == '1':
            watched_list = trakt.json_response('users/me/watched/shows')
            watched_list = sorted(watched_list,
                                  key=lambda i: i['last_watched_at'],
                                  reverse=True)
            watched_list = [i['show']['ids']['trakt'] for i in watched_list]
            sort = {'type': 'showInfo', 'id_list': watched_list}
        else:
            sort = None

        episodes = self.itemList
        self.itemList = []

        self.mixedEpisodeBuilder(episodes, sort=sort, hide_watched=True)

        tools.closeDirectory('tvshows')
Пример #5
0
from resources.lib.modules import database
from resources.lib.modules.trakt_sync import bookmark
from resources.lib.modules.trakt_sync.hidden import TraktSyncDatabase as HiddenDatabase
from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase

sysaddon = sys.argv[0]
try:
    syshandle = int(sys.argv[1])
except:
    syshandle = ''
trakt = TraktAPI()

language_code = tools.get_language_code()

trakt_database = TraktSyncDatabase()
hidden_database = HiddenDatabase()
bookmark_sync = bookmark.TraktSyncDatabase()


class Menus:
    def __init__(self):
        self.itemList = []
        self.direct_episode_threads = []
        self.title_appends = tools.getSetting('general.appendtitles')
        self.task_queue = ThreadPool()

    ######################################################
    # MENUS
    ######################################################

    def onDeckShows(self):