diff options
author | Alex <alexta69@gmail.com> | 2021-05-18 21:08:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-18 21:08:18 +0300 |
commit | 3c7e66760d1b340d35fabf2bc37dea2cf75666e6 (patch) | |
tree | 53de4205e856a0a1f18cd10a4d2a79b63fd3b3f0 /app | |
parent | upgraded youtube-dl (diff) | |
parent | add documentation for the OUTPUT_TEMPLATE env variable (diff) | |
download | metube-3c7e66760d1b340d35fabf2bc37dea2cf75666e6.tar.gz metube-3c7e66760d1b340d35fabf2bc37dea2cf75666e6.tar.bz2 metube-3c7e66760d1b340d35fabf2bc37dea2cf75666e6.zip |
Merge pull request #31 from xiongzi/master
environment variable to customize output file names
Diffstat (limited to 'app')
-rw-r--r-- | app/main.py | 1 | ||||
-rw-r--r-- | app/ytdl.py | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/app/main.py b/app/main.py index 88d2525..b8b512d 100644 --- a/app/main.py +++ b/app/main.py @@ -17,6 +17,7 @@ class Config: _DEFAULTS = {
'DOWNLOAD_DIR': '.',
'URL_PREFIX': '',
+ 'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
}
def __init__(self):
diff --git a/app/ytdl.py b/app/ytdl.py index dfdc4fd..c6b09ff 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -32,8 +32,9 @@ class DownloadInfo: class Download:
manager = None
- def __init__(self, download_dir, quality, info):
+ def __init__(self, download_dir, output_template, quality, info):
self.download_dir = download_dir
+ self.output_template = output_template
if quality == 'best':
self.format = None
elif quality in ('1440p', '1080p', '720p', '480p'):
@@ -59,7 +60,7 @@ class Download: 'quiet': True,
'no_color': True,
#'skip_download': True,
- 'outtmpl': os.path.join(self.download_dir, '%(title)s.%(ext)s'),
+ 'outtmpl': os.path.join(self.download_dir, self.output_template),
'format': self.format,
'cachedir': False,
'socket_timeout': 30,
@@ -147,7 +148,7 @@ class DownloadQueue: elif etype == 'video' or etype.startswith('url') and 'id' in entry:
if entry['id'] not in self.queue:
dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'])
- self.queue[entry['id']] = Download(self.config.DOWNLOAD_DIR, quality, dl)
+ self.queue[entry['id']] = Download(self.config.DOWNLOAD_DIR, self.config.OUTPUT_TEMPLATE, quality, dl)
self.event.set()
await self.notifier.added(dl)
return {'status': 'ok'}
|