From 43936cd84c030e2588602c9eb99b47419ca905f8 Mon Sep 17 00:00:00 2001 From: Steve Johnson Date: Sat, 14 Jan 2017 00:12:07 -0800 Subject: [PATCH] /item/at_path/ endpoint More at_path /item/by_path docs --- beetsplug/web/__init__.py | 8 ++++++++ docs/plugins/web.rst | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 05872f6d2..88bf299e4 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -221,6 +221,14 @@ def item_query(queries): return g.lib.items(queries) +@app.route('/item/at_path/') +def item_at_path(path): + try: + return flask.jsonify(_rep(beets.library.Item.from_path('/' + path))) + except beets.library.ReadError: + return flask.abort(404) + + @app.route('/item/values/') def item_unique_field_values(key): sort_key = flask.request.args.get('sort_key', key) diff --git a/docs/plugins/web.rst b/docs/plugins/web.rst index 45000dc26..93a67e7ea 100644 --- a/docs/plugins/web.rst +++ b/docs/plugins/web.rst @@ -162,6 +162,13 @@ response includes all the items requested. If a track is not found it is silentl dropped from the response. +``GET /item/by_path/...`` ++++++++++++++++++++++ + +Look for an item at the given path on the server. If it corresponds to a track, +return the track in the same format as /item/*. + + ``GET /item/query/querystring`` +++++++++++++++++++++++++++++++