From c709fa7e29e16cd5d2e0b3dc0c5d57ca5b81a6fe Mon Sep 17 00:00:00 2001 From: spl0k Date: Sat, 11 Nov 2017 00:12:10 +0100 Subject: [PATCH] Better errors on listings --- supysonic/api/albums_songs.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 05e93b4..734e07d 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -50,9 +50,12 @@ def rand_songs(): if genre: query = query.find(Track.genre == genre) if fid: - query = query.find(Track.root_folder_id == fid) - count = query.count() + if not store.find(Folder, Folder.id == fid, Folder.root == True).one(): + return request.error_formatter(70, 'Unknown folder') + query = query.find(Track.root_folder_id == fid) + + count = query.count() if not count: return request.formatter({ 'randomSongs': {} }) @@ -70,6 +73,8 @@ def rand_songs(): @app.route('/rest/getAlbumList.view', methods = [ 'GET', 'POST' ]) def album_list(): ltype, size, offset = map(request.values.get, [ 'type', 'size', 'offset' ]) + if not ltype: + return request.error_formatter(10, 'Missing type') try: size = int(size) if size else 10 offset = int(offset) if offset else 0 @@ -120,6 +125,8 @@ def album_list(): @app.route('/rest/getAlbumList2.view', methods = [ 'GET', 'POST' ]) def album_list_id3(): ltype, size, offset = map(request.values.get, [ 'type', 'size', 'offset' ]) + if not ltype: + return request.error_formatter(10, 'Missing type') try: size = int(size) if size else 10 offset = int(offset) if offset else 0