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


Python InfoCache.exists_in_cache方法代码示例

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


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

示例1: _cache_artists_art

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import exists_in_cache [as 别名]
 def _cache_artists_art(self):
     """
         Cache artwork for all artists
     """
     # We create cache if needed
     InfoCache.init()
     # Then cache artwork for lastfm/wikipedia/spotify
     # We cache content as the same time
     # TODO Make this code more generic
     for (artist_id, artist) in Lp().artists.get([]):
         debug("ArtDownloader::_cache_artists_art(): %s" % artist)
         artwork_set = False
         if not Gio.NetworkMonitor.get_default().get_network_available() or\
                 InfoCache.exists_in_cache(artist):
             continue
         if Lp().lastfm is not None:
             try:
                 (url, content) = Lp().lastfm.get_artist_infos(artist)
                 if url is not None:
                     s = Gio.File.new_for_uri(url)
                     (status, data, tag) = s.load_contents()
                     if status:
                         artwork_set = True
                         InfoCache.cache(artist, content, data, "lastfm")
                     else:
                         InfoCache.cache(artist, None, None, "lastfm")
             except:
                 InfoCache.cache(artist, None, None, "lastfm")
         if ArtDownloader.Wikipedia is not None:
             try:
                 wp = ArtDownloader.Wikipedia()
                 (url, content) = wp.get_page_infos(artist)
                 if url is not None:
                     s = Gio.File.new_for_uri(url)
                     (status, data, tag) = s.load_contents()
                     if status:
                         artwork_set = True
                         InfoCache.cache(artist, content, data, "wikipedia")
                     else:
                         InfoCache.cache(artist, None, None, "wikipedia")
             except:
                 InfoCache.cache(artist, None, None, "wikipedia")
         url = self._get_spotify_artist_artwork(artist)
         if url is not None:
             s = Gio.File.new_for_uri(url)
             (status, data, tag) = s.load_contents()
             if status:
                 artwork_set = True
                 InfoCache.cache(artist, None, data, "spotify")
             else:
                 InfoCache.cache(artist, None, None, "spotify")
         if artwork_set:
             Lp().art.emit('artist-artwork-changed', artist)
     self._cache_artists_running = False
开发者ID:Nikhil-z,项目名称:lollypop,代码行数:56,代码来源:art_downloader.py


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