X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/651c3fcf0e96681e5dfeb5afbbc4900a9342beb3..e7e2c234192c3e71cd69376eac9208a996eea935:/src/youtube/tasks.py diff --git a/src/youtube/tasks.py b/src/youtube/tasks.py index 0c3298a..7cf5eac 100644 --- a/src/youtube/tasks.py +++ b/src/youtube/tasks.py @@ -1,3 +1,4 @@ +import os from archive.tasks import AudioFormatTask from .models import YouTube @@ -6,16 +7,32 @@ class YouTubeTask(AudioFormatTask): 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): + def set_tags(self, tags, filename): pass @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) + 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