diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/main.py | 1 | ||||
-rw-r--r-- | app/ytdl.py | 10 |
2 files changed, 7 insertions, 4 deletions
diff --git a/app/main.py b/app/main.py index 36c0e94..9fbdf19 100644 --- a/app/main.py +++ b/app/main.py @@ -19,6 +19,7 @@ class Config: 'STATE_DIR': '.',
'URL_PREFIX': '',
'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
+ 'OUTPUT_TEMPLATE_CHAPTER': '%(title)s - %(section_number)s %(section_title)s.%(ext)s',
'YTDL_OPTIONS': '{}',
}
diff --git a/app/ytdl.py b/app/ytdl.py index 0128329..21b82da 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -38,9 +38,10 @@ class DownloadInfo: class Download:
manager = None
- def __init__(self, download_dir, output_template, quality, format, ytdl_opts, info):
+ def __init__(self, download_dir, output_template, output_template_chapter, quality, format, ytdl_opts, info):
self.download_dir = download_dir
self.output_template = output_template
+ self.output_template_chapter = output_template_chapter
self.format = get_format(format, quality)
self.ytdl_opts = get_opts(format, quality, ytdl_opts)
self.info = info
@@ -73,7 +74,7 @@ class Download: 'no_color': True,
#'skip_download': True,
'paths': {"home": self.download_dir},
- 'outtmpl': { "default": self.output_template},
+ 'outtmpl': { "default": self.output_template, "chapter": self.output_template_chapter },
'format': self.format,
'cachedir': False,
'socket_timeout': 30,
@@ -147,7 +148,7 @@ class PersistentQueue: def load(self):
for k, v in self.saved_items():
- self.dict[k] = Download(None, None, None, None, {}, v)
+ self.dict[k] = Download(None, None, None, None, None, {}, v)
def exists(self, key):
return key in self.dict
@@ -228,10 +229,11 @@ class DownloadQueue: dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'], quality, format)
dldirectory = self.config.DOWNLOAD_DIR if (quality != 'audio' and format != 'mp3') else self.config.AUDIO_DOWNLOAD_DIR
output = self.config.OUTPUT_TEMPLATE
+ output_chapter = self.config.OUTPUT_TEMPLATE_CHAPTER
for property, value in entry.items():
if property.startswith("playlist"):
output = output.replace(f"%({property})s", str(value))
- self.queue.put(Download(dldirectory, output, quality, format, self.config.YTDL_OPTIONS, dl))
+ self.queue.put(Download(dldirectory, output, output_chapter, quality, format, self.config.YTDL_OPTIONS, dl))
self.event.set()
await self.notifier.added(dl)
return {'status': 'ok'}
|