Easier cutting.
[audio.git] / src / youtube / tasks.py
index 32e41b7..d7ca67e 100644 (file)
@@ -7,8 +7,8 @@ class YouTubeTask(AudioFormatTask):
     ext = 'mkv'
     prefix = 'youtube'
 
     ext = 'mkv'
     prefix = 'youtube'
 
-    def encode(self, in_path, out_path):
-        YouTube.objects.first().prepare_file(in_path, out_path)
+    def encode(self, in_paths, out_path):
+        self.audiobook.project.youtube.prepare_file(in_paths, out_path)
 
     def set_tags(self, audiobook, filename):
         pass
 
     def set_tags(self, audiobook, filename):
         pass
@@ -19,4 +19,20 @@ class YouTubeTask(AudioFormatTask):
         os.unlink(file_name)
 
     def put(self, user, audiobook, filename):
         os.unlink(file_name)
 
     def put(self, user, audiobook, filename):
-        YouTube.objects.first().publish(audiobook, filename)
+        audiobook.project.youtube.publish(audiobook, filename)
+
+    def get_source_file_paths(self, audiobook):
+        if not audiobook.youtube_volume:
+            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