1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Previous commit work applied to API responses

This commit is contained in:
Alban 2012-11-10 23:02:30 +01:00
parent 7e2e93bcfd
commit e022f09db8
3 changed files with 13 additions and 6 deletions

View File

@ -27,7 +27,7 @@ def rand_songs():
if genre: if genre:
query = query.filter(Track.genre == genre) query = query.filter(Track.genre == genre)
if fid: if fid:
query = query.filter(Track.folder_id == fid) query = query.filter(Track.root_folder_id == fid)
tracks = query.all() tracks = query.all()
if not tracks: if not tracks:

View File

@ -36,7 +36,7 @@ def list_indexes():
folder = Folder.query.get(mfid) folder = Folder.query.get(mfid)
if not folder or not folder.root: if not folder and not folder.root:
return request.error_formatter(70, 'Folder not found') return request.error_formatter(70, 'Folder not found')
last_modif = max(map(lambda f: f.last_scan, folder)) if type(folder) is list else folder.last_scan last_modif = max(map(lambda f: f.last_scan, folder)) if type(folder) is list else folder.last_scan
@ -45,10 +45,16 @@ def list_indexes():
if (not ifModifiedSince is None) and last_modif_ts < ifModifiedSince: if (not ifModifiedSince is None) and last_modif_ts < ifModifiedSince:
return request.formatter({ 'indexes': { 'lastModified': last_modif_ts } }) return request.formatter({ 'indexes': { 'lastModified': last_modif_ts } })
# The XSD lies, we don't return artists but a directory structure
if type(folder) is list: if type(folder) is list:
artists = Artist.query.all() artists = []
childs = []
for f in folder:
artists += f.children
childs += f.tracks
else: else:
artists = Artist.query.join(Album, Track).filter(Track.folder_id == mfid) artists = folder.children
childs = folder.tracks
indexes = {} indexes = {}
for artist in artists: for artist in artists:
@ -72,7 +78,8 @@ def list_indexes():
'id': str(a.id), 'id': str(a.id),
'name': a.name 'name': a.name
} for a in sorted(v, key = lambda a: a.name.lower()) ] } for a in sorted(v, key = lambda a: a.name.lower()) ]
} for k, v in sorted(indexes.iteritems()) ] } for k, v in sorted(indexes.iteritems()) ],
'child': [ c.as_subsonic_child() for c in sorted(childs, key = lambda t: t.album.artist.name + t.album.name + str(t.disc) + str(t.number) + t.title ) ]
} }
}) })

View File

@ -27,7 +27,7 @@ def user_info():
'coverArtRole': False, 'coverArtRole': False,
'commentRole': False, 'commentRole': False,
'podcastRole': False, 'podcastRole': False,
'streamRole': False, 'streamRole': True,
'jukeboxRole': False, 'jukeboxRole': False,
'shareRole': False 'shareRole': False
} }