From: Radek Czajka Date: Tue, 16 Jun 2026 12:45:10 +0000 (+0200) Subject: Add audio bulk-download X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/89881ffd8c2da92f115f23b002f48b7e626014d0 Add audio bulk-download --- diff --git a/src/catalogue/templates/catalogue/book_detail.html b/src/catalogue/templates/catalogue/book_detail.html index 7074a81aa..69f81864b 100644 --- a/src/catalogue/templates/catalogue/book_detail.html +++ b/src/catalogue/templates/catalogue/book_detail.html @@ -263,7 +263,7 @@ - {% if book.has_mp3_file %} + {% if book.has_audio %}
@@ -280,17 +280,15 @@ .mp3
- {% if book.has_ogg_file %} -
-
-

OggVorbis

-

{% trans "Otwarty format plików audio, oferujący wysokiej jakości nagranie." %}

-
-
- .ogg -
+
+
+

OggVorbis

+

{% trans "Otwarty format plików audio, oferujący wysokiej jakości nagranie." %}

- {% endif %} +
+ .ogg +
+
{% if book.has_daisy_file %}
diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 8bb86c282..8d32e64ee 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -534,12 +534,19 @@ def stream_zip(request, media_format=None, slug=None): zs = ZipStream() + audiobook_list = list(iterate_audiobooks(book, ())) + licenses = set() - for i, (file_path, lic, names) in enumerate(iterate_audiobooks(book, ())): + for i, (file_path, lic, names) in enumerate(audiobook_list): index = i + 1 part_name = '_'.join(names) + if part_name: + part_name = '_' + part_name ext = file_path.rsplit('.', 1)[-1] - zip_name = f'{book.slug}_{index:03d}_{part_name}'[:240] + '.' + ext + if len(audiobook_list) > 1: + zip_name = f'{book.slug}_{index:03d}{part_name}'[:240] + '.' + ext + else: + zip_name = book.slug[:240] + '.' + ext zs.add_path(file_path, zip_name) lic_name = constants.LICENSES.get(lic, {}).get('locative')