mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-14 22:22:18 +00:00
fix searching problems
This commit is contained in:
parent
1f8289e1c6
commit
1aa2a2c62b
@ -199,7 +199,7 @@ def cover_art():
|
|||||||
app.logger.debug('No Art Found!')
|
app.logger.debug('No Art Found!')
|
||||||
res.has_cover_art = False
|
res.has_cover_art = False
|
||||||
session.commit()
|
session.commit()
|
||||||
return request.error_formatter(70, 'Cover art not found')
|
return request.error_formatter(70, 'Cover art not found'), 404
|
||||||
|
|
||||||
coverfile = coverfile[0]
|
coverfile = coverfile[0]
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ def cover_art():
|
|||||||
try:
|
try:
|
||||||
size = int(size)
|
size = int(size)
|
||||||
except:
|
except:
|
||||||
return request.error_formatter(0, 'Invalid size value')
|
return request.error_formatter(0, 'Invalid size value'), 404
|
||||||
else:
|
else:
|
||||||
app.logger.debug('Serving cover art: ' + res.path + coverfile)
|
app.logger.debug('Serving cover art: ' + res.path + coverfile)
|
||||||
return send_file(os.path.join(res.path, coverfile))
|
return send_file(os.path.join(res.path, coverfile))
|
||||||
|
@ -33,7 +33,7 @@ def old_search():
|
|||||||
'totalHits': folders.count() + tracks.count(),
|
'totalHits': folders.count() + tracks.count(),
|
||||||
'offset': offset,
|
'offset': offset,
|
||||||
'match': [ r.as_subsonic_child(request.user) for r in res ]
|
'match': [ r.as_subsonic_child(request.user) for r in res ]
|
||||||
}})
|
}})
|
||||||
else:
|
else:
|
||||||
return request.error_formatter(10, 'Missing search parameter')
|
return request.error_formatter(10, 'Missing search parameter')
|
||||||
|
|
||||||
@ -41,12 +41,13 @@ def old_search():
|
|||||||
'totalHits': query.count(),
|
'totalHits': query.count(),
|
||||||
'offset': offset,
|
'offset': offset,
|
||||||
'match': [ r.as_subsonic_child(request.user) for r in query.slice(offset, offset + count) ]
|
'match': [ r.as_subsonic_child(request.user) for r in query.slice(offset, offset + count) ]
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/rest/search2.view', methods = [ 'GET', 'POST' ])
|
@app.route('/rest/search2.view', methods = [ 'GET', 'POST' ])
|
||||||
def new_search():
|
def new_search():
|
||||||
query, artist_count, artist_offset, album_count, album_offset, song_count, song_offset = map(
|
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:
|
try:
|
||||||
artist_count = int(artist_count) if artist_count else 20
|
artist_count = int(artist_count) if artist_count else 20
|
||||||
@ -61,8 +62,8 @@ def new_search():
|
|||||||
if not query:
|
if not query:
|
||||||
return request.error_formatter(10, 'Missing query parameter')
|
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)
|
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.name.contains(query)).slice(album_offset, album_offset + album_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)
|
song_query = Track.query.filter(Track.title.contains(query)).slice(song_offset, song_offset + song_count)
|
||||||
|
|
||||||
return request.formatter({ 'searchResult2': {
|
return request.formatter({ 'searchResult2': {
|
||||||
@ -71,10 +72,11 @@ def new_search():
|
|||||||
'song': [ t.as_subsonic_child(request.user) for t in song_query ]
|
'song': [ t.as_subsonic_child(request.user) for t in song_query ]
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/rest/search3.view', methods = [ 'GET', 'POST' ])
|
@app.route('/rest/search3.view', methods = [ 'GET', 'POST' ])
|
||||||
def search_id3():
|
def search_id3():
|
||||||
query, artist_count, artist_offset, album_count, album_offset, song_count, song_offset = map(
|
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:
|
try:
|
||||||
artist_count = int(artist_count) if artist_count else 20
|
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 ],
|
'artist': [ a.as_subsonic_artist(request.user) for a in artist_query ],
|
||||||
'album': [ a.as_subsonic_album(request.user) for a in album_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 ]
|
'song': [ t.as_subsonic_child(request.user) for t in song_query ]
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@
|
|||||||
touch-reload = /tmp/supysonic.reload
|
touch-reload = /tmp/supysonic.reload
|
||||||
enable-threads = true
|
enable-threads = true
|
||||||
processes = 8
|
processes = 8
|
||||||
harakiri = 60
|
harakiri = 120
|
||||||
daemonize = uwsgi.log
|
daemonize = uwsgi.log
|
||||||
close-on-exec = true
|
close-on-exec = true
|
||||||
|
Loading…
Reference in New Issue
Block a user