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
def __init__(self): """ Init artists content """ Gtk.Stack.__init__(self) InfoCache.init() self._stop = False self._cancel = Gio.Cancellable.new() self._artist = "" self.set_transition_duration(500) self.set_transition_type(Gtk.StackTransitionType.CROSSFADE) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/InfoContent.ui') self._content = builder.get_object('content') self._image = builder.get_object('image') self._menu_found = builder.get_object('menu-found') self._menu_not_found = builder.get_object('menu-not-found') self.add_named(builder.get_object('widget'), 'widget') self.add_named(builder.get_object('notfound'), 'notfound') self._spinner = builder.get_object('spinner') self.add_named(self._spinner, 'spinner')
def __init__(self): """ Init artists content """ Gtk.Stack.__init__(self) InfoCache.init() self._stop = False self.__cancel = Gio.Cancellable.new() self._artist = "" self.set_transition_duration(500) self.set_transition_type(Gtk.StackTransitionType.CROSSFADE) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/InfoContent.ui') self.__content = builder.get_object('content') self.__image = builder.get_object('image') self._menu_found = builder.get_object('menu-found') self._menu_not_found = builder.get_object('menu-not-found') self.add_named(builder.get_object('widget'), 'widget') self.add_named(builder.get_object('notfound'), 'notfound') self._spinner = builder.get_object('spinner') self.add_named(self._spinner, 'spinner')
def __init__(self): """ Init artists content """ Gtk.Stack.__init__(self) InfoCache.init() self._stop = False self.__cancel = Gio.Cancellable.new() self._artist = "" self.set_transition_duration(500) self.set_transition_type(Gtk.StackTransitionType.CROSSFADE) builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/InfoContent.ui") self.__content = builder.get_object("content") self.__image = builder.get_object("image") self._menu_found = builder.get_object("menu-found") self._menu_not_found = builder.get_object("menu-not-found") self.__error = builder.get_object("error") self.add_named(builder.get_object("widget"), "widget") self.add_named(builder.get_object("notfound"), "notfound") self._spinner = builder.get_object("spinner") self.add_named(self._spinner, "spinner")
def __cache_artists_info(self): """ Cache info for all artists """ # We create cache if needed InfoCache.init() # Then cache for lastfm/wikipedia/spotify/deezer/... for (artist_id, artist) in Lp().artists.get([]): if not get_network_available() or\ InfoCache.exists(artist): continue artwork_set = False for (api, helper, unused) in InfoCache.WEBSERVICES: debug("Downloader::__cache_artists_info(): %s@%s" % (artist, api)) if helper is None: continue try: method = getattr(self, helper) (url, content) = method(artist) if url is not None: s = Lio.File.new_for_uri(url) (status, data, tag) = s.load_contents() if status: artwork_set = True InfoCache.add(artist, content, data, api) debug("Downloader::__cache_artists_info(): %s" % url) else: InfoCache.add(artist, None, None, api) except Exception as e: print("Downloader::__cache_artists_info():", e, artist) InfoCache.add(artist, None, None, api) if artwork_set: GLib.idle_add(Lp().art.emit, 'artist-artwork-changed', artist) self.__cache_artists_running = False
def __cache_artists_info(self): """ Cache info for all artists """ # We create cache if needed InfoCache.init() # Then cache for lastfm/wikipedia/spotify/deezer/... for (artist_id, artist, sort) in Lp().artists.get([]): if not get_network_available() or\ InfoCache.exists(artist): continue artwork_set = False for (api, helper, unused) in InfoCache.WEBSERVICES: debug("Downloader::__cache_artists_info(): %s@%s" % (artist, api)) if helper is None: continue try: method = getattr(self, helper) (url, content) = method(artist) if url is not None: s = Lio.File.new_for_uri(url) (status, data, tag) = s.load_contents() if status: artwork_set = True InfoCache.add(artist, content, data, api) debug("Downloader::__cache_artists_info(): %s" % url) else: InfoCache.add(artist, None, None, api) except Exception as e: print("Downloader::__cache_artists_info():", e, artist) InfoCache.add(artist, None, None, api) if artwork_set: GLib.idle_add(Lp().art.emit, 'artist-artwork-changed', artist) self.__cache_artists_running = False