def list_tvshows(response): items = [] results = response['results'] for tvdb_show, tmdb_show in executor.execute(tmdb_to_tvdb, results, workers=10): if tvdb_show is not None: info = build_tvshow_info(tvdb_show, tmdb_show) items.append(make_tvshow_item(info)) if xbmc.Monitor().abortRequested(): return if 'page' in response: page = response['page'] args = nav_base.caller_args() if page < response['total_pages']: args['page'] = str(page + 1) items.append({ 'label': '%s/%s [I]Next page[/I] >>' % (page + 1, response['total_pages']), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return items
def list_trakt_tvshows(results, pages, page): genres_dict = dict([(x['slug'], x['name']) for x in Trakt.get_genres('shows')]) try: shows = [ meta_info.get_tvshow_metadata_trakt(item['show'], genres_dict) for item in results ] except KeyError: shows = [ meta_info.get_tvshow_metadata_trakt(item, genres_dict) for item in results ] items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')] page = int(page) pages = int(pages) if pages > 1: args = nav_base.caller_args() args['page'] = page + 1 args['confirm'] = 'yes' items.append({ 'label': '%s/%s [I]Next page[/I] >>' % (page + 1, pages + 1), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return plugin.finish(items=items, sort_methods=SORT)
def list_trakt_movies(results, pages=1, page=1): genres_dict = dict([(x['slug'], x['name']) for x in Trakt.get_genres('movies')]) try: movies = [ meta_info.get_trakt_movie_metadata(item['movie'], genres_dict) for item in results ] except KeyError: movies = [ meta_info.get_trakt_movie_metadata(item, genres_dict) for item in results ] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > 1: args = nav_base.caller_args() args['page'] = page + 1 args['confirm'] = 'yes' items.append({ 'label': '%s/%s [I]Next page[/I] >>' % (page, pages + 1), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return plugin.finish(items=items, sort_methods=SORTRAKT)
def list_tmdb_movies(result): genres_dict = nav_base.get_base_genres() movies = [ meta_info.get_movie_metadata(item, genres_dict) for item in result['results'] ] items = [make_movie_item(movie) for movie in movies] if 'page' in result: page = int(result['page']) pages = int(result['total_pages']) args = nav_base.caller_args() if pages > page: args['page'] = page + 1 args['confirm'] = 'yes' items.append({ 'label': '%s/%s [I]Next page[/I] >>' % (page, pages + 1), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return plugin.finish(items=items, sort_methods=SORT)
def list_tvshows(response): items = [] results = response['results'] for tvdb_show, tmdb_show in executor.execute(tmdb_to_tvdb, results, workers=10): if tvdb_show is not None: try: info = build_tvshow_info(tvdb_show, tmdb_show) except Exception as e: xbmc.log('Failed to parse show, tvdbID: {}'.format(tvdb_show.get('id')), xbmc.LOGERROR) xbmc.log('Error: {}'.format(e), xbmc.LOGERROR) continue else: items.append(make_tvshow_item(info)) if xbmc.Monitor().abortRequested(): return if 'page' in response: page = response['page'] args = nav_base.caller_args() if page < response['total_pages']: args['page'] = str(page + 1) items.append( { 'label': '%s/%s [I]Next page[/I] >>' % (page + 1, response['total_pages']), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return items
def list_trakt_search_items(results, pages, page): movies = [meta_info.get_trakt_movie_metadata(item['movie'], None) for item in results] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > 1: args = nav_base.caller_args() args['page'] = page + 1 items.append( { 'label': '%s/%s [I]Next page[/I] >>' % (page, pages + 1), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return items
def list_trakt_search_items(results, pages, page): shows = [meta_info.get_tvshow_metadata_trakt(item['show'], None) for item in results] items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')] page = int(page) pages = int(pages) if pages > 1: args = nav_base.caller_args() nextpage = page + 1 args['page'] = page + 1 items.append( { 'label': '%s/%s [I]Next page[/I] >>' % (nextpage, pages), 'path': plugin.url_for(nav_base.caller_name(), **args), 'thumbnail': plugin.get_media_icon('item_next'), 'fanart': plugin.get_addon_fanart() }) return items