diff --git a/api/albums_songs.py b/api/albums_songs.py index e2a361c..741343b 100755 --- a/api/albums_songs.py +++ b/api/albums_songs.py @@ -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: diff --git a/api/browse.py b/api/browse.py index 62bcaa4..15f016c 100755 --- a/api/browse.py +++ b/api/browse.py @@ -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 ) ] } }) diff --git a/api/user.py b/api/user.py index 2200d7a..087e157 100755 --- a/api/user.py +++ b/api/user.py @@ -27,7 +27,7 @@ def user_info(): 'coverArtRole': False, 'commentRole': False, 'podcastRole': False, - 'streamRole': False, + 'streamRole': True, 'jukeboxRole': False, 'shareRole': False }