Exemple #1
0
    def save_thumbnail(self, ep_obj):
        """
        Retrieves a thumbnail and saves it to the correct spot. This method should not need to
        be overridden by implementing classes, changing get_episode_thumb_path and
        _get_episode_thumb_url should suffice.

        ep_obj: a TVEpisode object for which to generate a thumbnail
        """

        file_path = self.get_episode_thumb_path(ep_obj)

        if not file_path:
            sickrage.app.log.debug("Unable to find a file path to use for this thumbnail, not generating it")
            return False

        thumb_url = self._get_episode_thumb_url(ep_obj)

        # if we can't find one then give up
        if not thumb_url:
            sickrage.app.log.debug("No thumb is available for this episode, not creating a thumb")
            return False

        thumb_data = getShowImage(thumb_url)

        result = self._write_image(thumb_data, file_path)

        if not result:
            return False

        for cur_ep in [ep_obj] + ep_obj.relatedEps:
            cur_ep.hastbn = True

        return True
Exemple #2
0
    def _retrieve_show_image(self, image_type, show_obj, which=0):
        """
        Gets an image URL from theTVDB.com and fanart.tv, downloads it and returns the data.

        image_type: type of image to retrieve (currently supported: fanart, poster, banner)
        show_obj: a TVShow object to use when searching for the image
        which: optional, a specific numbered poster to look for

        Returns: the binary image data if available, or else None
        """

        image_data = None
        indexer_lang = show_obj.lang or sickrage.app.config.indexer_default_language

        try:
            # There's gotta be a better way of doing this but we don't wanna
            # change the language value elsewhere
            lINDEXER_API_PARMS = IndexerApi(show_obj.indexer).api_params.copy()

            lINDEXER_API_PARMS['language'] = indexer_lang

            if show_obj.dvdorder != 0:
                lINDEXER_API_PARMS['dvdorder'] = True

            t = IndexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)

        except (indexer_error, IOError) as e:
            sickrage.app.log.warning("{}: Unable to look up show on ".format(show_obj.indexerid) + IndexerApi(
                show_obj.indexer).name + ", not downloading images: {}".format(e))
            sickrage.app.log.debug("Indexer " + IndexerApi(
                show_obj.indexer).name + " maybe experiencing some problems. Try again later")
            return None

        if image_type not in ('fanart', 'poster', 'series', 'poster_thumb', 'series_thumb'):
            sickrage.app.log.warning(
                "Invalid image type " + str(image_type) + ", couldn't find it in the " + IndexerApi(
                    show_obj.indexer).name + " object")
            return

        if image_type == 'poster_thumb':
            try:
                image_url = t.images(show_obj.indexerid, key_type='poster')[which]['thumbnail']
            except (KeyError, IndexError):
                image_url = self._retrieve_show_images_from_fanart(show_obj, image_type, True)
        elif image_type == 'series_thumb':
            try:
                image_url = t.images(show_obj.indexerid, key_type='series')[which]['thumbnail']
            except (KeyError, IndexError):
                image_url = self._retrieve_show_images_from_fanart(show_obj, image_type, True)
        else:
            try:
                image_url = t.images(show_obj.indexerid, key_type=image_type)[which]['filename']
            except (KeyError, IndexError):
                image_url = self._retrieve_show_images_from_fanart(show_obj, image_type)

        if image_url:
            image_data = getShowImage(image_url)

        return image_data
Exemple #3
0
    def save_season_banner(self, show_obj, season, which=0):
        season_url = self._retrieve_season_banner_image(show_obj, season, which)

        season_banner_file_path = self.get_season_banner_path(show_obj, season)
        if not season_banner_file_path:
            sickrage.app.log.debug("Path for season " + str(season) + " came back blank, skipping this season")
            return False

        seasonData = getShowImage(season_url)
        if not seasonData:
            sickrage.app.log.debug("No season banner data available, skipping this season")
            return False

        return self._write_image(seasonData, season_banner_file_path)
Exemple #4
0
    def save_season_poster(self, show_obj, season):
        season_url = self._retrieve_season_poster_image(show_obj, season)

        season_poster_file_path = self.get_season_poster_path(show_obj, season)
        if not season_poster_file_path:
            sickrage.srCore.srLogger.debug(
                "Path for season " + str(season) +
                " came back blank, skipping this season")
            return False

        seasonData = getShowImage(season_url)
        if not seasonData:
            sickrage.srCore.srLogger.debug(
                "No season poster data available, skipping this season")
            return False

        return self._write_image(seasonData, season_poster_file_path)