From 70b528ed817783436e6331ff7f347fcd941fc29f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 2 Apr 2013 20:31:28 -0700 Subject: [PATCH] use standard query API for album-by-artist (#240) --- beetsplug/web/__init__.py | 15 +++++++-------- docs/changelog.rst | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index ffd417622..a61dae412 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -24,9 +24,10 @@ import os # Utilities. -def _rep(obj, expand=True): +def _rep(obj, expand=False): """Get a flat -- i.e., JSON-ish -- representation of a beets Item or - Album object. + Album object. For Albums, `expand` dictates whether tracks are + included. """ if isinstance(obj, beets.library.Item): out = dict(obj.record) @@ -98,12 +99,6 @@ def all_albums(): all_ids = [row[0] for row in rows] return flask.jsonify(album_ids=all_ids) -@app.route('/album/artist/') -def albums_for_artist(artist): - albums = g.lib.albums(artist=artist) - # Expanding album items would cost a lot of runtime which is not needed here - return flask.jsonify(results=[_rep(album, False) for album in albums]) - @app.route('/album/query/') def album_query(query): parts = query.split('/') @@ -115,7 +110,9 @@ def album_art(album_id): album = g.lib.get_album(album_id) return flask.send_file(album.artpath) + # Artists. + @app.route('/artist/') def all_artists(): with g.lib.transaction() as tx: @@ -123,6 +120,7 @@ def all_artists(): all_artists = [row[0] for row in rows] return flask.jsonify(artist_names=all_artists) + # UI. @app.route('/') @@ -145,6 +143,7 @@ class WebPlugin(BeetsPlugin): cmd.parser.add_option('-d', '--debug', action='store_true', default=False, help='debug mode') def func(lib, opts, args): + args = ui.decargs(args) if args: self.config['host'] = args.pop(0) if args: diff --git a/docs/changelog.rst b/docs/changelog.rst index 21449ae1b..14f28363d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,12 @@ Changelog * Avoid some error cases in the ``update`` command and the ``embedart`` and ``mbsync`` plugins. Invalid or missing files now cause error logs instead of crashing beets. Thanks to Lucas Duailibe. +* :doc:`/plugins/web`: Fix an error when specifying the hostname on the + command line. +* :doc:`/plugins/web`: The underlying API was expanded slightly to support + `Tomahawk`_ collections. Thanks to Uwe L. Korn. + +.. _Tomahawk: http://www.tomahawk-player.org/ 1.1b3 (March 16, 2013) ----------------------