From 818b2154757ab810e9678cd0c76519500e1fb951 Mon Sep 17 00:00:00 2001 From: "unref (Nikolai G)" Date: Thu, 25 Aug 2022 18:01:06 +0300 Subject: add couple env variables --- README.md | 3 +++ app/main.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0e1528a..8bb811c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ Certain values can be set via environment variables, using the `-e` parameter on * __OUTPUT_TEMPLATE__: the template for the filenames of the downloaded videos, formatted according to [this spec](https://github.com/yt-dlp/yt-dlp/blob/master/README.md#output-template). Defaults to `%(title)s.%(ext)s`. * __OUTPUT_TEMPLATE_CHAPTER__: the template for the filenames of the downloaded videos, when split into chapters via postprocessors. Defaults to `%(title)s - %(section_number)s %(section_title)s.%(ext)s`. * __YTDL_OPTIONS__: Additional options to pass to youtube-dl, in JSON format. [See available options here](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L176). They roughly correspond to command-line options, though some do not have exact equivalents here, for example `--recode-video` has to be specified via `postprocessors`. Also note that dashes are replaced with underscores. +* __HOST__: ip address under which MeTube will run. Defaults to `0.0.0.0`. +* __PORT__: port under which MeTube will run. Defaults to `8081`. +* __BASEDIR__: path to where MeTube is located. Defaults to empty string. The following example value for `YTDL_OPTIONS` embeds English subtitles and chapter markers (for videos that have them), and also changes the permissions on the downloaded video: ``` diff --git a/app/main.py b/app/main.py index 9fbdf19..4602ef9 100644 --- a/app/main.py +++ b/app/main.py @@ -21,6 +21,9 @@ class Config: 'OUTPUT_TEMPLATE': '%(title)s.%(ext)s', 'OUTPUT_TEMPLATE_CHAPTER': '%(title)s - %(section_number)s %(section_title)s.%(ext)s', 'YTDL_OPTIONS': '{}', + 'HOST': '0.0.0.0', + 'PORT': '8081', + 'BASE_DIR': '' } def __init__(self): @@ -99,7 +102,7 @@ async def connect(sid, environ): @routes.get(config.URL_PREFIX) def index(request): - return web.FileResponse('ui/dist/metube/index.html') + return web.FileResponse(os.path.join(config.BASE_DIR, 'ui/dist/metube/index.html')) if config.URL_PREFIX != '/': @routes.get('/') @@ -110,9 +113,9 @@ if config.URL_PREFIX != '/': def index_redirect_dir(request): return web.HTTPFound(config.URL_PREFIX) -routes.static(config.URL_PREFIX + 'favicon/', 'favicon') +routes.static(config.URL_PREFIX + 'favicon/', os.path.join(config.BASE_DIR, 'favicon')) routes.static(config.URL_PREFIX + 'download/', config.DOWNLOAD_DIR) -routes.static(config.URL_PREFIX, 'ui/dist/metube') +routes.static(config.URL_PREFIX, os.path.join(config.BASE_DIR, 'ui/dist/metube')) app.add_routes(routes) @@ -134,4 +137,4 @@ app.on_response_prepare.append(on_prepare) if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) - web.run_app(app, port=8081) + web.run_app(app, host=config.HOST, port=config.PORT, reuse_port=True) -- cgit From cdfdf1742f28b6110401f0f177b26cece8d9916a Mon Sep 17 00:00:00 2001 From: Nikolay G Date: Fri, 17 Feb 2023 20:49:51 +0300 Subject: Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 8bb811c..0e1528a 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,6 @@ Certain values can be set via environment variables, using the `-e` parameter on * __OUTPUT_TEMPLATE__: the template for the filenames of the downloaded videos, formatted according to [this spec](https://github.com/yt-dlp/yt-dlp/blob/master/README.md#output-template). Defaults to `%(title)s.%(ext)s`. * __OUTPUT_TEMPLATE_CHAPTER__: the template for the filenames of the downloaded videos, when split into chapters via postprocessors. Defaults to `%(title)s - %(section_number)s %(section_title)s.%(ext)s`. * __YTDL_OPTIONS__: Additional options to pass to youtube-dl, in JSON format. [See available options here](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L176). They roughly correspond to command-line options, though some do not have exact equivalents here, for example `--recode-video` has to be specified via `postprocessors`. Also note that dashes are replaced with underscores. -* __HOST__: ip address under which MeTube will run. Defaults to `0.0.0.0`. -* __PORT__: port under which MeTube will run. Defaults to `8081`. -* __BASEDIR__: path to where MeTube is located. Defaults to empty string. The following example value for `YTDL_OPTIONS` embeds English subtitles and chapter markers (for videos that have them), and also changes the permissions on the downloaded video: ``` -- cgit