def art_retrieved(result): if not result: if artist not in self.blacklist: self.blacklist[artist] = [] album_stripped = MediaArt.strip_invalid_entities(album) self.blacklist[artist].append(album_stripped) self.lookup(item, art_size, callback, itr)
def _add_to_blacklist(self): album = utils.get_album_title(self._media) artist = utils.get_artist_name(self._media) if artist not in self._blacklist: self._blacklist[artist] = [] album_stripped = MediaArt.strip_invalid_entities(album) self._blacklist[artist].append(album_stripped)
def _in_blacklist(self): album = utils.get_album_title(self._media) artist = utils.get_artist_name(self._media) album_stripped = MediaArt.strip_invalid_entities(album) if artist in self._blacklist: if album_stripped in self._blacklist[artist]: return True return False
def _lookup_local(self, item, callback, itr, art_size): """Checks if there is already a local art file, if not calls the remote lookup function""" album = utils.get_album_title(item) artist = utils.get_artist_name(item) def stream_open(thumb_file, result, arguments): try: stream = thumb_file.read_finish(result) except Exception as err: logger.warn("Error: %s, %s", err.__class__, err) do_callback(None) return GdkPixbuf.Pixbuf.new_from_stream_async(stream, None, pixbuf_loaded, None) def pixbuf_loaded(stream, result, data): try: pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result) except Exception as err: logger.warn("Error: %s, %s", err.__class__, err) do_callback(None) return do_callback(pixbuf) return def do_callback(pixbuf): if not pixbuf: surface = DefaultIcon(self._scale).get(DefaultIcon.Type.music, art_size) else: surface = _make_icon_frame(pixbuf, art_size, self._scale) # Sets the thumbnail location for MPRIS to use. item.set_thumbnail( GLib.filename_to_uri(thumb_file.get_path(), None)) GLib.idle_add(callback, surface, itr) return success, thumb_file = MediaArt.get_file(artist, album, "album") if (success and thumb_file.query_exists()): thumb_file.read_async(GLib.PRIORITY_LOW, None, stream_open, None) return stripped_album = MediaArt.strip_invalid_entities(album) if (artist in self.blacklist and stripped_album in self.blacklist[artist]): do_callback(None) return self._lookup_remote(item, callback, itr, art_size)
def _add_to_blacklist(self): # FIXME: coresong can be a CoreAlbum try: album = self._coresong.props.album except AttributeError: album = self._coresong.props.title artist = self._coresong.props.artist if artist not in self._blacklist: self._blacklist[artist] = [] album_stripped = MediaArt.strip_invalid_entities(album) self._blacklist[artist].append(album_stripped)
def _in_blacklist(self): # FIXME: coresong can be a CoreAlbum try: album = self._coresong.props.album except AttributeError: album = self._coresong.props.title artist = self._coresong.props.artist album_stripped = MediaArt.strip_invalid_entities(album) if artist in self._blacklist: if album_stripped in self._blacklist[artist]: return True return False
def _lookup_local(self, item, callback, itr, art_size): """Checks if there is already a local art file, if not calls the remote lookup function""" album = utils.get_album_title(item) artist = utils.get_artist_name(item) def stream_open(thumb_file, result, arguments): try: stream = thumb_file.read_finish(result) except Exception as err: logger.warn("Error: %s, %s", err.__class__, err) do_callback(None) return GdkPixbuf.Pixbuf.new_from_stream_async(stream, None, pixbuf_loaded, None) def pixbuf_loaded(stream, result, data): try: pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result) except Exception as err: logger.warn("Error: %s, %s", err.__class__, err) do_callback(None) return do_callback(pixbuf) return def do_callback(pixbuf): if not pixbuf: surface = DefaultIcon(self._scale).get(DefaultIcon.Type.music, art_size) else: surface = _make_icon_frame(pixbuf, art_size, self._scale) # Sets the thumbnail location for MPRIS to use. item.set_thumbnail(GLib.filename_to_uri(thumb_file.get_path(), None)) GLib.idle_add(callback, surface, itr) return success, thumb_file = MediaArt.get_file(artist, album, "album") if (success and thumb_file.query_exists()): thumb_file.read_async(GLib.PRIORITY_LOW, None, stream_open, None) return stripped_album = MediaArt.strip_invalid_entities(album) if (artist in self.blacklist and stripped_album in self.blacklist[artist]): do_callback(None) return self._lookup_remote(item, callback, itr, art_size)