mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
reduced UI blocking with large collections
This commit is contained in:
parent
90c9628616
commit
4f9a8a3f35
59
bin/mpdevil
59
bin/mpdevil
@ -775,9 +775,21 @@ class Client(MPDClient):
|
|||||||
|
|
||||||
def artist_to_playlist(self, artist, genre, mode="default"):
|
def artist_to_playlist(self, artist, genre, mode="default"):
|
||||||
def append():
|
def append():
|
||||||
for album in self.get_albums(artist, genre):
|
if genre is None:
|
||||||
self.findadd("albumartist", album["albumartist"], "albumartistsort", album["albumartistsort"],
|
genre_filter=()
|
||||||
"album", album["album"], "albumsort", album["albumsort"], "date", album["date"])
|
else:
|
||||||
|
genre_filter=("genre", genre)
|
||||||
|
if artist is None:
|
||||||
|
artists=self.get_artists(genre)
|
||||||
|
else:
|
||||||
|
artists=[artist]
|
||||||
|
for albumartist, albumartistsort in artists:
|
||||||
|
albums=self.list(
|
||||||
|
"album", "albumartist", albumartist, "albumartistsort", albumartistsort,
|
||||||
|
*genre_filter, "group", "date", "group", "albumsort")
|
||||||
|
for album in albums:
|
||||||
|
self.findadd("albumartist", albumartist, "albumartistsort", albumartistsort,
|
||||||
|
"album", album["album"], "albumsort", album["albumsort"], "date", album["date"])
|
||||||
self._to_playlist(append, mode)
|
self._to_playlist(append, mode)
|
||||||
|
|
||||||
def comp_list(self, *args): # simulates listing behavior of python-mpd2 1.0
|
def comp_list(self, *args): # simulates listing behavior of python-mpd2 1.0
|
||||||
@ -797,26 +809,6 @@ class Client(MPDClient):
|
|||||||
artists=self.list("albumartist", "genre", genre, "group", "albumartistsort")
|
artists=self.list("albumartist", "genre", genre, "group", "albumartistsort")
|
||||||
return [(artist["albumartist"], artist["albumartistsort"]) for artist in artists]
|
return [(artist["albumartist"], artist["albumartistsort"]) for artist in artists]
|
||||||
|
|
||||||
def get_albums(self, artist, genre):
|
|
||||||
if genre is None:
|
|
||||||
genre_filter=()
|
|
||||||
else:
|
|
||||||
genre_filter=("genre", genre)
|
|
||||||
if artist is None:
|
|
||||||
artists=self.get_artists(genre)
|
|
||||||
else:
|
|
||||||
artists=[artist]
|
|
||||||
albums=[]
|
|
||||||
for albumartist, albumartistsort in artists:
|
|
||||||
albums0=self.list(
|
|
||||||
"album", "albumartist", albumartist, "albumartistsort", albumartistsort,
|
|
||||||
*genre_filter, "group", "date", "group", "albumsort")
|
|
||||||
for album in albums0:
|
|
||||||
album["albumartist"]=albumartist
|
|
||||||
album["albumartistsort"]=albumartistsort
|
|
||||||
albums+=albums0
|
|
||||||
return albums
|
|
||||||
|
|
||||||
def get_cover_path(self, song):
|
def get_cover_path(self, song):
|
||||||
path=None
|
path=None
|
||||||
song_file=song["file"]
|
song_file=song["file"]
|
||||||
@ -2163,6 +2155,16 @@ class AlbumLoadingThread(threading.Thread):
|
|||||||
self._artist=artist
|
self._artist=artist
|
||||||
self._genre=genre
|
self._genre=genre
|
||||||
|
|
||||||
|
def _get_albums(self):
|
||||||
|
for albumartist, albumartistsort in self._artists:
|
||||||
|
albums=main_thread_function(self._client.list)(
|
||||||
|
"album", "albumartist", albumartist, "albumartistsort", albumartistsort,
|
||||||
|
*self._genre_filter, "group", "date", "group", "albumsort")
|
||||||
|
for album in albums:
|
||||||
|
album["albumartist"]=albumartist
|
||||||
|
album["albumartistsort"]=albumartistsort
|
||||||
|
yield album
|
||||||
|
|
||||||
def set_callback(self, callback):
|
def set_callback(self, callback):
|
||||||
self._callback=callback
|
self._callback=callback
|
||||||
|
|
||||||
@ -2181,14 +2183,21 @@ class AlbumLoadingThread(threading.Thread):
|
|||||||
self._iconview.set_markup_column(2) # show artist names
|
self._iconview.set_markup_column(2) # show artist names
|
||||||
else:
|
else:
|
||||||
self._iconview.set_markup_column(1) # hide artist names
|
self._iconview.set_markup_column(1) # hide artist names
|
||||||
self._albums=self._client.get_albums(self._artist, self._genre)
|
if self._genre is None:
|
||||||
|
self._genre_filter=()
|
||||||
|
else:
|
||||||
|
self._genre_filter=("genre", self._genre)
|
||||||
|
if self._artist is None:
|
||||||
|
self._artists=self._client.get_artists(self._genre)
|
||||||
|
else:
|
||||||
|
self._artists=[self._artist]
|
||||||
super().start()
|
super().start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# temporarily display all albums with fallback cover
|
# temporarily display all albums with fallback cover
|
||||||
fallback_cover=GdkPixbuf.Pixbuf.new_from_file_at_size(FALLBACK_COVER, self._cover_size, self._cover_size)
|
fallback_cover=GdkPixbuf.Pixbuf.new_from_file_at_size(FALLBACK_COVER, self._cover_size, self._cover_size)
|
||||||
add=main_thread_function(self._store.append)
|
add=main_thread_function(self._store.append)
|
||||||
for i, album in enumerate(self._albums):
|
for i, album in enumerate(self._get_albums()):
|
||||||
# album label
|
# album label
|
||||||
if album["date"]:
|
if album["date"]:
|
||||||
display_label=f"<b>{GLib.markup_escape_text(album['album'])}</b> ({GLib.markup_escape_text(album['date'])})"
|
display_label=f"<b>{GLib.markup_escape_text(album['album'])}</b> ({GLib.markup_escape_text(album['date'])})"
|
||||||
|
Loading…
Reference in New Issue
Block a user