diff options
author | Alex <alexta69@gmail.com> | 2021-07-25 21:47:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 21:47:43 +0300 |
commit | 3b97f4791528c4bf84b8e1acbb02ee26578097f2 (patch) | |
tree | 86904ea2cedc183386c6a24be689c45912fb39aa | |
parent | firefox bookmarklet (diff) | |
parent | set AUDIO_DOWNLOAD_DIR to the value if DOWNLOAD_DIR if it wasn't overriden in... (diff) | |
download | metube-3b97f4791528c4bf84b8e1acbb02ee26578097f2.tar.gz metube-3b97f4791528c4bf84b8e1acbb02ee26578097f2.tar.bz2 metube-3b97f4791528c4bf84b8e1acbb02ee26578097f2.zip |
Merge pull request #36 from omeryagmurlu/master
Add AUDIO_DOWNLOAD_DIR option
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | app/main.py | 4 | ||||
-rw-r--r-- | app/ytdl.py | 3 |
4 files changed, 8 insertions, 2 deletions
@@ -2,7 +2,7 @@ FROM node as builder WORKDIR /metube
COPY ui ./
-RUN npm install && \
+RUN npm ci && \
node_modules/.bin/ng build --prod
@@ -34,6 +34,7 @@ services: Certain values can be set via environment variables, using the `-e` parameter on the docker command line, or the `environment:` section in docker-compose.
* __DOWNLOAD_DIR__: path to where the downloads will be saved. Defaults to `/downloads` in the docker image, and `.` otherwise.
+* __AUDIO_DOWNLOAD_DIR__: path to where audio-only downloads will be saved, if you wish to separate them from the video downloads. Defaults to the value of `DOWNLOAD_DIR`.
* __URL_PREFIX__: base path for the web server (for use when hosting behind a reverse proxy). Defaults to `/`.
* __OUTPUT_TEMPLATE__: the template for the filenames of the downloaded videos, formatted according to [this spec](https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template). Defaults to `%(title)s.%(ext)s`.
diff --git a/app/main.py b/app/main.py index b8b512d..dad19e3 100644 --- a/app/main.py +++ b/app/main.py @@ -16,6 +16,7 @@ log = logging.getLogger('main') class Config:
_DEFAULTS = {
'DOWNLOAD_DIR': '.',
+ 'AUDIO_DOWNLOAD_DIR': '%%DOWNLOAD_DIR',
'URL_PREFIX': '',
'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
}
@@ -23,6 +24,9 @@ class Config: def __init__(self):
for k, v in self._DEFAULTS.items():
setattr(self, k, os.environ[k] if k in os.environ else v)
+ for k, v in self.__dict__.items():
+ if v.startswith('%%'):
+ setattr(self, k, getattr(self, v[2:]))
if not self.URL_PREFIX.endswith('/'):
self.URL_PREFIX += '/'
diff --git a/app/ytdl.py b/app/ytdl.py index c6b09ff..d29f108 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -148,7 +148,8 @@ 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, self.config.OUTPUT_TEMPLATE, quality, dl)
+ dldirectory = self.config.DOWNLOAD_DIR if quality != 'audio' else self.config.AUDIO_DOWNLOAD_DIR
+ self.queue[entry['id']] = Download(dldirectory, self.config.OUTPUT_TEMPLATE, quality, dl)
self.event.set()
await self.notifier.added(dl)
return {'status': 'ok'}
|