Ejemplo n.º 1
0
    def showPack(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])

            url = self.base_link + self.search_link % tools.quote('%s season 1-%s' % (showTitle, simpleInfo['no_seasons']))
            results = self.getList(url)

            url = self.base_link + self.search_link % tools.quote('%s complete' % showTitle)
            results += self.getList(url)

            torrent_list = []

            for i in results:
                try:
                    if not source_utils.filterShowPack(simpleInfo, i['release_title']):
                        continue
                    else:
                        i['package'] = 'show'
                        torrent_list.append(i)
                except:
                    continue

            self.threadResults += torrent_list

        except:
            import traceback
            traceback.print_exc()
            pass
Ejemplo n.º 2
0
 def resolve_hoster(self, url):
     url = tools.quote(url)
     resolve = self.get_url('link/unlock?link={}'.format(url), token_req=True)
     if resolve['success']:
         return resolve['infos']['link']
     else:
         return None
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']
        username = tools.quote_plus(arguments['username'])
        url = 'users/%s/lists/%s/items/%s?extended=full' % (
            username, arguments['trakt_id'], media_type)
        list_items = database.get(self.json_response, 12, url, None, False)

        if list_items is None or len(list_items) == 0:
            return

        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 movie(self, title, year):

        torrent_list = []
        self.get_token()
        title = source_utils.cleanTitle(title)
        url = self.base_link + self.search_string % (tools.quote(
            '%s %s' % (title, year)), self.token)
        response = json.loads(serenRequests().get(url).text)
        if 'error_code' in response:
            pass
        else:
            for i in response['torrent_results']:
                try:
                    torrent = {}
                    torrent['package'] = 'single'
                    torrent['release_title'] = i['title']
                    if not source_utils.filterMovieTitle(
                            torrent['release_title'], title, year):
                        continue
                    torrent['magnet'] = i['download']
                    torrent['seeds'] = i['seeders']
                    torrent['size'] = int((i['size'] / 1024) / 1024)
                    torrent_list.append(torrent)
                except:
                    import traceback
                    traceback.print_exc()
                    continue

        return torrent_list
Ejemplo n.º 5
0
    def _build_cache_assist(self):
        if len(self.sources_information["allTorrents"]) == 0:
            return
        valid_packages = ['show', 'season', 'single']

        if self.media_type == 'episode' and self.item_information['is_airing']:
            valid_packages.remove('show')
            if int(self.item_information['info']['season']) >= int(
                    self.item_information['season_count']):
                valid_packages.remove('season')

        sources = [i for i in self.sources_information['allTorrents'].values() if i['package'] in valid_packages]

        if g.get_bool_setting("general.autocache") and g.get_int_setting('general.cacheAssistMode') == 0:
            sources = self._get_best_torrent_to_cache(sources)
            if sources:
                action_args = tools.quote(json.dumps(sources))
                xbmc.executebuiltin(
                    'RunPlugin({}?action=cacheAssist&action_args={})'.format(g.BASE_URL, action_args))
        elif not self.silent:
            confirmation = xbmcgui.Dialog().yesno('{} - {}'.format(g.ADDON_NAME, g.get_language_string(30325)),
                                                  g.get_language_string(30056))
            if confirmation:
                window = ManualCacheWindow(*SkinManager().confirm_skin_path('manual_caching.xml'),
                                           item_information=self.item_information, sources=sources)
                window.doModal()
                del window
Ejemplo n.º 6
0
    def myTraktLists(self, media_type):

        lists = self.getLists()

        try:
            liked_lists = [
                i for i in self.json_response(
                    'users/likes/lists', limit=True, limitOverride=500)
            ]
            liked_lists = [i['list'] for i in liked_lists]
            lists += liked_lists

        except:

            import traceback
            traceback.print_exc()
            pass

        for user_list in lists:
            arguments = {
                'trakt_id': user_list['ids']['slug'],
                'username': user_list['user']['ids']['slug'],
                'type': media_type,
                'sort_how': user_list['sort_how'],
                'sort_by': user_list['sort_by']
            }

            tools.addDirectoryItem(
                user_list['name'], 'traktList&page=1&actionArgs=%s' %
                tools.quote(json.dumps(arguments)), None, None)

        tools.closeDirectory('addons')
        return
Ejemplo n.º 7
0
    def movieGenresList(self, args, page):
        if page is None:
            page = 1
        if args is None:
            genre_display_list = []
            genre_string = ''
            genres = database.get(trakt.json_response, 24, 'genres/movies')
            for genre in genres:
                genre_display_list.append(genre['name'])
            genre_multiselect = tools.showDialog.multiselect(
                '{}: {}'.format(tools.addonName, tools.lang(40298)),
                genre_display_list)
            if genre_multiselect is None: return
            for selection in genre_multiselect:
                genre_string += ', %s' % genres[selection]['slug']
            genre_string = genre_string[2:]
        else:
            genre_string = tools.unquote(args)

        trakt_list = trakt.json_response('movies/trending?genres=%s&page=%s' %
                                         (genre_string, page))

        if trakt_list is None:
            tools.cancel_directory()
            return
        self.commonListBuilder(trakt_list)
        tools.addDirectoryItem(tools.lang(32019),
                               'movieGenresGet&actionArgs=%s&page=%s' %
                               (tools.quote(genre_string), int(page) + 1),
                               isFolder=True)

        tools.closeDirectory('movies')
Ejemplo n.º 8
0
    def showListBuilder(self, trakt_list, forceResume=False, info_only=False):

        try:
            if len(trakt_list) == 0:
                tools.log('We received no titles to build a list', 'error')
                return
        except:
            import traceback
            traceback.print_exc()
            return

        if 'show' in trakt_list[0]:
            trakt_list = [i['show'] for i in trakt_list]

        show_ids = [i['ids']['trakt'] for i in trakt_list]

        self.itemList = trakt_database.get_show_list(show_ids)
        self.itemList = [x for x in self.itemList if x is not None and 'info' in x]
        self.itemList = tools.sort_list_items(self.itemList, trakt_list)

        item_list = []

        for item in self.itemList:
            try:
                # Add Arguments to pass with items
                args = {'trakt_id': item['ids']['trakt'], 'item_type': 'show'}
                args = tools.quote(json.dumps(args, sort_keys=True))

                name = tools.display_string(item['info']['tvshowtitle'])

                if info_only:
                    return args

                if not self.is_aired(item['info']):
                    if tools.getSetting('general.hideUnAired') == 'true':
                        continue
                    name = tools.colorString(name, 'red')
                    name = tools.italic_string(name)

                item['info'] = tools.clean_air_dates(item['info'])
                item['info']['title'] = item['info']['tvshowtitle']
                
                if tools.getSetting('smartplay.clickresume') == 'true' or forceResume is True:
                    action = 'playbackResume'
                else:
                    if tools.getSetting('general.flatten.episodes') == 'true':
                        action = 'flatEpisodes'
                    else:
                        action = 'showSeasons'

            except:
                import traceback
                traceback.print_exc()
                continue

            item_list.append(tools.addDirectoryItem(name, action, item['info'], item['art'], item['cast'], isFolder=True,
                                                    isPlayable=False, actionArgs=args, bulk_add=True,
                                                    set_ids=item['ids']))

        tools.addMenuItems(syshandle, item_list, len(item_list))
Ejemplo n.º 9
0
    def seasonPack(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])

            url = self.base_link + self.search_link % tools.quote('%s season %s' % (showTitle, simpleInfo['season_number']))
            results = self.getList(url)
            torrent_list = []

            for torrent in results:
                try:
                    torrent = {}

                    if not source_utils.filterSeasonPack(simpleInfo, torrent['release_title']):
                        continue
                    else:
                        torrent['package'] = 'season'
                        torrent_list.append(torrent)
                except:
                    continue

            self.threadResults += torrent_list

        except:
            import traceback
            traceback.print_exc()
            pass
Ejemplo n.º 10
0
    def getListItems(self, arguments, page):
        lists_database = lists.TraktSyncDatabase()
        paginate_lists = (
            tools.getSetting('general.paginatetraktlists') == 'true')
        arguments = json.loads(tools.unquote(arguments))
        media_type = arguments['type']
        list_items = ast.literal_eval(
            lists_database.get_list(arguments['trakt_id'], media_type,
                                    arguments['username'])['kodi_meta'])
        max_items = len(list_items)

        if paginate_lists:
            list_items = tools.paginate_list(
                list_items, int(page), int(tools.getSetting('item.limit')))

        if media_type in ['show', 'shows']:
            from resources.lib.gui import tvshowMenus
            tvshowMenus.Menus().showListBuilder(list_items)

        if media_type in ['movie', 'movies']:
            from resources.lib.gui import movieMenus
            movieMenus.Menus().commonListBuilder(list_items)

        content_type = 'tvshows'
        if media_type in ['movie', 'movies']:
            content_type = 'movies'

        if paginate_lists:
            limit = int(tools.getSetting('item.limit'))
            if int(page) * limit < max_items:
                tools.addDirectoryItem(
                    tools.lang(32019), 'traktList&page=%s&actionArgs=%s' %
                    (int(page) + 1, tools.quote(json.dumps(arguments))))
        tools.closeDirectory(content_type)
        return
Ejemplo n.º 11
0
    def singleEpisode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + self.search_link % tools.quote('%s s%se%s' % (showTitle, season, episode))
            results = self.getList(url)

            torrent_list = []

            for torrent in results:
                try:
                    if not source_utils.filterSingleEpisode(simpleInfo, torrent['release_title']):
                        continue
                    else:
                        torrent['package'] = 'single'
                        torrent_list.append(torrent)
                except:
                    continue

            self.threadResults += torrent_list
        except:
            import traceback
            traceback.print_exc()
            pass
Ejemplo n.º 12
0
    def movieGenresList(self, args, page):
        if page is None:
            page = 1
        if args is None:
            genre_display_list = []
            genre_string = ''
            genres = database.get(trakt.json_response, 24, 'genres/movies')
            for genre in genres:
                genre_display_list.append(genre['name'])
            genre_multiselect = tools.showDialog.multiselect(tools.addonName + ": Genre Selection", genre_display_list)
            if genre_multiselect is None: return
            for selection in genre_multiselect:
                genre_string += ', %s' % genres[selection]['slug']
            genre_string = genre_string[2:]
        else:
            genre_string = tools.unquote(args)

        trakt_list = trakt.json_response('movies/popular?genres=%s&page=%s' % (genre_string, page))

        if trakt_list is None:
            return
        self.commonListBuilder(trakt_list)
        tools.addDirectoryItem(tools.lang(32019).encode('utf-8'),
                               'movieGenresGet&actionArgs=%s&page=%s' % (tools.quote(genre_string), int(page) + 1),
                               '', '', isFolder=True)

        tools.closeDirectory('movies', viewType=self.viewType)
Ejemplo n.º 13
0
    def moviesSearch(self, actionArgs=None):

        if actionArgs == None:
            k = tools.showKeyboard('', tools.lang(32016))
            k.doModal()
            query = (k.getText() if k.isConfirmed() else None)
            if query == None or query == '':
                return
        else:
            query = actionArgs
        database.addSearchHistory(query, 'movie')
        query = tools.deaccentString(tools.display_string(query))
        tools.quote(query)
        tools.closeAllDialogs()
        tools.closeDirectory('movies')
        tools.execute("Container.Update(%s?action=moviesSearchResults&actionArgs=%s, replace)'" % (sysaddon, query))
Ejemplo n.º 14
0
    def showSearchHistory(self):
        history = database.getSearchHistory('show')
        tools.addDirectoryItem(tools.lang(40142), 'showsSearch', isFolder=True, isPlayable=False)
        tools.addDirectoryItem(tools.lang(40140), 'clearSearchHistory', isFolder=False, isPlayable=False)

        for i in history:
            tools.addDirectoryItem(i, 'showsSearchResults&actionArgs=%s' % tools.quote(i))
        tools.closeDirectory('addons')
Ejemplo n.º 15
0
    def seasonListBuilder(self, show_id, smartPlay=False):

        self.itemList = trakt_database.get_season_list(show_id)

        self.itemList = [x for x in self.itemList if x is not None and 'info' in x]

        self.itemList = sorted(self.itemList, key=lambda k: int(k['info']['season']))

        if len(self.itemList) == 0:
            tools.log('We received no titles to build a list', 'error')
            return

        hide_specials = False

        if tools.getSetting('general.hideSpecials') == 'true':
            hide_specials = True

        item_list = []

        for item in self.itemList:
            try:
                if hide_specials and int(item['info']['season']) == 0:
                    continue

                action = 'seasonEpisodes'
                args = {'trakt_id': item['showInfo']['ids']['trakt'],
                        'season': item['info']['season'],
                        'item_type': 'season'}

                args = tools.quote(json.dumps(args, sort_keys=True))

                item['trakt_object']['show_id'] = item['showInfo']['ids']['trakt']
                name = item['info']['season_title']

                if not self.is_aired(item['info']) or 'aired' not in item['info']:
                    if tools.getSetting('general.hideUnAired') == 'true':
                        continue
                    name = tools.colorString(name, 'red')
                    name = tools.italic_string(name)
                    item['info']['title'] = name

                item['info'] = tools.clean_air_dates(item['info'])

            except:
                import traceback
                traceback.print_exc()
                continue

            if smartPlay is True:
                return args

            item_list.append(tools.addDirectoryItem(name, action, item['info'], item['art'], item['cast'], isFolder=True,
                                                    isPlayable=False, actionArgs=args, set_ids=item['ids'],
                                                    bulk_add=True))

        tools.addMenuItems(syshandle, item_list, len(item_list))
Ejemplo n.º 16
0
    def showPack(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])

            url = self.base_link + self.search_link + tools.quote(
                '%s season 1-%s' % (showTitle, simpleInfo['no_seasons']))
            response = serenRequests().get(url, timeout=10)
            try:
                if response.status_code != 200:
                    return
            except:
                return
            webpage = BeautifulSoup(response.text, 'html.parser')
            results = webpage.find_all('tr')

            url = self.base_link + self.search_link + tools.quote(
                '%s complete' % showTitle)
            response = serenRequests().get(url)
            webpage = BeautifulSoup(response.text, 'html.parser')
            results += webpage.find_all('tr')

            torrent_list = []

            for i in results:
                try:
                    torrent = {}
                    torrent['package'] = 'pack'
                    torrent['release_title'] = i.find('a', {'class', 'detLink'}).text
                    if not source_utils.filterShowPack(simpleInfo, torrent['release_title']):
                        continue
                    torrent['magnet'] = i.find_all('a')[3]['href']
                    if 'magnet:?' not in torrent['magnet']:
                        torrent['magnet'] = self.magnet_request(torrent['magnet'])
                    torrent['seeds'] = int(i.find_all('td')[2].text)
                    torrent_list.append(torrent)
                except:
                    continue

            self.threadResults += torrent_list

        except:
            pass
Ejemplo n.º 17
0
    def commonListBuilder(self, trakt_list, info_return=False):

        if len(trakt_list) == 0:
            return
        if 'movie' in trakt_list[0]:
            trakt_list = [i['movie'] for i in trakt_list]

        self.itemList = trakt_database.get_movie_list(trakt_list)

        self.itemList = [x for x in self.itemList if x is not None and 'info' in x]
        self.itemList = tools.sort_list_items(self.itemList, trakt_list)

        list_items = []

        for item in self.itemList:
            try:

                name = tools.display_string(item['info']['title'])

                if not self.is_aired(item['info']):
                    if tools.getSetting('general.hideUnAired') == 'true':
                        continue
                    name = tools.colorString(name, 'red')
                    name = tools.italic_string(name)

                args = {'trakt_id': item['ids']['trakt'], 'item_type': 'movie'}
                args = tools.quote(json.dumps(args, sort_keys=True))

            except:
                import traceback
                traceback.print_exc()
                continue

            if item is None:
                continue

            if 'trakt' in item['ids']:
                try:
                    bookmark = bookmark_sync.get_bookmark(item['ids']['trakt'])
                    item['info']['resumetime'] = bookmark['timeInSeconds'] if bookmark is not None else 0
                    item['info']['totaltime'] = item['info']['duration']
                except:
                    pass

            item['info']['title'] = item['info']['originaltitle'] = name
            list_items.append(tools.addDirectoryItem(name, 'getSources', item['info'], item['art'], item['cast'],
                                                     isFolder=False, isPlayable=True, actionArgs=args,
                                                     set_ids=item['ids'], bulk_add=True))

        if info_return:
            return list_items

        tools.addMenuItems(syshandle, list_items, len(list_items))
Ejemplo n.º 18
0
    def getSourcesWorkaround2(self, actionArgs):

        item_information = tools.get_item_information(actionArgs)
        item = tools.menuItem(label=item_information['info']['title'])
        item.setArt(item_information['art'])
        item.setUniqueIDs(item_information['ids'])
        item.setInfo(type='video',
                     infoLabels=tools.clean_info_keys(
                         item_information['info']))
        tools.playList.add(
            url='plugin://plugin.video.%s?action=getSources&actionArgs=%s' %
            (tools.addonName.lower(), tools.quote(actionArgs)),
            listitem=item)
        tools.player().play(tools.playList)
Ejemplo n.º 19
0
    def _format_items(self, items):
        for i in items:
            i.update({'debrid_provider': self.provider})
            if self._is_folder(i):
                isPlayable = False
                isFolder = True
                action = 'myFilesFolder'
            else:
                isPlayable = True
                isFolder = False
                action = 'myFilesPlay'

            actionArgs = json.dumps(i)
            tools.addDirectoryItem(i['name'], action, isPlayable=isPlayable, isFolder=isFolder,
                                   actionArgs=tools.quote(actionArgs))
Ejemplo n.º 20
0
    def myTraktLists(self, media_type):
        lists_database = lists.TraktSyncDatabase()
        for user_list in lists_database.get_lists(self._remove_pluralization(media_type), 'myLists'):
            arguments = {'trakt_id': user_list['trakt_id'],
                         'username': user_list['username'],
                         'type': user_list['media_type'],
                         'sort_how': user_list['sort_how'],
                         'sort_by': user_list['sort_by']}

            tools.addDirectoryItem('{} - [COLOR {}]{}[/COLOR]'.format(user_list['name'].encode('utf-8'),
                                                                      tools.get_user_text_color(),
                                                                      user_list['username'].encode('utf-8')),
                                   'traktList&page=1&actionArgs=%s' % tools.quote(json.dumps(arguments)))

        tools.closeDirectory('addons')
    def movies_search(self, query=None):
        if query is None:
            k = xbmc.Keyboard("", g.get_language_string(30013))
            k.doModal()
            query = k.getText() if k.isConfirmed() else None
            del k
            if not query:
                g.cancel_directory()
                return

        query = g.decode_py2(query)
        if g.get_bool_setting("searchHistory"):
            SearchHistory().add_search_history("movie", query)
        query = g.deaccent_string(g.display_string(query))
        query = tools.quote(query)

        self.movies_search_results(query)
Ejemplo n.º 22
0
    def showsSearch(self, actionArgs=None):

        if actionArgs == None:
            k = tools.showKeyboard('', tools.lang(32016))
            k.doModal()
            query = (k.getText() if k.isConfirmed() else None)
            if query == None or query == '':
                tools.cancel_directory()
                return
        else:
            query = actionArgs

        query = query.decode('utf-8')
        database.addSearchHistory(query, 'show')
        query = tools.deaccentString(tools.display_string(query))
        query = tools.quote(query)
        self.showsSearchResults(query)
Ejemplo n.º 23
0
    def movie(self, title, year):
        title = source_utils.cleanTitle(title)

        url = self.base_link + self.search_link % tools.quote('%s %s' % (title, year))
        results = self.getList(url)

        torrent_list = []
        for i in results:
            try:
                if source_utils.filterMovieTitle(i['release_title'], title, year):
                    i['package'] = 'single'
                    torrent_list.append(i)
                else:
                    continue
            except:
                import traceback
                traceback.print_exc()
                continue
        return torrent_list
Ejemplo n.º 24
0
    def build_playlist(self, season=None, minimum_episode=None, params=None):

        if season is None:
            season = self.info_dictionary['info']['season']

        if minimum_episode is None:
            minimum_episode = int(self.info_dictionary['info']['episode']) + 1

        url_params = self.clean_playback_params(params)

        playlist = tvshowMenus.Menus().episodeListBuilder(self.show_trakt_id,
                                                          season,
                                                          smartPlay=True)

        for i in playlist:
            params = dict(tools.parse_qsl(i[0].replace('?', '')))
            actionArgs = params.get('actionArgs')

            if not tvshowMenus.Menus().is_aired(
                    tools.get_item_information(actionArgs)['info']):
                tools.log('Episode not Aired, skipping')
                continue

            actionArgs = json.loads(actionArgs)

            if actionArgs['episode'] < minimum_episode:
                continue

            url = i[0]

            if actionArgs['episode'] == minimum_episode:
                request_args = json.loads(tools.unquote(self.actionArgs))
                # actionArgs['resume'] = request_args['resume'] if 'resume' in request_args else 'false'
                url = '&actionArgs='.join([
                    url.split('&actionArgs=')[0],
                    tools.quote(json.dumps(actionArgs, sort_keys=True))
                ])

            if url_params is not None:
                url += '&{}'.format(url_params)

            tools.playList.add(url=url, listitem=i[1])
Ejemplo n.º 25
0
 def movie(self, title, year):
     url = self.base_link + self.search_link + tools.quote('%s %s' % (title, year))
     response = serenRequests().get(url, timeout=10)
     results = BeautifulSoup(response.text, 'html.parser').find_all('tr')
     torrent_list = []
     for i in results:
         try:
             torrent = {}
             torrent['package'] = 'single'
             torrent['release_title'] = i.find('a', {'class', 'detLink'}).text
             if not source_utils.filterMovieTitle(torrent['release_title'], title, year):
                 continue
             torrent['magnet'] = i.find_all('a')[3]['href']
             if 'magnet:?' not in torrent['magnet']:
                 torrent['magnet'] = self.magnet_request(torrent['magnet'])
             torrent['seeds'] = int(i.find_all('td')[2].text)
             torrent_list.append(torrent)
         except:
             continue
     return torrent_list
Ejemplo n.º 26
0
    def myTraktLists(self, media_type):

        lists = self.getLists()
        lists += [
            i['list']
            for i in self.json_response('users/likes/lists', limit=500)
        ]
        for user_list in lists:
            arguments = {
                'trakt_id': user_list['ids']['trakt'],
                'username': user_list['user']['username'],
                'type': media_type,
                'sort_how': user_list['sort_how'],
                'sort_by': user_list['sort_by']
            }
            tools.addDirectoryItem(
                user_list['name'], 'traktList&page=1&actionArgs=%s' %
                tools.quote(json.dumps(arguments)), None, None)

        tools.closeDirectory('addons')
        return
Ejemplo n.º 27
0
 def _create_args(item):
     get = MetadataHandler.get_trakt_info
     info = MetadataHandler.info
     args = {
         "trakt_id": get(item, "trakt_id",
                         info(item).get("trakt_id")),
         "mediatype": get(item, "mediatype",
                          info(item).get("mediatype")),
     }
     if args["trakt_id"] == None:
         import inspect
         g.log(inspect.stack())
         g.log(item)
     if args["mediatype"] == "season":
         args["trakt_show_id"] = get(item, "trakt_show_id",
                                     info(item).get("trakt_show_id"))
     if args["mediatype"] == "episode":
         args["trakt_show_id"] = get(item, "trakt_show_id",
                                     info(item).get("trakt_show_id"))
         args["trakt_season_id"] = get(item, "trakt_season_id",
                                       info(item).get("trakt_season_id"))
     return tools.quote(json.dumps(args, sort_keys=True))
Ejemplo n.º 28
0
    def singleEpisode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + self.search_link + tools.quote('%s s%se%s' % (showTitle, season, episode))
            response = serenRequests().get(url, timeout=10)
            webpage = BeautifulSoup(response.text, 'html.parser')
            results = webpage.find_all('tr')
            torrent_list = []

            page_limit = 2
            torrent_list = []

            for x in range(1, page_limit):
                for i in results:
                    try:
                        torrent = {}
                        torrent['package'] = 'single'
                        torrent['release_title'] = i.find('a', {'class', 'detLink'}).text

                        if not source_utils.filterSingleEpisode(simpleInfo, torrent['release_title']):
                            continue

                        torrent['magnet'] = i.find_all('a')[3]['href']
                        if 'magnet:?' not in torrent['magnet']:
                            torrent['magnet'] = self.magnet_request(torrent['magnet'])
                        torrent['seeds'] = int(i.find_all('td')[2].text)
                        torrent_list.append(torrent)
                    except:
                        import traceback
                        traceback.print_exc()
                        continue

                self.threadResults += torrent_list
        except:
            pass
Ejemplo n.º 29
0
    def build_cache_assist(self, args):
        if tools.getSetting('general.autocache') == 'false':
            return
        if len(self.allTorrents) == 0:
            return
        if len(self.torrentCacheSources) > 0:
            return

        build_list = []

        if tools.getSetting('general.cacheAssistMode') == "0":
            quality_list = ['1080p', '720p', 'SD']

            for quality in quality_list:
                if len(build_list) > 0: break
                if len([
                        i for i in self.torrentCacheSources
                        if i['quality'] == quality
                ]) == 0:
                    quality_filter = [
                        i for i in self.allTorrents if i['quality'] == quality
                    ]
                    if len(quality_filter) > 0:
                        packtype_filter = [
                            i for i in quality_filter if i['package'] == 'show'
                            or i['package'] == 'season'
                        ]
                        sorted_list = sorted(packtype_filter,
                                             key=lambda k: k['seeds'],
                                             reverse=True)
                        if len(sorted_list) > 0:
                            build_list.append(sorted_list[0])
                            break
                        else:
                            package_type_list = [
                                i for i in quality_filter
                                if i['package'] == 'single'
                            ]
                            sorted_list = sorted(package_type_list,
                                                 key=lambda k: k['seeds'],
                                                 reverse=True)
                            if sorted_list > 0:
                                build_list.append(sorted_list[0])
        else:
            if self.silent is True:
                return
            yesno = tools.showDialog.yesno(
                '%s - Cache Assist' % tools.addonName,
                tools.lang(32086).encode('utf-8'))
            if yesno == 0:
                return
            display_list = [
                '%sS | %s | %s | %s' %
                (i['seeds'], tools.color_quality(
                    i['quality']), tools.source_size_display(
                        i['size']), tools.colorString(i['release_title']))
                for i in self.allTorrents
            ]
            selection = tools.showDialog.select(
                '%s - ' % tools.addonName + tools.lang(32087).encode('utf-8'),
                display_list)
            if selection == -1:
                return
            build_list.append(self.allTorrents[selection])

        if len(build_list) > 0:
            actionArgs = {'torrent_list': build_list, 'args': args}
            actionArgs = tools.quote(json.dumps(actionArgs))
            tools.execute('RunPlugin(%s?action=cacheAssist&actionArgs=%s)' %
                          (sysaddon, actionArgs))

        return
Ejemplo n.º 30
0
    def showListBuilder(self, trakt_list, forceResume=False, info_only=False):

        self.threadList = []
        try:
            if len(trakt_list) == 0: return
        except:
            return

        if 'show' in trakt_list[0]:
            buildList = [i['show'] for i in trakt_list]
            trakt_list = buildList

        for item in trakt_list:

            if tools.getSetting('general.metalocation') == '1':
                self.threadList.append(Thread(target=self.tvdbShowListWorker, args=(item,)))
            else:
                self.threadList.append(Thread(target=self.tmdbShowListWorker, args=(item,)))

        self.runThreads()

        self.itemList = tools.sort_list_items(self.itemList, trakt_list)
        if tools.getSetting('trakt.auth') != '':
            traktWatched = trakt.json_response('sync/watched/shows?extended=full')

            for listItem in self.itemList:
                try:
                    for show in traktWatched:
                        if show['show']['ids']['trakt'] == listItem['ids']['trakt']:
                            listItem['info']['playcount'] = 1
                            episodes = 0
                            for season in show['seasons']:
                                episodes += len(season['episodes'])
                            if episodes < show['show']['aired_episodes']:
                                listItem['info']['playcount'] = 0
                            break
                except:
                    pass

        for item in self.itemList:
            if item is None: continue
            try:
                args = {}
                cm = []
                action = ''

                # Add Arguments to pass with items
                args['ids'] = item['ids']
                args['info'] = item['info']
                args['art'] = item['art']
                name = item['info']['tvshowtitle']
                args = tools.quote(json.dumps(args, sort_keys=True))

                if info_only == True:
                    return args

                if 'setCast' in item:
                    set_cast = item['setCast']
                else:
                    set_cast = False

                if tools.getSetting('smartplay.clickresume') == 'true' or forceResume is True:
                    action = 'smartPlay'
                else:
                    action = 'showSeasons'

                # Context Menu Items

                cm.append((tools.lang(32070).encode('utf-8'),
                           'XBMC.RunPlugin(%s?action=shufflePlay&actionArgs=%s)' % (sysaddon,
                                                                                    args)))

                cm.append((tools.lang(32020).encode('utf-8'),
                           'Container.Update(%s?action=showsRelated&actionArgs=%s)' % (sysaddon, item['ids']['trakt'])))

                cm.append(
                    (tools.lang(32069).encode('utf-8'), 'XBMC.Container.Update(%s?action=showSeasons&actionArgs=%s)'
                     % (sysaddon, args)))

                if tools.getSetting('trakt.auth') != '':
                    cm.append(('Trakt Manager', 'RunPlugin(%s?action=traktManager&actionArgs=%s)'
                               % (sysaddon, tools.quote(json.dumps(item['trakt_object'])))))

                if tools.context_addon():
                    cm = []

                try:
                    if tools.kodiVersion > 17:
                        item['info'].pop('seasonCount')
                        item['info'].pop('episodeCount')
                        item['info'].pop('showaliases')
                except:
                    pass

            except:
                import traceback
                traceback.print_exc()
                continue

            tools.addDirectoryItem(name, action, item['info'], item['art'], all_fanart=None, cm=cm,
                                   isFolder=True, isPlayable=False, actionArgs=args, set_cast=set_cast,
                                   set_ids=item['ids'])