def explicit_filter(media_list): filtered_list = [] explicit_genres_str = [api_genres[i] for i in explicit_genres] for media in media_list.get('data'): source = API.get_source(media) genres = source.get('info_labels').get('genre') is_blocked = bool(set(genres).intersection(explicit_genres_str)) if is_blocked: continue filtered_list.append(media) media_list.update({'data': filtered_list})
def select_season(self, collection, media_id): logger.debug('Showing season list') MainMenuFolderItem(url=router_url_from_string(ROUTE.CLEAR_PATH))( self.handle) media = self._on_media_selected(collection, media_id) self.set_cached_media(media) season_list = API.get_source(media).get('seasons') if season_list: list_items = [ movie.build() for movie in self.build_season_list_gui( collection, media_id, season_list) ] self.render(collection, list_items)
def build_media_item_gui(item_type, media, url, title=None): source = API.get_source(media) info_labels = source.get('info_labels') info_labels.update({'imdbnumber': str(source.get('services').get('imdb'))}) del info_labels['playcount'] return item_type( title=title if title else STRINGS.TITLE_YEAR.format(title=info_labels.get('title').encode('utf-8'), year=info_labels.get('year')), url=url, art=source.get('art'), info_labels=info_labels, stream_info=MediaListRenderer.stream_info(source), services=source.get('services') )
def search_for_csfd_item(self, collection, search_value): # No idea how to decode search_value to correct format. It must be decoded on the server right now. media_list = self.filter_media(collection, FILTER_TYPE.EXACT_TITLE, Url.encode_param([search_value]), ORDER.ASCENDING).get('data') num_media = len(media_list) if num_media == 1: media_id = media_list.pop().get('_id') streams = API.get_source( self.get_media_detail(collection, media_id)).get('streams') self.renderers[RENDERER.MOVIES].select_stream(media_id, streams) elif num_media == 0: InfoDialog( get_string(30303).format(number=str(num_media))).notify()
def show_mixed_media_list(self, media_list): media_list_gui = [] for media in media_list.get('data'): source = API.get_source(media) media_type = source.get('info_labels').get('mediatype') info_labels = source.get('info_labels') genres = translate_genres(info_labels.get('genre')) title = STRINGS.TITLE_GENRE_YEAR.format( title=info_labels.get('title').encode('utf-8'), genre=' / '.join(genres), year=info_labels.get('year')) if media_type == MEDIA_TYPE.TV_SHOW: media_list_gui.append( MediaListRenderer.build_media_item_gui( TvShowMenuItem, source, self.renderers[RENDERER.TV_SHOWS].url_builder( media, COLLECTION.TV_SHOWS), title=title)) elif media_type == MEDIA_TYPE.MOVIE: media_list_gui.append( MovieListRenderer.build_media_item_gui( MediaItem, source, self.renderers[RENDERER.MOVIES].url_builder( media, COLLECTION.MOVIES), title=title)) pagination = media_list.get('pagination') is_pagination = True if pagination else False MediaListRenderer.add_navigation(media_list_gui, bottom=is_pagination) MediaListRenderer.add_pagination(COLLECTION.ALL, media_list_gui, pagination) with DirectoryRenderer.start_directory(self.router.handle, as_type=COLLECTION.MOVIES): xbmcplugin.addDirectoryItems( self.router.handle, [item.build() for item in media_list_gui])
def api(): return API(plugin_version=get_info('version'), uuid=settings[SETTINGS.UUID], api_url=URL.API)
def get_season(self, season_id): return API.get_source( self.get_cached_media()).get('seasons')[season_id]
def select_tv_show_stream(self, media_id, season_id, episode_id): logger.debug('Showing stream list') media = self.get_episode(int(season_id), int(episode_id)) self.select_stream(media_id, API.get_source(media)['streams'])
def select_movie_stream(self, collection, media_id): media = self._on_media_selected(collection, media_id) super(MovieListRenderer, self).select_stream(media_id, API.get_source(media)['streams'])