libsaria: Get artwork when songs are loaded
I may change this to something that has to be requested by the front end, rather than always fetching it. We'll see.
This commit is contained in:
parent
889e17fab9
commit
d0198cdd1a
|
@ -1,5 +1,7 @@
|
|||
# Bryan Schumaker (4 / 30 / 2011)
|
||||
|
||||
import libsaria
|
||||
|
||||
def null_cb(*args):
|
||||
pass
|
||||
|
||||
|
@ -14,6 +16,7 @@ def pause():
|
|||
on_load = null_cb
|
||||
def load_file(file):
|
||||
on_load(file)
|
||||
libsaria.path.lastfm.get_artwork(file)
|
||||
|
||||
on_like = null_cb
|
||||
def like_song(like):
|
||||
|
@ -22,3 +25,7 @@ def like_song(like):
|
|||
on_set_volume = null_cb
|
||||
def set_volume(prcnt):
|
||||
on_set_volume(prcnt)
|
||||
|
||||
on_get_art = null_cb
|
||||
def get_art(file, id):
|
||||
on_get_art(file, id)
|
||||
|
|
|
@ -4,6 +4,8 @@ import libsaria
|
|||
from libsaria import sources
|
||||
from libsaria import web
|
||||
from libsaria import xm
|
||||
from libsaria import callbacks
|
||||
from libsaria import threads
|
||||
|
||||
file_id = libsaria.path.file_id
|
||||
cache = libsaria.cache
|
||||
|
@ -89,8 +91,10 @@ def get_artwork_id(id):
|
|||
artist, album = sources.get_attrs("artist", "album")
|
||||
return get_artwork_tags(artist, album)
|
||||
|
||||
def get_artwork(filepath):
|
||||
def get_artwork_bg(file):
|
||||
id = sources.get_attrs("id")
|
||||
file = get_artwork_id(id)
|
||||
libsaria.event.start("POSTGETART", file, id)
|
||||
libsaria.event.invite("POSTLOAD", get_artwork, True)
|
||||
callbacks.get_art(file, id)
|
||||
|
||||
def get_artwork(file):
|
||||
threads.background(get_artwork_bg, file)
|
||||
|
|
|
@ -15,9 +15,7 @@ class BG_Thread(Thread):
|
|||
self.func = func
|
||||
self.args = args
|
||||
def run(self):
|
||||
print "running func %s with args %s" % (self.func, self.args)
|
||||
self.func(*self.args)
|
||||
print "exiting func %s" % self.func
|
||||
|
||||
|
||||
def background(func, *args):
|
||||
|
|
|
@ -25,7 +25,7 @@ import queue
|
|||
import library
|
||||
import callbacks
|
||||
|
||||
callbacks.on_getart("images/ocarina.png", 0)
|
||||
callbacks.on_get_art("images/ocarina.png", 0)
|
||||
libsaria.startup()
|
||||
print "Startup took:", uptime()
|
||||
gtk.main()
|
||||
|
|
|
@ -28,12 +28,12 @@ def on_like(like):
|
|||
footer.on_like(like)
|
||||
callbacks.on_like = on_like
|
||||
|
||||
def on_getart(path, id):
|
||||
def on_get_art(path, id):
|
||||
cur_id = libsaria.sources.get_attrs("id")
|
||||
if id != cur_id:
|
||||
path = "images/ocarina.png"
|
||||
footer.set_art(path)
|
||||
invite("POSTGETART", on_getart)
|
||||
callbacks.on_get_art = on_get_art
|
||||
|
||||
def on_load_playlist(*args):
|
||||
playlist.refresh()
|
||||
|
|
Loading…
Reference in New Issue
Block a user