From e8eaf6db942b01623cd5b3a7298b5f4daac70850 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Tue, 11 Jul 2017 08:40:54 +0200 Subject: [PATCH] Now display CLI instructions to download a set of tracks --- api/funkwhale_api/music/models.py | 6 +++ api/funkwhale_api/music/serializers.py | 2 +- api/funkwhale_api/music/views.py | 5 +- front/src/components/audio/track/Table.vue | 46 ++++++++++++++++++- front/src/components/library/Album.vue | 2 +- front/src/components/semantic/Modal.vue | 53 ++++++++++++++++++++++ 6 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 front/src/components/semantic/Modal.vue diff --git a/api/funkwhale_api/music/models.py b/api/funkwhale_api/music/models.py index d7a08b7a4..596f890b7 100644 --- a/api/funkwhale_api/music/models.py +++ b/api/funkwhale_api/music/models.py @@ -362,6 +362,12 @@ class TrackFile(models.Model): 'api:v1:trackfiles-serve', kwargs={'pk': self.pk}) return self.audio_file.url + @property + def filename(self): + return '{}{}'.format( + self.track.full_name, + os.path.splitext(self.audio_file.name)[-1]) + class ImportBatch(models.Model): creation_date = models.DateTimeField(default=timezone.now) diff --git a/api/funkwhale_api/music/serializers.py b/api/funkwhale_api/music/serializers.py index 6b839b9cf..40fbb65ea 100644 --- a/api/funkwhale_api/music/serializers.py +++ b/api/funkwhale_api/music/serializers.py @@ -34,7 +34,7 @@ class ImportBatchSerializer(serializers.ModelSerializer): class TrackFileSerializer(serializers.ModelSerializer): class Meta: model = models.TrackFile - fields = ('id', 'path', 'duration', 'source') + fields = ('id', 'path', 'duration', 'source', 'filename') class SimpleAlbumSerializer(serializers.ModelSerializer): diff --git a/api/funkwhale_api/music/views.py b/api/funkwhale_api/music/views.py index 4a4032c57..983192552 100644 --- a/api/funkwhale_api/music/views.py +++ b/api/funkwhale_api/music/views.py @@ -139,9 +139,8 @@ class TrackFileViewSet(viewsets.ReadOnlyModelViewSet): return Response(status=404) response = Response() - filename = "filename*=UTF-8''{}{}".format( - urllib.parse.quote(f.track.full_name), - os.path.splitext(f.audio_file.name)[-1]) + filename = "filename*=UTF-8''{}".format( + urllib.parse.quote(f.filename)) response["Content-Disposition"] = "attachment; {}".format(filename) response['X-Accel-Redirect'] = "{}{}".format( settings.PROTECT_FILES_PATH, diff --git a/front/src/components/audio/track/Table.vue b/front/src/components/audio/track/Table.vue index 8dca90902..e9beaa05a 100644 --- a/front/src/components/audio/track/Table.vue +++ b/front/src/components/audio/track/Table.vue @@ -40,26 +40,70 @@ + + + + + +
+ Download tracks +
+
+
+

There is currently no way to download directly multiple tracks from funkwhale as a ZIP archive. + However, you can use a command line tools such as cURL to easily download a list of tracks. +

+

Simply copy paste the snippet below into a terminal to launch the download.

+
+ Keep your PRIVATE_TOKEN secret as it gives access to your account. +
+
+export PRIVATE_TOKEN="{{ auth.getAuthToken ()}}"
+
+
+
+
+
+
+ Cancel +
+
+
+ + + + + + + + + + +