diff --git a/api/media.py b/api/media.py index 2fe6589..81acacc 100755 --- a/api/media.py +++ b/api/media.py @@ -199,7 +199,7 @@ def cover_art(): app.logger.debug('No Art Found!') res.has_cover_art = False session.commit() - return request.error_formatter(70, 'Cover art not found') + return request.error_formatter(70, 'Cover art not found'), 404 coverfile = coverfile[0] @@ -208,7 +208,7 @@ def cover_art(): try: size = int(size) except: - return request.error_formatter(0, 'Invalid size value') + return request.error_formatter(0, 'Invalid size value'), 404 else: app.logger.debug('Serving cover art: ' + res.path + coverfile) return send_file(os.path.join(res.path, coverfile)) diff --git a/api/search.py b/api/search.py index 0a812dd..b6ae80a 100755 --- a/api/search.py +++ b/api/search.py @@ -33,7 +33,7 @@ def old_search(): 'totalHits': folders.count() + tracks.count(), 'offset': offset, 'match': [ r.as_subsonic_child(request.user) for r in res ] - }}) + }}) else: return request.error_formatter(10, 'Missing search parameter') @@ -41,12 +41,13 @@ def old_search(): 'totalHits': query.count(), 'offset': offset, 'match': [ r.as_subsonic_child(request.user) for r in query.slice(offset, offset + count) ] - }}) + }}) + @app.route('/rest/search2.view', methods = [ 'GET', 'POST' ]) def new_search(): query, artist_count, artist_offset, album_count, album_offset, song_count, song_offset = map( - request.args.get, [ 'query', 'artistCount', 'artistOffset', 'albumCount', 'albumOffset', 'songCount', 'songOffset' ]) + request.args.get, [ 'query', 'artistCount', 'artistOffset', 'albumCount', 'albumOffset', 'songCount', 'songOffset' ]) try: artist_count = int(artist_count) if artist_count else 20 @@ -61,8 +62,8 @@ def new_search(): if not query: return request.error_formatter(10, 'Missing query parameter') - artist_query = Folder.query.filter(~ Folder.tracks.any(), Folder.name.contains(query)).slice(artist_offset, artist_offset + artist_count) - album_query = Folder.query.filter(Folder.tracks.any(), Folder.name.contains(query)).slice(album_offset, album_offset + album_count) + artist_query = Folder.query.filter(~ Folder.tracks.any(), Folder.path.contains(query)).slice(artist_offset, artist_offset + artist_count) + album_query = Folder.query.filter(Folder.tracks.any(), Folder.path.contains(query)).slice(album_offset, album_offset + album_count) song_query = Track.query.filter(Track.title.contains(query)).slice(song_offset, song_offset + song_count) return request.formatter({ 'searchResult2': { @@ -71,10 +72,11 @@ def new_search(): 'song': [ t.as_subsonic_child(request.user) for t in song_query ] }}) + @app.route('/rest/search3.view', methods = [ 'GET', 'POST' ]) def search_id3(): query, artist_count, artist_offset, album_count, album_offset, song_count, song_offset = map( - request.args.get, [ 'query', 'artistCount', 'artistOffset', 'albumCount', 'albumOffset', 'songCount', 'songOffset' ]) + request.args.get, [ 'query', 'artistCount', 'artistOffset', 'albumCount', 'albumOffset', 'songCount', 'songOffset' ]) try: artist_count = int(artist_count) if artist_count else 20 @@ -97,5 +99,5 @@ def search_id3(): 'artist': [ a.as_subsonic_artist(request.user) for a in artist_query ], 'album': [ a.as_subsonic_album(request.user) for a in album_query ], 'song': [ t.as_subsonic_child(request.user) for t in song_query ] - }}) + }}) diff --git a/supysonic.ini b/supysonic.ini index 06882ea..d1fe0bf 100755 --- a/supysonic.ini +++ b/supysonic.ini @@ -9,6 +9,6 @@ touch-reload = /tmp/supysonic.reload enable-threads = true processes = 8 - harakiri = 60 + harakiri = 120 daemonize = uwsgi.log close-on-exec = true