當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。