Fix auto build
This commit is contained in:
parent
16608dc72c
commit
a8b403aadf
8 changed files with 100 additions and 88 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -21,7 +21,7 @@
|
|||
.history/*
|
||||
|
||||
# Keep Var dir
|
||||
./var/*
|
||||
var/*
|
||||
!./var/config/.gitkeep
|
||||
!./var/downloads/.gitkeep
|
||||
!./var/tmp/.gitkeep
|
||||
|
|
|
|||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
|
@ -29,7 +29,7 @@
|
|||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"env": {
|
||||
"YTP_STATE_PATH": "${workspaceFolder}/var/config",
|
||||
"YTP_CONFIG_PATH": "${workspaceFolder}/var/config",
|
||||
"YTP_DOWNLOAD_PATH": "${workspaceFolder}/var/downloads",
|
||||
"YTP_TEMP_PATH": "${workspaceFolder}/var/tmp",
|
||||
"YTP_YTDL_OPTIONS_FILE": "${workspaceFolder}/var/config/ytdlp.json",
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ ARG TZ=UTC
|
|||
ARG USER_ID=1000
|
||||
ENV IN_CONTAINER=1
|
||||
ENV UMASK=022
|
||||
ENV YTP_STATE_DIR=/config
|
||||
ENV YTP_TEMP_DIR=/tmp
|
||||
ENV YTP_DOWNLOAD_DIR=/downloads
|
||||
ENV YTP_CONFIG_PATH=/config
|
||||
ENV YTP_TEMP_PATH=/tmp
|
||||
ENV YTP_DOWNLOAD_PATH=/downloads
|
||||
|
||||
RUN mkdir /config /downloads && ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone && \
|
||||
apk add --update --no-cache bash ffmpeg aria2 coreutils curl shadow sqlite tzdata && \
|
||||
|
|
|
|||
79
README.md
79
README.md
|
|
@ -1,15 +1,15 @@
|
|||
# ACTube
|
||||
# YTPTube
|
||||
|
||||

|
||||
|
||||
Web GUI for [yt-dlp](https://github.com/yt-dlp/yt-dlp) with playlist & channel support. Allows you to download videos from YouTube and [dozens of other sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md).
|
||||
|
||||
ACTube is a fork of [meTube](https://github.com/alexta69/metube) project by alexta69.
|
||||
YTPTube is a fork of [meTube](https://github.com/alexta69/metube) project by alexta69.
|
||||
|
||||
## Run using Docker
|
||||
|
||||
```bash
|
||||
docker run -d --name ytptube -p 8081:8081 -v ./config:/config:rw -v /path/to/downloads:/downloads:rw ghcr.io/ArabCoders/ytptube
|
||||
docker run -d --name ytptube -p 8081:8081 -v ./config:/config:rw -v ./downloads:/downloads:rw ghcr.io/arabcoders/ytptube
|
||||
```
|
||||
|
||||
## Run using docker-compose
|
||||
|
|
@ -18,43 +18,35 @@ docker run -d --name ytptube -p 8081:8081 -v ./config:/config:rw -v /path/to/dow
|
|||
version: "3"
|
||||
services:
|
||||
ytptube:
|
||||
image: ghcr.io/ArabCoders/ytptube
|
||||
user: "1000:1000"
|
||||
image: ghcr.io/arabcoders/ytptube
|
||||
container_name: ytptube
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8081:8081"
|
||||
volumes:
|
||||
- ./config:/config
|
||||
- /path/to/downloads:/downloads
|
||||
- ./downloads:/downloads
|
||||
```
|
||||
|
||||
## Configuration via environment variables
|
||||
|
||||
Certain values can be set via environment variables, using the `-e` parameter on the docker command line, or the `environment:` section in docker-compose.
|
||||
|
||||
* __UID__: user under which ytptube will run. Defaults to `1000`.
|
||||
* __GID__: group under which ytptube will run. Defaults to `1000`.
|
||||
* __UMASK__: umask value used by ytptube. Defaults to `022`.
|
||||
* __DEFAULT_THEME__: default theme to use for the UI, can be set to `light`, `dark` or `auto`. Defaults to `auto`.
|
||||
* __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`.
|
||||
* __DOWNLOAD_DIRS_INDEXABLE__: if `true`, the download dirs (__DOWNLOAD_DIR__ and __AUDIO_DOWNLOAD_DIR__) are indexable on the web server. Defaults to `false`.
|
||||
* __CUSTOM_DIRS__: whether to enable downloading videos into custom directories within the __DOWNLOAD_DIR__ (or __AUDIO_DOWNLOAD_DIR__). When enabled, a drop-down appears next to the Add button to specify the download directory. Defaults to `true`.
|
||||
* __CREATE_CUSTOM_DIRS__: whether to support automatically creating directories within the __DOWNLOAD_DIR__ (or __AUDIO_DOWNLOAD_DIR__) if they do not exist. When enabled, the download directory selector becomes supports free-text input, and the specified directory will be created recursively. Defaults to `true`.
|
||||
* __STATE_DIR__: path to where the queue persistence files will be saved. Defaults to `/config` in the docker image, and `.` otherwise.
|
||||
* __TEMP_DIR__: path where intermediary download files will be saved. Defaults to `/downloads` in the docker image, and `.` otherwise. Set this to an SSD or RAM filesystem (e.g., `tmpfs`) for better performance __Note__: Using a RAM filesystem may prevent downloads from being resumed.
|
||||
* __DELETE_FILE_ON_TRASHCAN__: if `true`, downloaded files are deleted on the server, when they are trashed from the "Completed" section of the UI. Defaults to `false`.
|
||||
* __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/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#L183). 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.
|
||||
* __YTDL_OPTIONS_FILE__: A path to a JSON file that will be loaded and used for populating `YTDL_OPTIONS` above. Please note that if both `YTDL_OPTIONS_FILE` and `YTDL_OPTIONS` are specified, the options in `YTDL_OPTIONS` take precedence.
|
||||
* __UMASK__: umask value used by YTPTube. Defaults to `022`.
|
||||
* __YTP_CONFIG_PATH__: path to where the queue persistence files will be saved. Defaults to `/config` in the docker image, and `./var/config` otherwise.
|
||||
* __YTP_DOWNLOAD_PATH__: path to where the downloads will be saved. Defaults to `/downloads` in the docker image, and `./var/downloads` otherwise.
|
||||
* __YTP_TEMP_PATH__: path where intermediary download files will be saved. Defaults to `/downloads` in the docker image, and `./var/tmp` otherwise. Set this to an SSD or RAM filesystem (e.g., `tmpfs`) for better performance __Note__: Using a RAM filesystem may prevent downloads from being resumed.
|
||||
* __YTP_URL_PREFIX__: base path for the web server (for use when hosting behind a reverse proxy). Defaults to `/`.
|
||||
* __YTP_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`.
|
||||
* __YTP_YTDL_OPTIONS__: Additional options to pass to yt-dlp, in JSON format. [See available options here](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L183). 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.
|
||||
* __YTP_YTDL_OPTIONS_FILE__: A path to a JSON file that will be loaded and used for populating `YTDL_OPTIONS` above.
|
||||
|
||||
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 and sets the file modification timestamp to the date of when it was downloaded:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- 'YTDL_OPTIONS={"writesubtitles":true,"subtitleslangs":["en","-live_chat"],"updatetime":false,"postprocessors":[{"key":"Exec","exec_cmd":"chmod 0664","when":"after_move"},{"key":"FFmpegEmbedSubtitle","already_have_subtitle":false},{"key":"FFmpegMetadata","add_chapters":true}]}'
|
||||
- 'YTP_YTDL_OPTIONS={"writesubtitles":true,"subtitleslangs":["en","-live_chat"],"updatetime":false,"postprocessors":[{"key":"Exec","exec_cmd":"chmod 0664","when":"after_move"},{"key":"FFmpegEmbedSubtitle","already_have_subtitle":false},{"key":"FFmpegMetadata","add_chapters":true}]}'
|
||||
```
|
||||
|
||||
The following example value for `OUTPUT_TEMPLATE` sets:
|
||||
|
|
@ -68,31 +60,11 @@ The following example value for `OUTPUT_TEMPLATE` sets:
|
|||
- 'OUTPUT_TEMPLATE=%(playlist_title&Playlist |)S%(playlist_title|)S%(playlist_uploader& by |)S%(playlist_uploader|)S%(playlist_autonumber& - |)S%(playlist_autonumber|)S%(playlist_count& of |)S%(playlist_count|)S%(playlist_autonumber& - |)S%(uploader,creator|UNKNOWN_AUTHOR)S - %(title|UNKNOWN_TITLE)S - %(release_date>%Y-%m-%d,upload_date>%Y-%m-%d|UNKNOWN_DATE)S.%(ext)s'
|
||||
```
|
||||
|
||||
## Using browser cookies
|
||||
|
||||
In case you need to use your browser's cookies with ytptube, for example to download restricted or private videos:
|
||||
|
||||
* Add the following to your docker-compose.yml:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- /path/to/cookies:/cookies
|
||||
environment:
|
||||
- YTDL_OPTIONS={"cookiefile":"/cookies/cookies.txt"}
|
||||
```
|
||||
|
||||
* Install in your browser an extension to extract cookies:
|
||||
* [Firefox](https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/)
|
||||
* [Chrome](https://chrome.google.com/webstore/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
|
||||
* Extract the cookies you need with the extension and rename the file `cookies.txt`
|
||||
* Drop the file in the folder you configured in the docker-compose.yml above
|
||||
* Restart the container
|
||||
|
||||
## Running behind a reverse proxy
|
||||
|
||||
It's advisable to run ytptube behind a reverse proxy, if authentication and/or HTTPS support are required.
|
||||
It's advisable to run YTPTube behind a reverse proxy, if authentication and/or HTTPS support are required.
|
||||
|
||||
When running behind a reverse proxy which remaps the URL (i.e. serves ytptube under a subdirectory and not under root), don't forget to set the URL_PREFIX environment variable to the correct value.
|
||||
When running behind a reverse proxy which remaps the URL (i.e. serves YTPTube under a subdirectory and not under root), don't forget to set the `YTP_URL_PREFIX` environment variable to the correct value.
|
||||
|
||||
### NGINX
|
||||
|
||||
|
|
@ -123,17 +95,17 @@ example.com {
|
|||
|
||||
## Updating yt-dlp
|
||||
|
||||
The engine which powers the actual video downloads in ytptube is [yt-dlp](https://github.com/yt-dlp/yt-dlp). Since video sites regularly change their layouts, frequent updates of yt-dlp are required to keep up.
|
||||
The engine which powers the actual video downloads in YTPTube is [yt-dlp](https://github.com/yt-dlp/yt-dlp). Since video sites regularly change their layouts, frequent updates of yt-dlp are required to keep up.
|
||||
|
||||
There's an automatic nightly build of ytptube which looks for a new version of yt-dlp, and if one exists, the build pulls it and publishes an updated docker image. Therefore, in order to keep up with the changes, it's recommended that you update your ytptube container regularly with the latest image.
|
||||
There's an automatic nightly build of YTPTube which looks for a new version of yt-dlp, and if one exists, the build pulls it and publishes an updated docker image. Therefore, in order to keep up with the changes, it's recommended that you update your YTPTube container regularly with the latest image.
|
||||
|
||||
I recommend installing and setting up [watchtower](https://github.com/containrrr/watchtower) for this purpose.
|
||||
|
||||
## Troubleshooting and submitting issues
|
||||
|
||||
Before asking a question or submitting an issue for ytptube, please remember that ytptube is only a UI for [yt-dlp](https://github.com/yt-dlp/yt-dlp). Any issues you might be experiencing with authentication to video websites, postprocessing, permissions, other `YTDL_OPTIONS` configurations which seem not to work, or anything else that concerns the workings of the underlying yt-dlp library, need not be opened on the ytptube project. In order to debug and troubleshoot them, it's advised to try using the yt-dlp binary directly first, bypassing the UI, and once that is working, importing the options that worked for you into `YTDL_OPTIONS`.
|
||||
Before asking a question or submitting an issue for YTPTube, please remember that YTPTube is only a UI for [yt-dlp](https://github.com/yt-dlp/yt-dlp). Any issues you might be experiencing with authentication to video websites, postprocessing, permissions, other `YTDL_OPTIONS` configurations which seem not to work, or anything else that concerns the workings of the underlying yt-dlp library, need not be opened on the YTPTube project. In order to debug and troubleshoot them, it's advised to try using the yt-dlp binary directly first, bypassing the UI, and once that is working, importing the options that worked for you into `YTDL_OPTIONS`.
|
||||
|
||||
In order to test with the yt-dlp command directly, you can either download it and run it locally, or for a better simulation of its actual conditions, you can run it within the ytptube container itself. Assuming your ytptube container is called `ytptube`, run the following on your Docker host to get a shell inside the container:
|
||||
In order to test with the yt-dlp command directly, you can either download it and run it locally, or for a better simulation of its actual conditions, you can run it within the YTPTube container itself. Assuming your YTPTube container is called `YTPTube`, run the following on your Docker host to get a shell inside the container:
|
||||
|
||||
```bash
|
||||
docker exec -ti ytptube sh
|
||||
|
|
@ -147,15 +119,16 @@ Once there, you can use the yt-dlp command freely.
|
|||
Make sure you have node.js and Python 3.8 installed.
|
||||
|
||||
```bash
|
||||
cd ytptube/ui
|
||||
# install Angular and build the UI
|
||||
cd ytptube/frontend
|
||||
# install Vue and build the UI
|
||||
npm install
|
||||
node_modules/.bin/ng build
|
||||
npm run build
|
||||
# install python dependencies
|
||||
cd ..
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
pip3 install pipenv
|
||||
pipenv install
|
||||
# run
|
||||
python app/main.py
|
||||
```
|
||||
|
|
|
|||
41
app/main.py
41
app/main.py
|
|
@ -26,6 +26,47 @@ class Main:
|
|||
|
||||
def __init__(self):
|
||||
self.config = Config()
|
||||
|
||||
try:
|
||||
if not os.path.exists(self.config.download_path):
|
||||
logging.info(
|
||||
f'Creating download folder at {self.config.download_path}')
|
||||
os.makedirs(self.config.download_path, exist_ok=True)
|
||||
except OSError as e:
|
||||
logging.error(
|
||||
f'Could not create download folder at {self.config.download_path}')
|
||||
raise e
|
||||
try:
|
||||
if not os.path.exists(self.config.temp_path):
|
||||
logging.info(
|
||||
f'Creating temp folder at {self.config.temp_path}')
|
||||
os.makedirs(self.config.temp_path, exist_ok=True)
|
||||
except OSError as e:
|
||||
logging.error(
|
||||
f'Could not create temp folder at {self.config.temp_path}')
|
||||
raise e
|
||||
|
||||
try:
|
||||
if not os.path.exists(self.config.config_path):
|
||||
logging.info(
|
||||
f'Creating config folder at {self.config.config_path}')
|
||||
os.makedirs(self.config.config_path, exist_ok=True)
|
||||
except OSError as e:
|
||||
logging.error(
|
||||
f'Could not create config folder at {self.config.config_path}')
|
||||
raise e
|
||||
|
||||
try:
|
||||
if not os.path.exists(self.config.db_file):
|
||||
logging.info(
|
||||
f'Creating database file at {self.config.db_file}')
|
||||
with open(self.config.db_file, 'w') as _:
|
||||
pass
|
||||
except OSError as e:
|
||||
logging.error(
|
||||
f'Could not create database file at {self.config.db_file}')
|
||||
raise e
|
||||
|
||||
caribou.upgrade(self.config.db_file, './app/migrations')
|
||||
|
||||
self.serializer = ObjectSerializer()
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ log = logging.getLogger('config')
|
|||
|
||||
|
||||
class Config:
|
||||
state_path: str = '../../var/config'
|
||||
download_path: str = '../../var/downloads'
|
||||
temp_path: str = '../../var/tmp'
|
||||
config_path: str = '.'
|
||||
download_path: str = '.'
|
||||
temp_path: str = '{download_path}'
|
||||
|
||||
db_file: str = '{state_path}/ytptube.db'
|
||||
db_file: str = '{config_path}/ytptube.db'
|
||||
|
||||
url_host: str = ''
|
||||
url_prefix: str = ''
|
||||
|
|
@ -34,7 +34,7 @@ class Config:
|
|||
def __init__(self):
|
||||
baseDefualtPath: str = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
self.state_path = os.path.join(baseDefualtPath, 'var', 'config')
|
||||
self.config_path = os.path.join(baseDefualtPath, 'var', 'config')
|
||||
self.download_path = os.path.join(baseDefualtPath, 'var', 'downloads')
|
||||
self.temp_path = os.path.join(baseDefualtPath, 'var', 'tmp')
|
||||
|
||||
|
|
@ -77,34 +77,35 @@ class Config:
|
|||
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')
|
||||
except (json.decoder.JSONDecodeError, AssertionError) as e:
|
||||
log.error(f'JSON error in "YTP_YTDL_OPTIONS": {e}')
|
||||
sys.exit(1)
|
||||
|
||||
if self.ytdl_options_file:
|
||||
log.info(
|
||||
f'Loading yt-dlp custom options from "{self.ytdl_options_file}"')
|
||||
if not os.path.exists(self.ytdl_options_file):
|
||||
log.error(f'File "{self.ytdl_options_file}" not found')
|
||||
sys.exit(1)
|
||||
try:
|
||||
with open(self.ytdl_options_file) as json_data:
|
||||
opts = json.load(json_data)
|
||||
assert isinstance(opts, dict)
|
||||
except (json.decoder.JSONDecodeError, AssertionError):
|
||||
log.error('ytdl_options_file contents is invalid')
|
||||
sys.exit(1)
|
||||
|
||||
self.ytdl_options.update(opts)
|
||||
log.error(f'"YTP_YTDL_OPTIONS_FILE" ENV points to non-existent file: "{self.ytdl_options_file}"')
|
||||
else:
|
||||
try:
|
||||
with open(self.ytdl_options_file) as json_data:
|
||||
opts = json.load(json_data)
|
||||
assert isinstance(opts, dict)
|
||||
self.ytdl_options.update(opts)
|
||||
except (json.decoder.JSONDecodeError, AssertionError) as e:
|
||||
log.error(f'JSON error in "{self.ytdl_options_file}": {e}')
|
||||
sys.exit(1)
|
||||
|
||||
def getAttributes(self) -> dict:
|
||||
attrs: dict = {}
|
||||
vclass: str = self.__class__
|
||||
|
||||
for attribute in vclass.__dict__.keys():
|
||||
if not attribute.startswith('_'):
|
||||
value = getattr(vclass, attribute)
|
||||
if not callable(value):
|
||||
attrs[attribute] = value
|
||||
if attribute.startswith('_'):
|
||||
continue
|
||||
|
||||
value = getattr(vclass, attribute)
|
||||
if not callable(value):
|
||||
attrs[attribute] = value
|
||||
|
||||
return attrs
|
||||
|
|
|
|||
|
|
@ -4,15 +4,12 @@ set -e
|
|||
echo "Setting umask to ${UMASK}"
|
||||
umask ${UMASK}
|
||||
|
||||
echo "Creating download directory (${YTP_DOWNLOAD_DIR}), state directory (${YTP_STATE_DIR}), and temp dir (${YTP_TEMP_DIR})"
|
||||
mkdir -p "${YTP_DOWNLOAD_DIR}" "${YTP_STATE_DIR}" "${YTP_TEMP_DIR}"
|
||||
|
||||
echo_err() { cat <<< "$@" 1>&2; }
|
||||
|
||||
if [ ! -w "${YTP_STATE_DIR}" ]; then
|
||||
CH_USER=$(stat -c "%u" "${YTP_STATE_DIR}")
|
||||
CH_GRP=$(stat -c "%g" "${YTP_STATE_DIR}")
|
||||
echo_err "ERROR: Unable to write to [${YTP_STATE_DIR}] data directory. Current user id [${UID}] while directory owner is [${CH_USER}]"
|
||||
if [ ! -w "${YTP_CONFIG_PATH}" ]; then
|
||||
CH_USER=$(stat -c "%u" "${YTP_CONFIG_PATH}")
|
||||
CH_GRP=$(stat -c "%g" "${YTP_CONFIG_PATH}")
|
||||
echo_err "ERROR: Unable to write to [${YTP_CONFIG_PATH}] data directory. Current user id [${UID}] while directory owner is [${CH_USER}]"
|
||||
echo_err "[Running under docker]"
|
||||
echo_err "change docker-compose.yaml user: to user:\"${CH_USER}:${CH_GRP}\""
|
||||
echo_err "Run the following command to change the directory ownership"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "frontend",
|
||||
"name": "YTPTube",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue