fix
[audio.git] / src / youtube / tasks.py
index 0c3298a..63051c9 100644 (file)
@@ -1,3 +1,4 @@
+import os
 from archive.tasks import AudioFormatTask
 from .models import YouTube
 
 from archive.tasks import AudioFormatTask
 from .models import YouTube
 
@@ -6,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):
+        YouTube.objects.first().prepare_file(in_paths, out_path)
 
     def set_tags(self, audiobook, filename):
         pass
 
     def set_tags(self, audiobook, filename):
         pass
@@ -15,7 +16,19 @@ class YouTubeTask(AudioFormatTask):
     @classmethod
     def save(cls, audiobook, file_name):
         """We do not save the video files."""
     @classmethod
     def save(cls, audiobook, file_name):
         """We do not save the video files."""
-        pass
+        os.unlink(file_name)
 
     def put(self, user, audiobook, filename):
         YouTube.objects.first().publish(audiobook, filename)
 
     def put(self, user, audiobook, filename):
         YouTube.objects.first().publish(audiobook, filename)
+
+    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")
+        ]