def get_media_path(self): media_file = '' if self.media_format == 'normal': media_file = ImageCache().poster_path(self.indexer_id) if self.media_format == 'thumb': media_file = ImageCache().poster_thumb_path(self.indexer_id) if not all([media_file, os.path.exists(media_file)]): media_file = os.path.join(self.get_media_root(), 'images', self.get_default_media_name()) return media_file
def indexerImage(id=None, which=None): media_format = ('normal', 'thumb')[which in ('banner_thumb', 'poster_thumb', 'small')] image_type = which[0:6] if image_type not in ('fanart', 'poster', 'banner'): sickrage.app.log.error("Invalid image type " + str(image_type) + ", couldn't find it in the " + IndexerApi(INDEXER_TVDB).name + " object") return try: lINDEXER_API_PARMS = IndexerApi(INDEXER_TVDB).api_params.copy() t = IndexerApi(INDEXER_TVDB).indexer(**lINDEXER_API_PARMS) image_name = str(id) + '.' + image_type + '.jpg' try: if media_format == "thumb": image_path = os.path.join(ImageCache()._thumbnails_dir(), image_name) if not os.path.exists(image_path): image_url = t.images(int(id), key_type=image_type)[0]['thumbnail'] sickrage.app.wsession.download(image_url, image_path) else: image_path = os.path.join(ImageCache()._cache_dir(), image_name) if not os.path.exists(image_path): image_url = t.images(int(id), key_type=image_type)[0]['filename'] sickrage.app.wsession.download(image_url, image_path) except (KeyError, IndexError): return if image_type == 'banner': return Banner(int(id), media_format).url elif image_type == 'fanart': return FanArt(int(id), media_format).url elif image_type == 'poster': return Poster(int(id), media_format).url except (indexer_error, IOError) as e: sickrage.app.log.warning( "{}: Unable to look up show on ".format(id) + IndexerApi(INDEXER_TVDB).name + ", not downloading images: {}".format(e.message))
def series_provider_image(series_id=None, series_provider_id=None, which=None): media_format = ('normal', 'thumb')[which in (SeriesImageType.BANNER_THUMB, SeriesImageType.POSTER_THUMB, SeriesImageType.SMALL)] if which not in (SeriesImageType.FANART, SeriesImageType.POSTER, SeriesImageType.BANNER, SeriesImageType.BANNER_THUMB, SeriesImageType.POSTER_THUMB): sickrage.app.log.error( f"Invalid image type {which}, couldn't find it in the {sickrage.app.series_providers[SeriesProviderID.THETVDB].name} object" ) return try: image_name = str(id) + '.' + which.value + '.jpg' if media_format == "thumb": image_path = os.path.join(ImageCache()._thumbnails_dir(), image_name) if not os.path.exists(image_path): image_data = sickrage.app.series_providers[ series_provider_id].images(int(series_id), key_type=which.value) if image_data: image_url = image_data[0]['thumbnail'] WebSession().download(image_url, image_path) else: image_path = os.path.join(ImageCache()._cache_dir(), image_name) if not os.path.exists(image_path): image_data = sickrage.app.series_providers[ series_provider_id].images(int(series_id), key_type=which.value) if image_data: image_url = image_data[0]['filename'] WebSession().download(image_url, image_path) except (KeyError, IndexError): pass if which in [SeriesImageType.BANNER, SeriesImageType.BANNER_THUMB]: return Banner(int(series_id), series_provider_id, media_format) elif which == SeriesImageType.FANART: return FanArt(int(series_id), series_provider_id, media_format) elif which in [SeriesImageType.POSTER, SeriesImageType.POSTER_THUMB]: return Poster(int(series_id), series_provider_id, media_format)
def get_media_path(self): media_file = None if self.get_show(): media_file = ImageCache().fanart_path(self.indexer_id) if not all([media_file, os.path.exists(media_file)]): media_file = os.path.join(self.get_media_root(), 'images', self.get_default_media_name()) return media_file
def indexerImage(id=None, which=None): media_format = ('normal', 'thumb')[which in ('banner_thumb', 'poster_thumb', 'small')] image_type = which[0:6] if image_type not in ('fanart', 'poster', 'banner'): sickrage.app.log.error("Invalid image type " + str(image_type) + ", couldn't find it in the " + IndexerApi(INDEXER_TVDB).name + " object") return try: lINDEXER_API_PARMS = IndexerApi(INDEXER_TVDB).api_params.copy() t = IndexerApi(INDEXER_TVDB).indexer(**lINDEXER_API_PARMS) image_name = str(id) + '.' + image_type + '.jpg' if media_format == "thumb": image_path = os.path.join(ImageCache()._thumbnails_dir(), image_name) if not os.path.exists(image_path): image_data = t.images(int(id), key_type=image_type) if image_data: image_url = image_data[0]['thumbnail'] WebSession().download(image_url, image_path) else: image_path = os.path.join(ImageCache()._cache_dir(), image_name) if not os.path.exists(image_path): image_data = t.images(int(id), key_type=image_type) if image_data: image_url = image_data[0]['filename'] WebSession().download(image_url, image_path) except (KeyError, IndexError): pass if image_type == 'banner': return Banner(int(id), media_format) elif image_type == 'fanart': return FanArt(int(id), media_format) elif image_type == 'poster': return Poster(int(id), media_format)
def populate_cache(self, force=False): sickrage.app.log.debug("Checking & filling cache for show " + self.name) ImageCache().fill_cache(self, force)