From 8ff437a68265c5584c7a391ef32c871926e10a5c Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Thu, 3 Feb 2011 08:34:12 -0500 Subject: [PATCH] web server: Load songs from the library browser This patch will load a song clicked on in the original library browser. This is a better action than trying to play the song through html5! --- html/album.py | 27 +++++++++++++++------------ html/controls.js | 5 +++++ html/controls.py | 6 ++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/html/album.py b/html/album.py index 504000fa..6739e0eb 100644 --- a/html/album.py +++ b/html/album.py @@ -5,12 +5,16 @@ from libsaria import path splitext = path.splitext def header(wfile): - wfile.write("\n") + wfile.write("\n") + wfile.write("") @@ -39,13 +43,12 @@ def body(wfile, args): titles = [] for title, key in library.titles(args["artist"], args["album"]): sid = library.song_id(args["artist"], args["album"], key) - track, filepath = library.get_attrs(sid, "track", "filepath") - ext = splitext(filepath)[1] - titles += [(track, sid, ext, title)] + track = library.get_attrs(sid, "track") + titles += [(track, sid, title)] titles.sort() - tags = "%s.%s\n" - for id, sid, ext, title in titles: - wfile.write(tags % (id, sid, ext, title)) + tags = "%s.%s\n" + for id, sid, title in titles: + wfile.write(tags % (id, sid, title)) wfile.write("") wfile.write("") diff --git a/html/controls.js b/html/controls.js index 626cc65b..77af1b7d 100644 --- a/html/controls.js +++ b/html/controls.js @@ -10,6 +10,11 @@ function play() control("play"); } +function load_id(id) +{ + control("load&id="+id); +} + function pause() { control("pause"); diff --git a/html/controls.py b/html/controls.py index b0561b69..49e2458d 100644 --- a/html/controls.py +++ b/html/controls.py @@ -11,6 +11,7 @@ pause = controls.pause stop = controls.stop next = controls.next attrs = libsaria.sources.get_attrs +load_id = libsaria.sources.library.load_id playing = controls.playing forward = controls.seek_forward @@ -43,4 +44,9 @@ def to_html(wfile, args): ret = "by %s" % attrs("artist") elif action == "playing": ret = playing() + elif action == "load": + load_id(int(args['id'])) + play() + #else: + # print action, args wfile.write(str(ret))