libsaria: Return album art as part of all_attrs()
If the album art exists, I might as well return it so it can be set in the main gtk thread. If it doesn't exist, I'll trigger a web search for it.
This commit is contained in:
parent
851c7251a2
commit
e8e0c5d743
|
@ -68,13 +68,19 @@ def lfm_cache_album(artist, album, title, file):
|
|||
pass
|
||||
return False
|
||||
|
||||
def get_album_art(file):
|
||||
attrs = sources.all_attrs()
|
||||
def get_album_art(attrs):
|
||||
print attrs
|
||||
file = cache.get_item(attrs["artist"], attrs["album"], attrs["title"], "Folder.jpg", lfm_cache_album)
|
||||
callbacks.get_art(file, attrs["id"])
|
||||
|
||||
def get_artwork(file):
|
||||
threading.Thread(target=get_album_art, args=(file,)).start()
|
||||
def get_artwork(attrs):
|
||||
threading.Thread(target=get_album_art, args=(attrs,)).start()
|
||||
|
||||
def test_artwork(attrs):
|
||||
path = cache.test_item(attrs["artist"], attrs["album"], "Folder.jpg", "images/ocarina.png")
|
||||
if path == "images/ocarina.png":
|
||||
get_artwork(attrs)
|
||||
return path
|
||||
|
||||
def set_artwork(artist, album, img_path):
|
||||
cache.copy_in_file(artist, album, "Folder.jpg", img_path)
|
||||
|
|
|
@ -79,6 +79,7 @@ def all_attrs():
|
|||
if found != False:
|
||||
res["like"] = attrs.get_like("like")
|
||||
res["count"] = attrs.get_count("count")
|
||||
res["art"] = libsaria.path.lastfm.test_artwork(res)
|
||||
return res
|
||||
|
||||
def filter(text):
|
||||
|
|
|
@ -39,6 +39,12 @@ def get_item(artist, album, title, file, cache_func):
|
|||
cache_path = fill_cache(artist, album, title, cache_func, cache_path)
|
||||
return cache_path
|
||||
|
||||
def test_item(artist, album, file, default):
|
||||
cache_path = make_cache_path(artist, album, file)
|
||||
if not file_exists(cache_path):
|
||||
return default
|
||||
return cache_path
|
||||
|
||||
def copy_in_file(artist, album, file, orig_file):
|
||||
cache_path = make_cache_path(artist, album, file)
|
||||
orig = open(orig_file)
|
||||
|
|
Loading…
Reference in New Issue