1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Implemented starring in getAlbumList2?.view

This commit is contained in:
spl0k 2013-06-12 22:09:36 +02:00
parent 7398f3511a
commit 349dbe6d68

View File

@ -44,13 +44,16 @@ def rand_songs():
@app.route('/rest/getAlbumList.view', methods = [ 'GET', 'POST' ]) @app.route('/rest/getAlbumList.view', methods = [ 'GET', 'POST' ])
def album_list(): def album_list():
ltype, size, offset = map(request.args.get, [ 'type', 'size', 'offset' ]) username, ltype, size, offset = map(request.args.get, [ 'u', 'type', 'size', 'offset' ])
try: try:
size = int(size) if size else 10 size = int(size) if size else 10
offset = int(offset) if offset else 0 offset = int(offset) if offset else 0
except: except:
return request.error_formatter(0, 'Invalid parameter format') return request.error_formatter(0, 'Invalid parameter format')
if not username:
username = request.authorization.username
query = Folder.query.filter(Folder.tracks.any()) query = Folder.query.filter(Folder.tracks.any())
if ltype == 'random': if ltype == 'random':
albums = query.all() albums = query.all()
@ -68,7 +71,7 @@ def album_list():
elif ltype == 'recent': elif ltype == 'recent':
query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play))) query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play)))
elif ltype == 'starred': elif ltype == 'starred':
return request.error_formatter(0, 'Not implemented') query = query.join(StarredFolder).join(User).filter(User.name == username)
elif ltype == 'alphabeticalByName': elif ltype == 'alphabeticalByName':
query = query.order_by(Folder.name) query = query.order_by(Folder.name)
elif ltype == 'alphabeticalByArtist': elif ltype == 'alphabeticalByArtist':
@ -85,13 +88,16 @@ def album_list():
@app.route('/rest/getAlbumList2.view', methods = [ 'GET', 'POST' ]) @app.route('/rest/getAlbumList2.view', methods = [ 'GET', 'POST' ])
def album_list_id3(): def album_list_id3():
ltype, size, offset = map(request.args.get, [ 'type', 'size', 'offset' ]) username, ltype, size, offset = map(request.args.get, [ 'u', 'type', 'size', 'offset' ])
try: try:
size = int(size) if size else 10 size = int(size) if size else 10
offset = int(offset) if offset else 0 offset = int(offset) if offset else 0
except: except:
return request.error_formatter(0, 'Invalid parameter format') return request.error_formatter(0, 'Invalid parameter format')
if not username:
username = request.authorization.username
query = Album.query query = Album.query
if ltype == 'random': if ltype == 'random':
albums = query.all() albums = query.all()
@ -107,7 +113,7 @@ def album_list_id3():
elif ltype == 'recent': elif ltype == 'recent':
query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.max(Track.last_play))) query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.max(Track.last_play)))
elif ltype == 'starred': elif ltype == 'starred':
return request.error_formatter(0, 'Not implemented') query = query.join(StarredAlbum).join(User).filter(User.name == username)
elif ltype == 'alphabeticalByName': elif ltype == 'alphabeticalByName':
query = query.order_by(Album.name) query = query.order_by(Album.name)
elif ltype == 'alphabeticalByArtist': elif ltype == 'alphabeticalByArtist':