aboutsummaryrefslogtreecommitdiff
path: root/app/main.py
diff options
context:
space:
mode:
authorAlex Shnitman <alexta69@gmail.com>2021-08-28 10:32:24 +0300
committerAlex Shnitman <alexta69@gmail.com>2021-08-28 10:32:24 +0300
commitb1f856474cda80714688bf214e5aa4ee07898b47 (patch)
tree723e68c07717199e6270e6e7b720dcca67b753e1 /app/main.py
parentallow all video formats, and merge into mp4 (diff)
downloadmetube-b1f856474cda80714688bf214e5aa4ee07898b47.tar.gz
metube-b1f856474cda80714688bf214e5aa4ee07898b47.tar.bz2
metube-b1f856474cda80714688bf214e5aa4ee07898b47.zip
add support for youtube-dl options (closes #33, #34)
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/main.py b/app/main.py
index d94967b..000cb28 100644
--- a/app/main.py
+++ b/app/main.py
@@ -2,6 +2,7 @@
# pylint: disable=no-member,method-hidden
import os
+import sys
from aiohttp import web
import socketio
import logging
@@ -17,6 +18,7 @@ class Config:
'AUDIO_DOWNLOAD_DIR': '%%DOWNLOAD_DIR',
'URL_PREFIX': '',
'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
+ 'YTDL_OPTIONS': '{}',
}
def __init__(self):
@@ -27,6 +29,12 @@ class Config:
setattr(self, k, getattr(self, v[2:]))
if not self.URL_PREFIX.endswith('/'):
self.URL_PREFIX += '/'
+ try:
+ self.YTDL_OPTIONS = json.loads(self.YTDL_OPTIONS)
+ assert isinstance(self.YTDL_OPTIONS, dict)
+ except (json.decoder.JSONDecodeError, AssertionError):
+ log.error('YTDL_OPTIONS is invalid')
+ sys.exit(1)
config = Config()
bgstack15