Add project info flac.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Jun 2021 14:20:08 +0000 (16:20 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Jun 2021 14:20:29 +0000 (16:20 +0200)
src/archive/migrations/0023_project_info_flac.py [new file with mode: 0644]
src/archive/models.py
src/youtube/tasks.py

diff --git a/src/archive/migrations/0023_project_info_flac.py b/src/archive/migrations/0023_project_info_flac.py
new file mode 100644 (file)
index 0000000..99897c4
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 3.1.2 on 2021-06-25 16:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('archive', '0022_auto_20210316_1406'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='project',
+            name='info_flac',
+            field=models.FileField(blank=True, upload_to='archive/info_flac'),
+        ),
+    ]
index 1fc033b..fe6cc5c 100644 (file)
@@ -32,6 +32,7 @@ class Project(models.Model):
     description = models.TextField(blank=True, verbose_name="Opis")
     youtube = models.ForeignKey('youtube.YouTube', models.PROTECT)
     icon = models.FileField(upload_to='archive/project', blank=True, null=True)
     description = models.TextField(blank=True, verbose_name="Opis")
     youtube = models.ForeignKey('youtube.YouTube', models.PROTECT)
     icon = models.FileField(upload_to='archive/project', blank=True, null=True)
+    info_flac = models.FileField(upload_to='archive/info_flac', blank=True)
 
     class Meta:
         verbose_name = _("project")
 
     class Meta:
         verbose_name = _("project")
index cad3d11..d7ca67e 100644 (file)
@@ -23,12 +23,16 @@ class YouTubeTask(AudioFormatTask):
 
     def get_source_file_paths(self, audiobook):
         if not audiobook.youtube_volume:
 
     def get_source_file_paths(self, audiobook):
         if not audiobook.youtube_volume:
-            return [audiobook.source_file.path]
-        return [
-            a.source_file.path
-            for a in type(audiobook)
-            .objects.filter(
-                slug=audiobook.slug, youtube_volume=audiobook.youtube_volume
-            )
-            .order_by("index")
-        ]
+            paths = [audiobook.source_file.path]
+        else:
+            paths = [
+                a.source_file.path
+                for a in type(audiobook)
+                .objects.filter(
+                    slug=audiobook.slug, youtube_volume=audiobook.youtube_volume
+                )
+                .order_by("index")
+            ]
+        if audiobook.project.info_flac:
+            paths.append(audiobook.project.info_flac.path)
+        return paths