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


Python ImageBase.update_info_from方法代码示例

本文整理汇总了Python中foobnix.helpers.image.ImageBase.update_info_from方法的典型用法代码示例。如果您正苦于以下问题:Python ImageBase.update_info_from方法的具体用法?Python ImageBase.update_info_from怎么用?Python ImageBase.update_info_from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在foobnix.helpers.image.ImageBase的用法示例。


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

示例1: InfoPanelWidget

# 需要导入模块: from foobnix.helpers.image import ImageBase [as 别名]
# 或者: from foobnix.helpers.image.ImageBase import update_info_from [as 别名]

#.........这里部分代码省略.........
        bean = update_bean_from_normalized_text(bean)
        
        if not bean.artist or not bean.title:
            logging.debug("Artist and title not defined")
        
        self.bean = bean
        
        self.update_info_panel()
        
    
    def show_album_title(self):
        bean = self.bean
        """update info album and year"""
        
        album_name = self.controls.lastfm.get_album_name(bean.artist, bean.title)
        album_year = self.controls.lastfm.get_album_year(bean.artist, bean.title)
      
        info_line = bean.artist        
        if album_name:
            info_line = album_name
        if album_name and album_year:
            info_line = album_name + "(" + album_year + ")"
            
        self.album_label.set_markup("<b>%s</b>" % info_line)
  
    
    def show_disc_cover(self):
        bean = self.bean
        
        """update image"""
        if not bean.image:
            bean.image = self.controls.lastfm.get_album_image_url(bean.artist, bean.title)
        
        self.image.update_info_from(bean)
        self.controls.trayicon.update_info_from(bean)
        
    def show_similar_lyrics(self):
        if self.info_cache.lyric_bean == self.bean:
            return None
        self.info_cache.lyric_bean = self.bean
        
        """lyrics"""
        text = get_lyrics(self.bean.artist, self.bean.title)
        lyrics_title = "*** %s - %s *** \n" % (self.bean.artist, self.bean.title)
        self.lyrics.set_text(text, lyrics_title)
        
    def show_wiki_info(self):
        if self.info_cache.wiki_artist == self.bean.artist:
            return None
        self.info_cache.wiki_artist = self.bean.artist    
        if "ru" in locale.getlocale()[0]:
            self.wiki_label.set_uri("http://ru.wikipedia.org/w/index.php?&search=%s" % self.bean.artist)
        else:
            self.wiki_label.set_uri("http://en.wikipedia.org/w/index.php?&search=%s" % self.bean.artist)
        
        self.last_fm_label.set_uri("http://www.last.fm/search?q=%s" % self.bean.artist)
        
        artist = self.controls.lastfm.get_network().get_artist(self.bean.artist)        
        self.wiki.set_text(artist.get_bio_content(), self.bean.artist)
        
        images = artist.get_images(limit=5)
        
        for image in images:
            try:
                url = image.sizes.large
            except AttributeError:
开发者ID:Lomir,项目名称:foobnix,代码行数:70,代码来源:infopanel.py

示例2: InfoPanelWidget

# 需要导入模块: from foobnix.helpers.image import ImageBase [as 别名]
# 或者: from foobnix.helpers.image.ImageBase import update_info_from [as 别名]

#.........这里部分代码省略.........
            if isinstance(info_line, unicode) or isinstance(info_line, str) :
                FCache().album_titles[bean.text] = info_line
        info_line.replace('&', '&amp;')
        self.album_label.set_markup("<b>%s</b>" % info_line)
        self.controls.coverlyrics.album_title.set_markup("<b>%s</b>" % info_line)
        
    def show_disc_cover(self):
        bean = self.bean
        dict = FCache().covers
        
        """update image"""
        if not bean.image:
            if not os.path.isdir(COVERS_DIR):
                os.mkdir(COVERS_DIR)
            list_images = os.listdir(COVERS_DIR)
            '''remove extra keys'''
            for key in dict.keys():
                if (key+'.jpg') not in list_images:
                    del dict[key]
            '''remove extra files'''
            for file in list_images:
                if os.path.splitext(file)[0] not in dict.keys():
                    os.remove(os.path.join(COVERS_DIR, file))
            
            for list, key in zip(dict.values(), dict.keys()):
                if bean.text in list:
                    bean.image = os.path.join(COVERS_DIR, key + ".jpg")
                    break
            
            if not bean.image:
                '''get image url'''
                bean.image = self.controls.lastfm_service.get_album_image_url(bean.artist, bean.title)
                              
        self.image.update_info_from(bean)
        
        if not bean.image:
            logging.warning("""""Can't get cover image. Check the correctness of the artist's name and track title""""")
            
        '''make .jpg image and store it in cache'''        
        if bean.image and bean.image.startswith("http://"):
            url_basename = os.path.splitext(os.path.basename(bean.image))[0]
            if dict.has_key(url_basename):
                dict[url_basename].append(bean.text)
            else:
                dict[url_basename] = [bean.text]
                self.image.get_pixbuf().save(os.path.join(COVERS_DIR, url_basename + '.jpg'), "jpeg", {"quality":"90"})
        
        self.controls.trayicon.update_info_from(bean)
        self.controls.coverlyrics.set_cover()
        
        
    def show_similar_lyrics(self):
        if self.info_cache.lyric_bean == self.bean:
            return None
        self.info_cache.lyric_bean = self.bean
        
        """lyrics"""
        if not os.path.isdir(LYRICS_DIR):
            os.mkdir(LYRICS_DIR)
        lyrics_list = os.listdir(LYRICS_DIR)
        lyrics_title = "*** %s - %s *** \n" % (self.bean.artist, self.bean.title)
        if lyrics_title in lyrics_list:
            text = "".join(open(os.path.join(LYRICS_DIR, lyrics_title), 'r').readlines())
        else:
            text = get_lyrics(self.bean.artist, self.bean.title)
            if text:
开发者ID:matttbe,项目名称:foobnix,代码行数:70,代码来源:infopanel.py


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