Skip to content

nekono-dev/ytdlpServer

Repository files navigation

ytdlp Server

ytdlp Sever is a API Endpoint for launch yt-dlp on your network.

tl;dr

Prepair Ubuntu Server and run here.

sudo apt update
sudo apt install docker.io cifs-utils
sudo gpasswd --add $USER docker
newgrp docker
sudo curl -SL https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Customise to your environment.

sudo mkdir -p /mnt/video
## if samba
sudo tee -a "//<your windows ipaddr>/<your sharing path>   /mnt/video   cifs  nofail,_netdev,x-systemd.automount,user=<your username>,password=<your password>,file_mode=0666,dir_mode=0777  0  0" /etc/fstab
sudo mount -a

Start Service.

docker-compose up -d --scale worker=4

Now you can download video by curl -X POST "http://<Your Server IPaddr>:5000/ytdlp" -d "{\"url\": \"https://www.youtube.com/watch?v=XXXXXXXXXX\"}"

Setup

Install Container engine

Install and setup docker

docker.io may charge a fee in the future.

sudo apt update
sudo apt install docker.io
sudo gpasswd --add $USER docker
newgrp docker
## if docker soket is down, reboot
sudo reboot

Install docker compose

Launch in ubuntu 22.04 LTS.

https://matsuand.github.io/docs.docker.jp.onthefly/compose/install/

sudo curl -SL https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
ubuntu@devsv:~/git/ytdlpServer
>> docker-compose --version
Docker Compose version v2.4.1

(Optional) Install cifs for mount Windows Directory

Install for mount windows samba share directory if you need.

sudo apt install cifs-utils

Create mout directory

sudo mkdir -p /mnt/video

if you need not hide your credential, you can setup fstab with hardcode credential.

ex. mount ¥¥192.168.3.120¥Videos, user name is samba, password is samba. add that to /etc/fstab

//192.168.3.120/Videos   /mnt/video   cifs  nofail,_netdev,x-systemd.automount,user=samba,password=samba,file_mode=0666,dir_mode=0777  0  0

If not, create samba credential directory and credential file for connect windows share directory.

sudo mkdir -p /etc/smb-credentials/
cat << EOF | sudo tee /etc/smb-credentials/.pw
username=user
password=passwd
EOF

...And prevent access all user except root.

sudo chmod +600 /etc/smb-credentials/.pw

Edit /etc/fstab for mount on startup.
ex. mount ¥¥192.168.3.120¥Videos add...

//192.168.3.120/Videos   /mnt/video   cifs  nofail,_netdev,x-systemd.automount,credentials=/etc/smb-credentials/.pw,file_mode=0666,dir_mode=0777  0  0

Try mount directory.

sudo mount -a

Build / Install

Install as container

Build container image.

docker-compose build

Attention: Very long to build, wait a moment.

Launch

Launch as container

Edit docker-compose.yml set your directory to volumes for download.

worker:
  build:
    dockerfile: ./Dockerfile.worker
  depends_on:
    - redis
  environment:
    RQ_REDIS_URL: redis://redis
  volumes:
    - /mnt/video:/download
  working_dir: /download

Lauch container with mounting download path.

## set scale of workers.
docker-compose up -d --scale worker=4
## show log
docker-compose logs -f

How to use

  1. send request like:

    curl -X POST "http://localhost:5000/ytdlp" -d "{\"url\": "https://www.youtube.com/watch?v=XXXXXXXXXX", \"format\": \"bv*+ba/best\"}
  2. wait a minute and will generate video to your directory.

To make it easy, I recommend create iOS Shortcut like that...

image

iOS Shortcut example

Or use it with edit: video-dl.shortcut

API option

option type description
url string video URL, input of yt-dlp
format string format setting, input of yt-dlp.
origts boolean if this parameter defined, do not update creation timestamp to download date.
category string put video to sub-directory. create dir if not exist .
language string language setting for dubbed video, defalut "ja"

About

yt-dlp download request execute server

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages