mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Implement recursive downloading of folders
Example use case: ``` Some Album/ ├── CD1 │ └── <songs> ├── CD2 │ └── <songs> └── cover.jpg ``` Previously, downloading the `Some Album` folder would result in no data being sent (not even `cover.jpg`) This commit changes folder-based downloads so that the entire folder tree (including any non-music) is added to the returned zip file. This allows any included album art, scans, notes, etc. to be distributed with the files. Album-based downloads are unaffected.
This commit is contained in:
parent
387a5e3de3
commit
359e391fcc
@ -249,14 +249,19 @@ def download_media():
|
|||||||
except ObjectNotFound:
|
except ObjectNotFound:
|
||||||
raise NotFound("Folder")
|
raise NotFound("Folder")
|
||||||
|
|
||||||
# Stream a zip of the tracks + cover art to the client
|
# Stream a zip of multiple files to the client
|
||||||
z = ZipStream(sized=True)
|
z = ZipStream(sized=True)
|
||||||
for track in rv.tracks:
|
if isinstance(rv, Folder):
|
||||||
z.add_path(track.path)
|
# Add the entire folder tree to the zip
|
||||||
|
z.add_path(rv.path, recurse=True)
|
||||||
|
else:
|
||||||
|
# Add tracks + cover art to the zip
|
||||||
|
for track in rv.tracks:
|
||||||
|
z.add_path(track.path)
|
||||||
|
|
||||||
cover_path = _cover_from_collection(rv, extract=False)
|
cover_path = _cover_from_collection(rv, extract=False)
|
||||||
if cover_path:
|
if cover_path:
|
||||||
z.add_path(cover_path)
|
z.add_path(cover_path)
|
||||||
|
|
||||||
if not z:
|
if not z:
|
||||||
raise GenericError("Nothing to download")
|
raise GenericError("Nothing to download")
|
||||||
|
Loading…
Reference in New Issue
Block a user