mirror of
https://github.com/beetbox/beets.git
synced 2026-02-13 02:42:38 +01:00
Rename /item/by_path to /item/path and use PathQuery instead of direct file access
This commit is contained in:
parent
05bc4996a8
commit
866a650bc0
2 changed files with 10 additions and 8 deletions
|
|
@ -221,11 +221,14 @@ def item_query(queries):
|
|||
return g.lib.items(queries)
|
||||
|
||||
|
||||
@app.route('/item/at_path/<path:path>')
|
||||
@app.route('/item/path/<path: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']:
|
||||
|
|
|
|||
|
|
@ -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/*``.
|
||||
|
|
|
|||
Loading…
Reference in a new issue