Compare commits

...

4 Commits

Author SHA1 Message Date
ge c42fdb2127 upd 2023-02-19 22:03:40 +03:00
ge 743f272072 add docker 2023-02-19 22:03:19 +03:00
ge 44158c15a5 add version, handle channel 2023-02-19 22:02:35 +03:00
ge b252c768fe add license 2023-02-19 21:54:05 +03:00
7 changed files with 148 additions and 2 deletions

4
.gitignore vendored
View File

@ -4,3 +4,7 @@ __pycache__/
.env
node_modules/
examples/
data/
downloads/
logs/
params/

24
COPYING Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM alpine:latest
RUN apk update && apk add --no-cache python3 py3-pip
RUN mkdir -p /opt/ydl_web_ui
ADD requirements.txt web_ui/ /opt/ydl_web_ui
WORKDIR /opt/ydl_web_ui
RUN pip install --disable-pip-version-check --requirement requirements.txt
RUN pip install --disable-pip-version-check gunicorn
EXPOSE 3000
USER nobody
ENV YDL_API_HOST=
CMD gunicorn router:app --bind :3000

View File

@ -10,3 +10,7 @@ run:
lint:
pipenv run black $(SRCDIR)
pipenv run pylint $(SRCDIR)
image:
ver=$$(awk -F'= ' '/__version__/{gsub("\"", ""); print $$2}' web_ui/router.py) && \
sudo docker build . -t ydl-web-ui:$$ver -t ydl-web-ui:latest

View File

@ -11,10 +11,11 @@ This UI is written for my personal use and may not have the features you would l
# Roadmap
- [ ] Add Dockerfile and docker-compose.yml
- [x] Add Dockerfile and docker-compose.yml
- [ ] Handle non-youtube links
- [ ] Twitter
- [ ] Nicovideo
- [ ] vk.com
- [ ] Handle unsupported URLs
- [ ] YouTube playlists download
- [ ] Advanced settings
@ -22,7 +23,50 @@ This UI is written for my personal use and may not have the features you would l
# Installation
I recomment setup with Docker via [docker-compose.yml](docker-compose.yml).
## Docker Compose (easiest)
Copy [docker-compose.yml](docker-compose.yml) and edit if you want.
Then up containers:
```
docker compose up -d
```
ydl-web-ui will listen port 4011/tcp.
## Docker
1. [Setup ydl_api_ng](https://github.com/Totonyus/ydl_api_ng#installation).
2. Install Web UI.
You must specify your ydl_api_ng instance host as `YDL_API_HOST` environment variable.
```
docker run -d \
--name ydl_web_ui \
-p 4011:3000 \
-e YDL_API_HOST=http://1.2.3.4:5011 \
nxhs/ydl-web-ui:latest
```
## Without Docker
Use python 3.6 or newer.
Replace `YDL_API_HOST` value to your actual ydl_api_ng instance URL.
```
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
pip install gunicorn
export YDL_API_HOST=http://1.2.3.4:5011
gunicorn --chdir=./web_ui router:app -b :3000
```
See also gunicorn deployment options: https://docs.gunicorn.org/en/latest/deploy.html
# Development

50
docker-compose.yml Normal file
View File

@ -0,0 +1,50 @@
version: "3.1"
services:
web_ui:
container_name: ydl_web_ui
image: nxhs/ydl-web-ui
restart: unless-stopped
depends_on:
- api
ports:
- 4011:3000
environment:
- YDL_API_HOST=http://api:80
networks:
- ydl_api_ng
api:
container_name: ydl_api_ng
image: totonyus/ydl_api_ng
restart: unless-stopped
depends_on:
- redis
ports:
- 5011:80
volumes:
- ./params:/app/params
- ./logs:/app/logs
- ./downloads:/app/downloads
- ./data:/app/data
- /etc/localtime:/etc/localtime:ro
environment:
- UID=1000
- GID=1000
- NB_WORKERS=5
- LOG_LEVEL=error
# Redis will be disable is this value is not false, remember to also change the setting in params.ini file
- DISABLE_REDIS=false
networks:
- ydl_api_ng
redis:
container_name: ydl_api_ng_redis
image: redis
restart: unless-stopped
networks:
- ydl_api_ng
volumes:
- /etc/localtime:/etc/localtime:ro
networks:
ydl_api_ng:

View File

@ -1,5 +1,7 @@
"""ydl_api_ng Web UI."""
__version__ = "0.1.0"
import os
import datetime
@ -29,6 +31,13 @@ def info():
video_info["duration_in_hms"] = str(
datetime.timedelta(seconds=int(video_info["duration"]))
)
# Replace channel with uploader for non-YouTube sources
try:
video_info["channel_url"]
except KeyError:
video_info["channel_url"] = video_info["uploader_url"]
video_info["channel"] = video_info["uploader"]
return template("templates/video.tpl", video=video_info)