def _create_recommended_show(self, series, storage_key=None): """Create the RecommendedShow object from the returned showobj.""" try: tvdb_id = cached_aid_to_tvdb(series.aid) except Exception: log.warning("Couldn't map AniDB id {0} to a TVDB id", series.aids) return None # If the anime can't be mapped to a tvdb_id, return none, and move on to the next. if not tvdb_id: return tvdb_id rec_show = RecommendedShow( self, series.aid, series.title, INDEXER_TVDBV2, tvdb_id, **{'rating': series.rating_permanent, 'votes': series.count_permanent, 'image_href': self.base_url.format(aid=series.aid), 'ids': {'tvdb': tvdb_id, 'aid': series.aid } } ) # Check cache or get and save image use_default = self.default_img_src if not series.picture.url else None rec_show.cache_image(series.picture.url, default=use_default) # By default pre-configure the show option anime = True rec_show.is_anime = True return rec_show
def _create_recommended_show(self, series): """Create the RecommendedShow object from the returned showobj.""" try: tvdb_id = cached_aid_to_tvdb(series.aid) except Exception: log.warning("Couldn't map AniDB id {0} to a TVDB id", series.aids) return None rec_show = RecommendedShow( self, series.aid, str(series.title), **{ 'rating': series.rating_permanent, 'votes': series.count_permanent, 'image_href': self.base_url.format(aid=series.aid), 'ids': { 'tvdb_id': tvdb_id, 'anidb_id': series.aid }, 'is_anime': True, 'subcat': 'hot' }) # Check cache or get and save image use_default = self.default_img_src if not series.picture.url else None rec_show.cache_image(series.picture.url, default=use_default) return rec_show
def _create_recommended_show(self, storage_key, series): """Create the RecommendedShow object from the returned showobj.""" try: tvdb_id = cached_aid_to_tvdb(series.aid) except Exception: log.warning("Couldn't map AniDB id {0} to a TVDB id", series.aids) return None # If the anime can't be mapped to a tvdb_id, return none, and move on to the next. if not tvdb_id: return tvdb_id rec_show = RecommendedShow( self, series.aid, series.title, INDEXER_TVDBV2, tvdb_id, **{'rating': series.rating_permanent, 'votes': series.count_permanent, 'image_href': self.base_url.format(aid=series.aid), 'ids': {'tvdb': tvdb_id, 'aid': series.aid } } ) # Check cache or get and save image use_default = self.default_img_src if not series.picture.url else None rec_show.cache_image(series.picture.url, default=use_default) # By default pre-configure the show option anime = True rec_show.is_anime = True return rec_show
def _create_recommended_show(self, show): """Create the RecommendedShow object from the returned showobj.""" rec_show = RecommendedShow( self, show['id'], show['title']['userPreferred'], **{ 'rating': show['averageScore'] / 10 if show['averageScore'] else 0, 'votes': show['popularity'], 'image_href': f"https://anilist.co/anime/{show['id']}", 'ids': { 'anilist_id': show['id'] }, 'is_anime': True, 'subcat': f"{show['startDate']['year']}_{show['season'].lower()}", 'genres': [genre.lower() for genre in show['genres']], 'plot': show['description'] } ) # Check cache or get and save image use_default = self.default_img_src if not show['coverImage']['large'] else None rec_show.cache_image(show['coverImage']['large'], default=use_default) return rec_show
def _create_recommended_show(self, series): """Create the RecommendedShow object from the returned showobj.""" externals = { 'imdb_id': ImdbIdentifier(series.get('imdb_tt')).series_id } # Get tmdb id using a call to tmdb api. t = indexerApi(INDEXER_TMDB).indexer( **indexerApi(INDEXER_TMDB).api_params.copy()) externals.update(t.get_id_by_external(**externals)) rec_show = RecommendedShow( self, ImdbIdentifier(series.get('imdb_tt')).series_id, series.get('name'), **{ 'rating': series.get('rating'), 'votes': series.get('votes'), 'image_href': series.get('imdb_url'), 'ids': externals, 'subcat': 'popular', 'genres': [genre.lower() for genre in series.get('genres')], 'plot': series.get('outline') }) if series.get('image_url'): rec_show.cache_image(series.get('image_url')) return rec_show
def _create_recommended_show(self, show_obj): """Create the RecommendedShow object from the returned showobj.""" cached_tvdb_id = tvdb_mapping_cache.get(show_obj.get('imdb_tt')) if not cached_tvdb_id: tvdb_id = helpers.get_tvdb_from_id(show_obj.get('imdb_tt'), 'IMDB') if tvdb_id: tvdb_mapping_cache.append(show_obj.get('imdb_tt'), tvdb_id) else: tvdb_id = cached_tvdb_id.value if not tvdb_id: return None rec_show = RecommendedShow( self, show_obj.get('imdb_tt'), show_obj.get('name'), INDEXER_TVDBV2, int(tvdb_id), **{ 'rating': show_obj.get('rating'), 'votes': show_obj.get('votes'), 'image_href': show_obj.get('imdb_url') }) if show_obj.get('image_url_large'): rec_show.cache_image(show_obj.get('image_url_large')) return rec_show
def _create_recommended_show(self, show_obj): """Create the RecommendedShow object from the returned showobj.""" rec_show = RecommendedShow( self, show_obj['show']['ids'], show_obj['show']['title'], INDEXER_TVDBV2, # indexer show_obj['show']['ids']['tvdb'], **{ 'rating': show_obj['show']['rating'], 'votes': try_int(show_obj['show']['votes'], '0'), 'image_href': 'http://www.trakt.tv/shows/{0}'.format( show_obj['show']['ids']['slug']), # Adds like: {'tmdb': 62126, 'tvdb': 304219, 'trakt': 79382, 'imdb': 'tt3322314', # 'tvrage': None, 'slug': 'marvel-s-luke-cage'} 'ids': show_obj['show']['ids'] }) use_default = None image = None try: if not missing_posters.has(show_obj['show']['ids']['tvdb']): image = self.check_cache_for_poster(show_obj['show']['ids']['tvdb']) or \ self.tvdb_api_v2.config['session'].series_api.series_id_images_query_get(show_obj['show']['ids']['tvdb'], key_type='poster').data[0].file_name else: log.info('CACHE: Missing poster on TVDB for show {0}', show_obj['show']['title']) use_default = self.default_img_src except ApiException as error: use_default = self.default_img_src if getattr(error, 'status', None) == 404: log.info('Missing poster on TheTVDB for show {0}', show_obj['show']['title']) missing_posters.append(show_obj['show']['ids']['tvdb']) except Exception as error: use_default = self.default_img_src log.debug('Missing poster on TheTVDB, cause: {0!r}', error) if image: rec_show.cache_image( 'http://thetvdb.com/banners/{0}'.format(image), default=use_default) else: rec_show.cache_image('', default=use_default) # As the method below requires allot of resources, i've only enabled it when # the shows language or country is 'jp' (japanese). Looks a litle bit akward, # but alternative is allot of resource used if 'jp' in [show_obj['show']['country'], show_obj['show']['language']]: rec_show.check_if_anime(self.anidb, show_obj['show']['ids']['tvdb']) return rec_show
def _create_recommended_show(self, storage_key, series): """Create the RecommendedShow object from the returned showobj.""" rec_show = RecommendedShow( self, series['show']['ids'], series['show']['title'], INDEXER_TVDBV2, # indexer series['show']['ids']['tvdb'], **{'rating': series['show']['rating'], 'votes': try_int(series['show']['votes'], '0'), 'image_href': 'http://www.trakt.tv/shows/{0}'.format(series['show']['ids']['slug']), # Adds like: {'tmdb': 62126, 'tvdb': 304219, 'trakt': 79382, 'imdb': 'tt3322314', # 'tvrage': None, 'slug': 'marvel-s-luke-cage'} 'ids': series['show']['ids'] } ) use_default = None image = None try: if not missing_posters.has(series['show']['ids']['tvdb']): image = self.check_cache_for_poster(series['show']['ids']['tvdb']) or \ self.tvdb_api_v2.config['session'].series_api.series_id_images_query_get( series['show']['ids']['tvdb'], key_type='poster').data[0].file_name else: log.info('CACHE: Missing poster on TVDB for show {0}', series['show']['title']) use_default = self.default_img_src except ApiException as error: use_default = self.default_img_src if getattr(error, 'status', None) == 404: log.info('Missing poster on TheTVDB for show {0}', series['show']['title']) missing_posters.append(series['show']['ids']['tvdb']) except Exception as error: use_default = self.default_img_src log.debug('Missing poster on TheTVDB, cause: {0!r}', error) image_url = '' if image: image_url = self.tvdb_api_v2.config['artwork_prefix'].format(image=image) rec_show.cache_image(image_url, default=use_default) # As the method below requires a lot of resources, i've only enabled it when # the shows language or country is 'jp' (japanese). Looks a litle bit akward, # but alternative is a lot of resource used if 'jp' in [series['show']['country'], series['show']['language']]: rec_show.flag_as_anime(series['show']['ids']['tvdb']) return rec_show
def _create_recommended_show(self, series, storage_key=None): """Create the RecommendedShow object from the returned showobj.""" tvdb_id = helpers.get_tvdb_from_id(series.get('imdb_tt'), 'IMDB') if not tvdb_id: return None rec_show = RecommendedShow( self, series.get('imdb_tt'), series.get('name'), INDEXER_TVDBV2, int(tvdb_id), **{ 'rating': series.get('rating'), 'votes': series.get('votes'), 'image_href': series.get('imdb_url') }) if series.get('image_url'): rec_show.cache_image(series.get('image_url')) return rec_show
def _create_recommended_show(self, storage_key, series): """Create the RecommendedShow object from the returned showobj.""" tvdb_id = helpers.get_tvdb_from_id(series.get('imdb_tt'), 'IMDB') if not tvdb_id: return None rec_show = RecommendedShow( self, series.get('imdb_tt'), series.get('name'), INDEXER_TVDBV2, int(tvdb_id), **{'rating': series.get('rating'), 'votes': series.get('votes'), 'image_href': series.get('imdb_url')} ) if series.get('image_url'): rec_show.cache_image(series.get('image_url')) return rec_show
def _create_recommended_show(self, show, subcat=None): """Create the RecommendedShow object from the returned showobj.""" rec_show = RecommendedShow( self, show.trakt, show.title, **{'rating': show.ratings['rating'], 'votes': try_int(show.ratings['votes'], '0'), 'image_href': 'http://www.trakt.tv/shows/{0}'.format(show.ids['ids']['slug']), # Adds like: {'tmdb': 62126, 'tvdb': 304219, 'trakt': 79382, 'imdb': 'tt3322314', # 'tvrage': None, 'slug': 'marvel-s-luke-cage'} 'ids': {f'{k}_id': v for k, v in iteritems(show.ids['ids']) if TRAKT_INDEXERS.get(k)}, 'subcat': subcat, 'genres': [genre.lower() for genre in show.genres], 'plot': show.overview } ) use_default = None image = None try: if not missing_posters.has(show.tvdb): image = self.check_cache_for_poster(show.tvdb) or \ self.tvdb_api_v2.config['session'].series_api.series_id_images_query_get( show.tvdb, key_type='poster').data[0].file_name else: log.info('CACHE: Missing poster on TVDB for show {0}', show.title) use_default = self.default_img_src except ApiException as error: use_default = self.default_img_src if getattr(error, 'status', None) == 404: log.info('Missing poster on TheTVDB for show {0}', show.title) missing_posters.append(show.tvdb) except Exception as error: use_default = self.default_img_src log.debug('Missing poster on TheTVDB, cause: {0!r}', error) image_url = '' if image: image_url = self.tvdb_api_v2.config['artwork_prefix'].format(image=image) rec_show.cache_image(image_url, default=use_default) # As the method below requires a lot of resources, i've only enabled it when # the shows language or country is 'jp' (japanese). Looks a litle bit akward, # but alternative is a lot of resource used if 'jp' in [show.country, show.language]: rec_show.flag_as_anime(show.tvdb) return rec_show