def library_set_image_for_current_song(self, cache_key): # Search through the rows in the library to see # if we match the currently playing song: play_artist, play_album = library_get_data(cache_key, 'artist', 'album') for row in self.lib_model: artist, album, path = library_get_data(row[1], 'artist', 'album', 'path') if unicode(play_artist).lower() == unicode(artist).lower() \ and unicode(play_album).lower() == unicode(album).lower(): pb = self.get_library_artwork_cached_pb(cache_key, None) self.lib_model.set_value(row.iter, 0, pb)
def library_set_image_for_current_song(self, cache_key, filename): # Search through the rows in the library to see # if we match the currently playing song: play_artist, play_album = library_get_data(cache_key, 'artist', 'album') for row in range(len(self.lib_model)): i = self.lib_model.get_iter((row,)) data = self.lib_model.get_value(i, 1) artist, album, path = library_get_data(data, 'artist', 'album', 'path') if unicode(play_artist).lower() == unicode(artist).lower() \ and unicode(play_album).lower() == unicode(album).lower(): pb = self.get_library_artwork_cached_pb(cache_key, None) self.lib_model.set_value(i, 0, pb)
def library_set_image_for_current_song(self, cache_key): # Search through the rows in the library to see # if we match the currently playing song: play_artist, play_album = library_get_data(cache_key, "artist", "album") if play_artist is None and play_album is None: return for row in self.lib_model: artist, album, path = library_get_data(row[1], "artist", "album", "path") if ( unicode(play_artist).lower() == unicode(artist).lower() and unicode(play_album).lower() == unicode(album).lower() ): pb = self.get_library_artwork_cached_pb(cache_key, None) self.lib_model.set_value(row.iter, 0, pb)
def library_set_image_for_current_song(self, cache_key, filename): # Search through the rows in the library to see # if we match the currently playing song: play_artist, play_album = library_get_data(cache_key, 'artist', 'album') for row in range(len(self.lib_model)): i = self.lib_model.get_iter((row, )) data = self.lib_model.get_value(i, 1) artist, album, path = library_get_data(data, 'artist', 'album', 'path') if unicode(play_artist).lower() == unicode(artist).lower() \ and unicode(play_album).lower() == unicode(album).lower(): pb = self.get_library_artwork_cached_pb(cache_key, None) self.lib_model.set_value(i, 0, pb)
def _library_artwork_update(self): while True: remote_art = False # Wait for items.. self.lib_art_cond.acquire() while(len(self.lib_art_rows_local) == 0 and len(self.lib_art_rows_remote) == 0): self.lib_art_cond.wait() self.lib_art_cond.release() # Try first element, giving precedence to local queue: if len(self.lib_art_rows_local) > 0: i, data, icon = self.lib_art_rows_local[0] remote_art = False elif len(self.lib_art_rows_remote) > 0: i, data, icon = self.lib_art_rows_remote[0] remote_art = True else: i = None if i is not None and self.lib_model.iter_is_valid(i): artist, album, path = library_get_data(data, 'artist', 'album', 'path') if artist is None or album is None: if remote_art: self.lib_art_rows_remote.pop(0) else: self.lib_art_rows_local.pop(0) cache_key = library_set_data(artist=artist, album=album, path=path) filename = None # Try to replace default icons with cover art: pb = self.get_library_artwork_cached_pb(cache_key, None) # No cached pixbuf, try local/remote search: if pb is None: if not remote_art: pb, filename = self.library_get_album_cover(path, artist, album, self.lib_art_pb_size) else: filename = self.target_image_filename(None, path, artist, album) self.artwork_download_img_to_file(artist, album, filename) pb, filename = self.library_get_album_cover(path, artist, album, self.lib_art_pb_size) # Set pixbuf icon in model; add to cache if pb is not None: if filename is not None: self.set_library_artwork_cached_filename(cache_key, filename) gobject.idle_add(self.library_set_cover, i, pb, data) # Remote processed item from queue: if not remote_art: if len(self.lib_art_rows_local) > 0 and (i, data, icon) == self.lib_art_rows_local[0]: self.lib_art_rows_local.pop(0) if pb is None and self.config.covers_pref == consts.ART_LOCAL_REMOTE: # No local art found, add to remote queue for later self.lib_art_rows_remote.append((i, data, icon)) else: if len(self.lib_art_rows_remote) > 0 and (i, data, icon) == self.lib_art_rows_remote[0]: self.lib_art_rows_remote.pop(0) if pb is None: # No remote art found, store self.albumpb filename in cache self.set_library_artwork_cached_filename(cache_key, self.album_filename)
def _library_artwork_update(self): while True: remote_art = False # Wait for items.. self.lib_art_cond.acquire() while (len(self.lib_art_rows_local) == 0 and len(self.lib_art_rows_remote) == 0): self.lib_art_cond.wait() self.lib_art_cond.release() # Try first element, giving precedence to local queue: if len(self.lib_art_rows_local) > 0: i, data, icon = self.lib_art_rows_local[0] remote_art = False elif len(self.lib_art_rows_remote) > 0: i, data, icon = self.lib_art_rows_remote[0] remote_art = True else: i = None if i is not None and self.lib_model.iter_is_valid(i): artist, album, path = library_get_data(data, 'artist', 'album', 'path') if artist is None or album is None: if remote_art: self.lib_art_rows_remote.pop(0) else: self.lib_art_rows_local.pop(0) cache_key = library_set_data(artist=artist, album=album, path=path) filename = None # Try to replace default icons with cover art: pb = self.get_library_artwork_cached_pb(cache_key, None) # No cached pixbuf, try local/remote search: if pb is None: if not remote_art: pb, filename = self.library_get_album_cover( path, artist, album, self.lib_art_pb_size) else: filename = self.target_image_filename( None, path, artist, album) self.artwork_download_img_to_file( artist, album, filename) pb, filename = self.library_get_album_cover( path, artist, album, self.lib_art_pb_size) # Set pixbuf icon in model; add to cache if pb is not None: if filename is not None: self.set_library_artwork_cached_filename( cache_key, filename) gobject.idle_add(self.library_set_cover, i, pb, data) # Remote processed item from queue: if not remote_art: if len(self.lib_art_rows_local) > 0 and ( i, data, icon) == self.lib_art_rows_local[0]: self.lib_art_rows_local.pop(0) if pb is None and self.config.covers_pref == consts.ART_LOCAL_REMOTE: # No local art found, add to remote queue for later self.lib_art_rows_remote.append((i, data, icon)) else: if len(self.lib_art_rows_remote) > 0 and ( i, data, icon) == self.lib_art_rows_remote[0]: self.lib_art_rows_remote.pop(0) if pb is None: # No remote art found, store self.albumpb filename in cache self.set_library_artwork_cached_filename( cache_key, self.album_filename)