diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 4d5dcba54..d47f1d183 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -221,11 +221,14 @@ def item_query(queries): return g.lib.items(queries) -@app.route('/item/at_path/') +@app.route('/item/path/') def item_at_path(path): - try: - return flask.jsonify(_rep(beets.library.Item.from_path('/' + path))) - except beets.library.ReadError: + g.lib._connection().create_function('bytelower', 1, beets.library._sqlite_bytelower) + query = beets.library.PathQuery('path', u'/' + path) + item = g.lib.items(query).get() + if item: + return flask.jsonify(_rep(item)) + else: return flask.abort(404) @@ -339,8 +342,7 @@ class WebPlugin(BeetsPlugin): # Normalizes json output app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False - app.config['INCLUDE_PATHS'] = ( - self.config.get('include_paths', False)) + app.config['INCLUDE_PATHS'] = self.config['include_paths'] # Enable CORS if required. if self.config['cors']: diff --git a/docs/plugins/web.rst b/docs/plugins/web.rst index 54c507cf0..f0adacc00 100644 --- a/docs/plugins/web.rst +++ b/docs/plugins/web.rst @@ -162,8 +162,8 @@ response includes all the items requested. If a track is not found it is silentl dropped from the response. -``GET /item/by_path/...`` -+++++++++++++++++++++++++ +``GET /item/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/*``.