Thumbnail fixes.
[audio.git] / src / youtube / tasks.py
1 import os
2 from archive.tasks import AudioFormatTask
3 from .models import YouTube
4
5
6 class YouTubeTask(AudioFormatTask):
7     ext = 'mkv'
8     prefix = 'youtube'
9
10     def encode(self, in_paths, out_path):
11         YouTube.objects.first().prepare_file(in_paths, out_path)
12
13     def set_tags(self, audiobook, filename):
14         pass
15
16     @classmethod
17     def save(cls, audiobook, file_name):
18         """We do not save the video files."""
19         os.unlink(file_name)
20
21     def put(self, user, audiobook, filename):
22         YouTube.objects.first().publish(audiobook, filename)
23
24     def get_source_file_paths(self, audiobook):
25         if not audiobook.youtube_volume:
26             return [audiobook.source_file.path]
27         return [
28             a.source_file.path
29             for a in type(audiobook)
30             .objects.filter(
31                 slug=audiobook.slug, youtube_volume=audiobook.youtube_volume
32             )
33             .order_by("index")
34         ]