Ejemplo n.º 1
0
    def showsPlayed(self, page):
        traktList = database.get(trakt.json_response, 12,
                                 'shows/played?page=%s&extended=full' % page)

        self.showListBuilder(traktList)
        tools.addDirectoryItem(tools.lang(32019),
                               'showsPlayed&page=%s' % (int(page) + 1), '', '')
        tools.closeDirectory('tvshows')
    def myNextUp(self, ):
        hidden_shows = trakt.get_trakt_hidden_items('watched')['shows']
        self.threadList = []
        watched = trakt.json_response('users/me/watched/shows?extended=full',
                                      limit=False)
        if watched is None:
            return
        watch_list = []
        for i in watched:
            if i is not None:
                watch_list.append(i)

        watched = [
            i for i in watched if i['show']['ids']['trakt'] not in hidden_shows
        ]
        if tools.getSetting('nextup.sort') == '1':
            watched = sorted(watched,
                             key=lambda i: tools.datetime_workaround(
                                 i['last_watched_at'][:19],
                                 format="%Y-%m-%dT%H:%M:%S",
                                 date_only=False),
                             reverse=True)

            sort = {
                'type': 'showInfo',
                'id_list': [i['show']['ids']['trakt'] for i in watched]
            }
        else:
            sort = None

        for i in watched:
            self.threadList.append(
                Thread(target=self.traktProgressWorker, args=(i, )))
        self.runThreads()
        self.threadList = []
        next_up = self.itemList

        self.itemList = []
        next_list = []
        for i in next_up:
            try:
                if i['progress']['next_episode'] is not None:
                    next_list.append(i)
            except:
                pass

        build_list = []

        for i in next_list:
            item = {
                'show': i['show'],
                'episode': i['progress']['next_episode']
            }
            build_list.append(item)

        self.directToEpisodeBuilder(build_list, sort=sort)

        tools.closeDirectory('episodes')
Ejemplo n.º 3
0
    def getListItems(self, arguments, page):
        from resources.lib.modules import database
        page = int(page)

        arguments = json.loads(tools.unquote(arguments))
        media_type = arguments['type']
        list_items = database.get(
            self.json_response, 12,
            'users/%s/lists/%s/items/%s?extended=full' % (
                arguments['username'],
                arguments['trakt_id'],
                media_type,
            ), None, False)
        if media_type == 'movies':
            media_type = 'movie'

        if media_type == 'shows':
            media_type = 'show'

        page_limit = int(tools.getSetting('item.limit'))

        list_items = self.sort_list(arguments['sort_by'],
                                    arguments['sort_how'], list_items,
                                    media_type)
        list_items = tools.paginate_list(list_items, page, page_limit)

        next = False

        if len(list_items) == page_limit:
            next = True

        if media_type == 'show':
            list_items = [
                i['show'] for i in list_items
                if i['type'] == 'show' and i is not None
            ]
            from resources.lib.gui import tvshowMenus
            tvshowMenus.Menus().showListBuilder(list_items)

        if media_type == 'movie':
            list_items = [
                i['movie'] for i in list_items
                if i['type'] == 'movie' and i is not None
            ]
            from resources.lib.gui import movieMenus
            movieMenus.Menus().commonListBuilder(list_items)

        content_type = 'tvshows'

        if media_type == 'movie':
            content_type = 'movies'
        if next:
            tools.addDirectoryItem(
                'Next', 'traktList&page=%s&actionArgs=%s' %
                (page + 1, tools.quote(json.dumps(arguments))), None, None)

        tools.closeDirectory(content_type)
        return
Ejemplo n.º 4
0
 def myMovieCollection(self):
     try:
         traktList = trakt.json_response('users/me/collection/movies',
                                         limit=False)
         self.commonListBuilder(traktList)
         tools.closeDirectory('movies', viewType=self.viewType)
     except:
         import traceback
         traceback.print_exc()
Ejemplo n.º 5
0
    def seasonEpisodes(self, args):

        args = json.loads(tools.unquote(args))

        traktList = trakt.json_response('shows/%s/seasons/%s?extended=full' % (args['showInfo']['ids']['trakt'],
                                                                 args['seasonInfo']['info']['season']))

        self.episodeListBuilder(traktList, args)
        tools.closeDirectory('episodes', sort='episode')
Ejemplo n.º 6
0
    def showSeasons(self, args):

        showInfo = json.loads(tools.unquote(args))

        traktList = trakt.json_response('shows/%s/seasons?extended=full' % showInfo['ids']['trakt'])

        self.seasonListBuilder(traktList, showInfo)

        tools.closeDirectory('seasons', sort='title')
Ejemplo n.º 7
0
    def showsUpdated(self, page):
        import datetime
        date = datetime.date.today() - datetime.timedelta(days=31)
        date = date.strftime('%Y-%m-%d')
        traktList = trakt.json_response('shows/updates/%s?page=%s&extended=full' % (date, page))

        self.showListBuilder(traktList)
        tools.addDirectoryItem(tools.lang(32019), 'showsUpdated&page=%s' % (int(page) + 1), '', '')
        tools.closeDirectory('tvshows')
Ejemplo n.º 8
0
 def myRecentEpisodes(self):
     datestring = datetime.datetime.today() - datetime.timedelta(days=7)
     hidden = trakt.json_response('/users/hidden/progress_watched?type=show')
     hidden += trakt.json_response('/users/hidden/calendar?type=show')
     trakt_list = trakt.json_response('calendars/my/shows/%s/7?extended=full' % datestring.strftime('%d-%m-%Y'))
     if len(trakt_list) > 100:
         trakt_list = trakt_list[:100]
     self.directToEpisodeBuilder(trakt_list)
     tools.closeDirectory('episodes')
Ejemplo n.º 9
0
 def providerMenu(self):
     tools.addDirectoryItem(tools.lang(40082).encode('utf-8'), 'manualProviderUpdate', None, None)
     tools.addDirectoryItem(tools.lang(40071).encode('utf-8'), 'installProviders', None, None)
     tools.addDirectoryItem(tools.lang(40072).encode('utf-8'), 'uninstallProviders', None, None)
     tools.addDirectoryItem(tools.lang(40073).encode('utf-8'), 'adjustPackage&actionArgs=disabled', None, None)
     tools.addDirectoryItem(tools.lang(40074).encode('utf-8'), 'adjustPackage&actionArgs=enabled', None, None)
     tools.addDirectoryItem(tools.lang(40076).encode('utf-8'), 'adjustProviders&actionArgs=disabled', None, None)
     tools.addDirectoryItem(tools.lang(40077).encode('utf-8'), 'adjustProviders&actionArgs=enabled', None, None)
     tools.closeDirectory('addons', cacheToDisc=True)
Ejemplo n.º 10
0
 def myWatchedMovies(self, page):
     if page is None:
         page = 1
     watched_movies = trakt.json_response('/sync/history/movies/?page=%s' % page)
     self.commonListBuilder(watched_movies)
     page = int(page)
     tools.addDirectoryItem(tools.lang(32019),
                            'myWatchedMovies&page={}'.format(page + 1))
     tools.closeDirectory('movies')
Ejemplo n.º 11
0
 def movieGenres(self):
     tools.addDirectoryItem(tools.lang(32065), 'movieGenresGet', isFolder=True)
     genres = database.get(trakt.json_response, 24, 'genres/movies')
     if genres is None:
         tools.cancel_directory()
         return
     for i in genres:
         tools.addDirectoryItem(i['name'], 'movieGenresGet&actionArgs=%s' % i['slug'], isFolder=True)
     tools.closeDirectory('genres')
Ejemplo n.º 12
0
 def moviesSearchResults(self, query):
     query = tools.quote_plus(tools.unquote(query))
     trakt_list = trakt.json_response('search/movie?query=%s' % query)
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.commonListBuilder([movie for movie in trakt_list if float(movie['score']) > 0])
     tools.closeAllDialogs()
     tools.closeDirectory('movies')
Ejemplo n.º 13
0
 def moviesAnticipated(self, page):
     trakt_list = database.get(trakt.json_response, 12, 'movies/anticipated?page=%s' % page)
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.commonListBuilder(trakt_list)
     tools.addDirectoryItem(tools.lang(32019), 'moviesAnticipated&page=%s' % (int(page) + 1),
                            isFolder=True)
     tools.closeDirectory('movies')
Ejemplo n.º 14
0
    def showsRelated(self, args):
        trakt_list = database.get(trakt.json_response, 12,
                                  'shows/%s/related' % args)
        if trakt_list is None:
            tools.cancel_directory()
            return

        self.showListBuilder(trakt_list)
        tools.closeDirectory('tvshows')
Ejemplo n.º 15
0
 def myFilesFolder(self, args):
     args = json.loads(args)
     tools.log(args)
     if args['id'] is None:
         tools.log('isNone')
         self.providers[args['debrid_provider']][1]().get_init_list()
     else:
         self.providers[args['debrid_provider']][1]().get_folder(args)
     tools.closeDirectory('addons', sort='title')
Ejemplo n.º 16
0
    def moviesPopular(self, page):
        trakt_list = database.get(trakt.json_response, 12, 'movies/popular?page=%s' % page)

        if trakt_list is None:
            return
        self.commonListBuilder(trakt_list)
        tools.addDirectoryItem(tools.lang(32019), 'moviesPopular&page=%s' % (int(page) + 1), '', '',
                               isFolder=True)
        tools.closeDirectory('movies')
Ejemplo n.º 17
0
 def myShows(self):
     tools.addDirectoryItem(tools.lang(32063).encode('utf-8'), 'onDeckShows', None, None)
     tools.addDirectoryItem(tools.lang(32017).encode('utf-8'), 'showsMyCollection', '', '')
     tools.addDirectoryItem(tools.lang(32018).encode('utf-8'), 'showsMyWatchlist', '', '')
     tools.addDirectoryItem('Next Up', 'showsNextUp', '', '')
     tools.addDirectoryItem('Unfinished Shows in Collection', 'showsMyProgress', '', '')
     tools.addDirectoryItem('Recent Episodes', 'showsMyRecentEpisodes', '', '')
     tools.addDirectoryItem('My Show Lists', 'myTraktLists&actionArgs=shows', '', '')
     tools.closeDirectory('addons', cacheToDisc=True)
Ejemplo n.º 18
0
    def showsPopular(self, page):
        trakt_list = database.get(trakt.json_response, 12, 'shows/popular?page=%s&extended=full' % page)

        if trakt_list is None:
            return

        self.showListBuilder(trakt_list)
        tools.addDirectoryItem(tools.lang(32019).encode('utf-8'), 'showsPopular&page=%s' % (int(page) + 1), '', '')
        tools.closeDirectory('tvshows')
Ejemplo n.º 19
0
    def showsRecommended(self):

        traktList = database.get(trakt.json_response,
                                 12,
                                 'recommendations/shows?extended=full',
                                 limit=True,
                                 limitOverride=100)
        self.showListBuilder(traktList)
        tools.closeDirectory('tvshows')
Ejemplo n.º 20
0
 def myWatchedEpisodes(self, page):
     if page is None:
         page = 1
     watched_episodes = trakt.json_response('/sync/history/episodes/?page=%s' % page)
     self.mixedEpisodeBuilder(watched_episodes, sort=False, hide_watched=False, hide_unaired=False)
     page = int(page)
     tools.addDirectoryItem(tools.lang(32019),
                            'myWatchedEpisodes&page={}'.format(page + 1))
     tools.closeDirectory('episodes')
Ejemplo n.º 21
0
 def showsAnticipated(self, page):
     trakt_list = database.get(trakt.json_response, 12, 'shows/anticipated?page=%s&language=%s'
                               % (page, language_code))
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.showListBuilder(trakt_list)
     tools.addDirectoryItem(tools.lang(32019), 'showsAnticipated&page=%s' % (int(page) + 1))
     tools.closeDirectory('tvshows')
Ejemplo n.º 22
0
 def showsSearchResults(self, query):
     query = tools.quote_plus(tools.unquote(query))
     trakt_list = trakt.json_response('search/show?query=%s&extended=full&type=show&field=title' % query)
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.showListBuilder([show for show in trakt_list if float(show['score']) > 0])
     tools.closeAllDialogs()
     tools.closeDirectory('tvshows')
Ejemplo n.º 23
0
    def seasonEpisodes(self, args):

        args = json.loads(tools.unquote(args))

        show_id = args['showInfo']['ids']['trakt']
        season_number = args['seasonInfo']['info']['season']

        self.episodeListBuilder(show_id, season_number)
        tools.closeDirectory('episodes', sort='episode')
Ejemplo n.º 24
0
    def showGenres(self):
        tools.addDirectoryItem(tools.lang(32065).encode('utf-8'), 'showGenresGet', '', '', isFolder=True)
        genres = database.get(trakt.json_response, 24, 'genres/shows')

        if genres is None:
            return

        for i in genres:
            tools.addDirectoryItem(i['name'], 'showGenresGet&actionArgs=%s' % i['slug'], '', '', isFolder=True)
        tools.closeDirectory('addons', cacheToDisc=True)
Ejemplo n.º 25
0
 def showsUpdated(self, page):
     import datetime
     date = datetime.date.today() - datetime.timedelta(days=31)
     date = date.strftime('%Y-%m-%d')
     trakt_list = database.get(trakt.json_response, 12, 'shows/updates/%s?page=%s&extended=full' % (date, page))
     if trakt_list is None:
         return
     self.showListBuilder(trakt_list)
     tools.addDirectoryItem(tools.lang(32019).encode('utf-8'), 'showsUpdated&page=%s' % (int(page) + 1), '', '')
     tools.closeDirectory('tvshows')
Ejemplo n.º 26
0
 def myRecentEpisodes(self):
     hidden_shows = trakt.get_trakt_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?extended=full' %
                               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.directToEpisodeBuilder(trakt_list)
     tools.closeDirectory('episodes')
Ejemplo n.º 27
0
    def showsPopular(self, page):
        trakt_list = database.get(trakt.json_response, 12, 'shows/popular?page=%s' % page)

        if trakt_list is None:
            tools.cancel_directory()
            return

        self.showListBuilder(trakt_list)
        tools.addDirectoryItem(tools.lang(32019), 'showsPopular&page=%s' % (int(page) + 1))
        tools.closeDirectory('tvshows')
Ejemplo n.º 28
0
    def myUpcomingEpisodes(self):
        tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
        upcoming_episodes = database.get(trakt.json_response, 24, 'calendars/my/shows/%s/30' % tomorrow)

        sort = sorted(upcoming_episodes, key=lambda i: i['first_aired'])
        sort = [i['episode']['ids']['trakt'] for i in sort]
        sort = {'type': None, 'id_list': sort}
        self.mixedEpisodeBuilder(upcoming_episodes, sort=sort, hide_watched=False, hide_unaired=False,
                                 prepend_date=True)
        tools.closeDirectory('episodes')
Ejemplo n.º 29
0
 def showsCollected(self, page):
     trakt_list = database.get(trakt.json_response, 12,
                               'shows/collected?page=%s' % page)
     if trakt_list is None:
         return
     self.showListBuilder(trakt_list)
     tools.addDirectoryItem(tools.lang(32019),
                            'showsCollected&page=%s' % (int(page) + 1), '',
                            '')
     tools.closeDirectory('tvshows')
Ejemplo n.º 30
0
 def myShowCollection(self):
     trakt_list = TraktSyncDatabase().get_collected_episodes()
     trakt_list = [i for i in trakt_list if i is not None]
     trakt_list = list(set([i['show_id'] for i in trakt_list]))
     trakt_list = [{'ids': {'trakt': i}} for i in trakt_list]
     trakt_list = [i for i in trakt_list if i is not None]
     if trakt_list is None:
         return
     self.showListBuilder(trakt_list)
     tools.closeDirectory('tvshows', sort='title')