libsaria: Get album art through new cache

I am working on replacing my old cache functions with something easier
to use.  I can now get album art out of the new cache.
This commit is contained in:
Bryan Schumaker 2011-05-07 09:46:00 -04:00
parent 904b475363
commit a7c7b85fdb
1 changed files with 5 additions and 15 deletions

View File

@ -7,9 +7,9 @@ from libsaria import xm
from libsaria import callbacks
from libsaria import threads
from libsaria import storage
from libsaria.storage import cache
file_id = libsaria.path.file_id
cache = libsaria.cache
pref_attr = xm.find_preferred_attribute
pref_sizes = ["extralarge", "large", "medium", "small"]
@ -77,25 +77,15 @@ def set_art_from_file(file, path):
return False
return True
def get_artwork_tags(artist, album, title):
storage.cache.get_item(artist, album, title, "Folder.jpg", lfm_cache_album)
cached = cache[artist]
file = cached.get("%s.jpg" % album, lfm_cache_album, artist, album, title)
return file
def set_artwork_tags(artist, album, path):
cached = cache[artist]
cached.delete("%s.jpg" % album)
file = cached.get("%s.jpg" % album, set_art_from_file, path)
def get_artwork_id(id):
artist, album, title = sources.get_attrs("artist", "album", "title")
return get_artwork_tags(artist, album, title)
def get_artwork_bg(file):
id = sources.get_attrs("id")
file = get_artwork_id(id)
def get_album_art(file):
id, artist, album, title = sources.get_attrs("id", "artist", "album", "title")
file = cache.get_item(artist, album, title, "Folder.jpg", lfm_cache_album)
callbacks.get_art(file, id)
def get_artwork(file):
threads.background(get_artwork_bg, file)
threads.background(get_album_art, file)