当前位置: 首页>>代码示例>>Python>>正文


Python helpers.getShowImage函数代码示例

本文整理汇总了Python中sickbeard.metadata.helpers.getShowImage函数的典型用法代码示例。如果您正苦于以下问题:Python getShowImage函数的具体用法?Python getShowImage怎么用?Python getShowImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getShowImage函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_thumbnail

    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:
            logger.log(u"Unable to find a file path to use for this thumbnail, not generating it", logger.DEBUG)
            return False
    
        thumb_url = self._get_episode_thumb_url(ep_obj)
    
        # if we can't find one then give up
        if not thumb_url:
            logger.log("No thumb is available for this episode, not creating a thumb", logger.DEBUG)
            return False

        thumb_data = metadata_helpers.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
开发者ID:Araldwenn,项目名称:Sick-Beard,代码行数:33,代码来源:generic.py

示例2: _retrieve_show_image

    def _retrieve_show_image(self, image_type, show_obj, which=None):
        """
        Gets an image URL from theTVDB.com and TMDB.com, 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_url = None
        indexer_lang = show_obj.lang

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

            lINDEXER_API_PARMS['banners'] = True

            if indexer_lang and not indexer_lang == sickbeard.INDEXER_DEFAULT_LANGUAGE:
                lINDEXER_API_PARMS['language'] = indexer_lang

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

            t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
            indexer_show_obj = t[show_obj.indexerid]
        except (sickbeard.indexer_error, IOError) as e:
            logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
                show_obj.indexer).name + ", not downloading images: " + ex(e), logger.WARNING)
            logger.log(u"%s may be experiencing some problems. Try again later." % sickbeard.indexerApi(show_obj.indexer).name, logger.DEBUG)
            return None

        if image_type not in ('fanart', 'poster', 'banner', 'poster_thumb', 'banner_thumb'):
            logger.log(u"Invalid image type " + str(image_type) + ", couldn't find it in the " + sickbeard.indexerApi(
                show_obj.indexer).name + " object", logger.ERROR)
            return None

        if image_type == 'poster_thumb':
            if getattr(indexer_show_obj, 'poster', None):
                image_url = re.sub('posters', '_cache/posters', indexer_show_obj['poster'])
            if not image_url:
                # Try and get images from TMDB
                image_url = self._retrieve_show_images_from_tmdb(show_obj, image_type)
        elif image_type == 'banner_thumb':
            if getattr(indexer_show_obj, 'banner', None):
                image_url = re.sub('graphical', '_cache/graphical', indexer_show_obj['banner'])
        else:
            if getattr(indexer_show_obj, image_type, None):
                image_url = indexer_show_obj[image_type]
            if not image_url:
                # Try and get images from TMDB
                image_url = self._retrieve_show_images_from_tmdb(show_obj, image_type)

        if image_url:
            image_data = metadata_helpers.getShowImage(image_url, which)
            return image_data

        return None
开发者ID:Thraxis,项目名称:pymedusa,代码行数:60,代码来源:generic.py

示例3: save_season_banners

    def save_season_banners(self, show_obj, season):
        """
        Saves all season banners to disk for the given show.

        show_obj: a TVShow object for which to save the season thumbs

        Cycles through all seasons and saves the season banners if possible. This
        method should not need to be overridden by implementing classes, changing
        _season_banners_dict and get_season_banner_path should be good enough.
        """

        season_dict = self._season_banners_dict(show_obj, season)
        result = []

        # Returns a nested dictionary of season art with the season
        # number as primary key. It's really overkill but gives the option
        # to present to user via ui to pick down the road.
        for cur_season in season_dict:

            cur_season_art = season_dict[cur_season]

            if len(cur_season_art) == 0:
                continue

            # Just grab whatever's there for now
            art_id, season_url = cur_season_art.popitem()  # @UnusedVariable

            season_banner_file_path = self.get_season_banner_path(
                show_obj, cur_season)

            if not season_banner_file_path:
                logger.log(
                    u"Path for season " + str(cur_season) +
                    " came back blank, skipping this season", logger.DEBUG)
                continue

            seasonData = metadata_helpers.getShowImage(season_url)

            if not seasonData:
                logger.log(
                    u"No season banner data available, skipping this season",
                    logger.DEBUG)
                continue

            result = result + [
                self._write_image(seasonData, season_banner_file_path)
            ]
        if result:
            return all(result)
        else:
            return False

        return True
开发者ID:GodZZila,项目名称:SickRage,代码行数:53,代码来源:generic.py

示例4: _retrieve_show_image

 def _retrieve_show_image(self, image_type, show_obj, which=None, all_images=False):
     """
     Gets an image URL from theTVDB.com or fanart.tv (depending on type), 
     downloads it, and returns the data.
     
     image_type: type of image to retrieve (currently supported: poster, fanart, banner, landscape, logo, clearart, character)
     show_obj: a TVShow object to use when searching for the image
     which: optional, a specific numbered poster to look for
     all_images: optional, if all_images is true, it will return a list of dictionary objects containing the keys 'id' and 'data' 
                 representing all_images images of that type that could be found (only for fanart.tv images).
     
     Returns: the binary image data if available, or else None
     """        
     TVDB_TYPES = ('fanart', 'poster', 'banner')
     FANARTTV_TYPES = ('landscape', 'logo', 'clearart', 'character', 'extra_fanart')
     
     if image_type in TVDB_TYPES:
         api = 'tvdb'
     elif image_type in FANARTTV_TYPES:
         api = 'fanart.tv'
     else:
         logger.log(u"Invalid image type "+str(image_type), logger.ERROR)
         return None
     
     image_data = None
     if api is 'tvdb':
         tvdb_lang = show_obj.lang
 
         try:
             # There's gotta be a better way of doing this but we don't wanna
             # change the language value elsewhere
             ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy()
 
             if tvdb_lang and not tvdb_lang == 'en':
                 ltvdb_api_parms['language'] = tvdb_lang
 
             t = tvdb_api.Tvdb(banners=True, **ltvdb_api_parms)
             tvdb_show_obj = t[show_obj.tvdbid]
         except (tvdb_exceptions.tvdb_error, IOError), e:
             logger.log(u"Unable to look up show on TVDB, not downloading images: "+ex(e), logger.ERROR)
             return None
     
         image_url = tvdb_show_obj[image_type]
     
         image_data = metadata_helpers.getShowImage(image_url, which)
开发者ID:Boehemyth,项目名称:Sick-Beard,代码行数:45,代码来源:generic.py

示例5: save_season_banners

    def save_season_banners(self, show_obj, season):
        """
        Saves all season banners to disk for the given show.

        show_obj: a TVShow object for which to save the season thumbs

        Cycles through all seasons and saves the season banners if possible.
        """

        season_dict = self._season_image_dict(show_obj, season, 'seasonwides')
        result = []

        # Returns a nested dictionary of season art with the season
        # number as primary key. It's really overkill but gives the option
        # to present to user via ui to pick down the road.
        for cur_season in season_dict:

            cur_season_art = season_dict[cur_season]

            if 0 == len(cur_season_art):
                continue

            # Just grab whatever's there for now
            art_id, season_url = cur_season_art.popitem()  # @UnusedVariable

            season_banner_file_path = self.get_season_banner_path(show_obj, cur_season)

            if not season_banner_file_path:
                logger.log(u'Path for season ' + str(cur_season) + ' came back blank, skipping this season',
                           logger.DEBUG)
                continue

            season_data = metadata_helpers.getShowImage(season_url, showName=show_obj.name)

            if not season_data:
                logger.log(u'No season banner data available, skipping this season', logger.DEBUG)
                continue

            result = result + [self._write_image(season_data, season_banner_file_path)]

        if result:
            return all(result)
        return False
开发者ID:JackDandy,项目名称:SickGear,代码行数:43,代码来源:generic.py

示例6: in

    
        if image_type not in ('fanart', 'poster', 'banner', 'poster_thumb', 'banner_thumb'):
            logger.log(u"Invalid image type "+str(image_type)+", couldn't find it in the TVDB object", logger.ERROR)
            return None

        try:
            if image_type == 'poster_thumb':
                image_url = re.sub('posters', '_cache/posters', tvdb_show_obj['poster'])
            elif image_type == 'banner_thumb':
                image_url = re.sub('graphical', '_cache/graphical', tvdb_show_obj['banner'])
            else:
                image_url = tvdb_show_obj[image_type]
        except:
            return None        
    
        image_data = metadata_helpers.getShowImage(image_url, which)

        return image_data
    
    def _season_thumb_dict(self, show_obj):
        """
        Should return a dict like:
        
        result = {<season number>: 
                    {1: '<url 1>', 2: <url 2>, ...},}
        """

        # This holds our resulting dictionary of season art
        result = {}
    
        tvdb_lang = show_obj.lang
开发者ID:Araldwenn,项目名称:Sick-Beard,代码行数:30,代码来源:generic.py

示例7: len

                    if len(image_urls) is 0:
                        logger.log(u"Unable to find any suitable extra fanart images for "+tvshow.name+" on Fanart.tv.")
                        return None
                    else:
                        best = TvShow.get_best_leaf([background for background in tvshow.backgrounds if background.language == show_obj.lang])
                        if best is not None:
                            image_url = best.url
                        else:
                            logger.log(u"Unable to find any suitable extra fanart images for "+tvshow.name+" on Fanart.tv")
                            return None
            
            # Build image data to return
            if all_images:
                image_data = []
                for tup in image_urls:
                    image_data.append(dict(id=tup[0], data=metadata_helpers.getShowImage(tup[1])))
            else:
                image_data = metadata_helpers.getShowImage(image_url)
        else:
            # This should be impossible
            raise RuntimeError()

        return image_data
    
    def _season_thumb_dict(self, show_obj):
        """
        Should return a dict like:
        
        result = {<season number>: 
                    {1: '<url 1>', 2: <url 2>, ...},}
        """
开发者ID:Boehemyth,项目名称:Sick-Beard,代码行数:31,代码来源:generic.py

示例8: _retrieve_show_image

    def _retrieve_show_image(self, image_type, show_obj, which=None):
        """
        Gets an image URL from theTVDB.com, fanart.tv and TMDB.com, downloads it and returns the data.
        If type is fanart, multiple image src urls are returned instead of a single data image.

        image_type: type of image to retrieve (currently supported: fanart, poster, banner, poster_thumb, banner_thumb)
        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
        """
        indexer_lang = show_obj.lang

        try:
            # There's gotta be a better way of doing this but we don't wanna
            # change the language value elsewhere
            lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
            if image_type.startswith('fanart'):
                lINDEXER_API_PARMS['fanart'] = True
            elif image_type.startswith('poster'):
                lINDEXER_API_PARMS['posters'] = True
            else:
                lINDEXER_API_PARMS['banners'] = True
            lINDEXER_API_PARMS['dvdorder'] = 0 != show_obj.dvdorder

            if indexer_lang and not 'en' == indexer_lang:
                lINDEXER_API_PARMS['language'] = indexer_lang

            t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
            indexer_show_obj = t[show_obj.indexerid, False]
        except (sickbeard.indexer_error, IOError) as e:
            logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
                show_obj.indexer).name + ", not downloading images: " + ex(e), logger.WARNING)
            return None

        if not self._valid_show(indexer_show_obj, show_obj):
            return None

        return_links = False
        if 'fanart_all' == image_type:
            return_links = True
            image_type = 'fanart'

        if image_type not in ('poster', 'banner', 'fanart', 'poster_thumb', 'banner_thumb'):
            logger.log(u"Invalid image type " + str(image_type) + ", couldn't find it in the " + sickbeard.indexerApi(
                show_obj.indexer).name + " object", logger.ERROR)
            return None

        image_urls = []
        init_url = None
        if 'poster_thumb' == image_type:
            if getattr(indexer_show_obj, 'poster', None) is not None:
                image_url = re.sub('posters', '_cache/posters', indexer_show_obj['poster'])
                if image_url:
                    image_urls.append(image_url)
            for item in self._fanart_urls_from_show(show_obj, image_type, indexer_lang, True) or []:
                image_urls.append(item[2])
            if 0 == len(image_urls):
                for item in self._tmdb_image_url(show_obj, image_type) or []:
                    image_urls.append(item[2])

        elif 'banner_thumb' == image_type:
            if getattr(indexer_show_obj, 'banner', None) is not None:
                image_url = re.sub('graphical', '_cache/graphical', indexer_show_obj['banner'])
                if image_url:
                    image_urls.append(image_url)
            for item in self._fanart_urls_from_show(show_obj, image_type, indexer_lang, True) or []:
                image_urls.append(item[2])
        else:
            for item in self._fanart_urls_from_show(show_obj, image_type, indexer_lang) or []:
                image_urls.append(item[2])

            if getattr(indexer_show_obj, image_type, None) is not None:
                image_url = indexer_show_obj[image_type]
                if image_url:
                    image_urls.append(image_url)
                    if 'poster' == image_type:
                        init_url = image_url

            if 0 == len(image_urls) or 'fanart' == image_type:
                for item in self._tmdb_image_url(show_obj, image_type) or []:
                    image_urls.append('%s?%s' % (item[2], item[0]))

        image_data = len(image_urls) or None
        if image_data:
            if return_links:
                return image_urls
            else:
                image_data = metadata_helpers.getShowImage((init_url, image_urls[0])[None is init_url], which, show_obj.name)

        if None is not image_data:
            return image_data

        return None
开发者ID:JackDandy,项目名称:SickGear,代码行数:94,代码来源:generic.py


注:本文中的sickbeard.metadata.helpers.getShowImage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。