Skip to content

Simple python server to fetch media data using yt-dlp/yt-dlp

License

Notifications You must be signed in to change notification settings

Rynoxx/youtube-dl-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Stars Shield Docker Pulls Shield GitHub license

youtube-dl-server

Barebones REST interface for getting youtube-dl/yt-dlp info from a longrunning process.
This is to improve performance over the cli implementation as we don't need to initialize the extractors again for every request.

starlette + yt-dlp.

Switched from youtube-dl to yt-dlp to get faster updates and some other improvements from yt-dlp not included in youtube-dl.

Running

Docker CLI

This example uses the docker run command to create the container to run the app. Binding to port 8080

docker run -d -p 8080:8080 --name youtube-dl rynoxx/youtube-dl-server

Docker Compose

This is an example service definition that could be put in docker-compose.yml. This service uses a VPN client container for its networking.

  youtube-dl:
    image: "rynoxx/youtube-dl-server"
    network_mode: "service:vpn"
    restart: always

Python

If you have python ^3.6.0 installed in your PATH you can run it like this, providing optional environment variable overrides inline.

python3 -m uvicorn youtube_dl_server:app --port 8123

Usage

Data can be fetched by supplying the {{url}} and {{format}} of the requested video through the REST interface via curl, etc.
Format is the youtube-dl string for the -f option, i.e. bestvideo or bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio

Curl

curl -X GET http://{{host}}:8080/info?url={{url}}&format={{format}}

JS Fetch

fetch(`http://${host}:8080/info?url=${url}&format=${format}`);

Implementation

The server uses starlette for the web framework and yt-dlp to handle the data fetching. The integration with yt-dlp makes use of their python api.

This docker image is based on python:3-alpine and consequently alpine:3.

About

Simple python server to fetch media data using yt-dlp/yt-dlp

Resources

License

Stars

Watchers

Forks

Packages

No packages published