Example #1
0
def showImage(show=None, which=None):
    media_format = ('normal', 'thumb')[which in ('banner_thumb', 'poster_thumb', 'small')]

    if which[0:6] == 'banner':
        return Banner(show, media_format)
    elif which[0:6] == 'fanart':
        return FanArt(show, media_format)
    elif which[0:6] == 'poster':
        return Poster(show, media_format)
    elif which[0:7] == 'network':
        return Network(show, media_format)
Example #2
0
def series_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 in (SeriesImageType.BANNER, SeriesImageType.BANNER_THUMB):
        return Banner(series_id, series_provider_id, media_format)
    elif which == SeriesImageType.FANART:
        return FanArt(series_id, series_provider_id, media_format)
    elif which in (SeriesImageType.POSTER, SeriesImageType.POSTER_THUMB):
        return Poster(series_id, series_provider_id, media_format)
    elif which == SeriesImageType.NETWORK:
        return Network(series_id, series_provider_id, media_format)
Example #3
0
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))
Example #4
0
def showImage(show=None, which=None):
    media = None
    media_format = ('normal', 'thumb')[which in ('banner_thumb', 'poster_thumb', 'small')]

    try:
        if which[0:6] == 'banner':
            media = Banner(show, media_format)
        elif which[0:6] == 'fanart':
            media = FanArt(show, media_format)
        elif which[0:6] == 'poster':
            media = Poster(show, media_format)
        elif which[0:7] == 'network':
            media = Network(show, media_format)

        static_url = url_escape(media.get_media, False)
        return static_url
    except:
        pass
Example #5
0
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)
Example #6
0
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)