1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +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:
query = query.filter(Track.genre == genre)
if fid:
query = query.filter(Track.folder_id == fid)
query = query.filter(Track.root_folder_id == fid)
tracks = query.all()
if not tracks:

View File

@ -36,7 +36,7 @@ def list_indexes():
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')
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:
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:
artists = Artist.query.all()
artists = []
childs = []
for f in folder:
artists += f.children
childs += f.tracks
else:
artists = Artist.query.join(Album, Track).filter(Track.folder_id == mfid)
artists = folder.children
childs = folder.tracks
indexes = {}
for artist in artists:
@ -72,7 +78,8 @@ def list_indexes():
'id': str(a.id),
'name': a.name
} 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,
'commentRole': False,
'podcastRole': False,
'streamRole': False,
'streamRole': True,
'jukeboxRole': False,
'shareRole': False
}