Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manbearwiz/youtube-dl-server
Web / REST interface for downloading youtube videos onto a server.
https://github.com/manbearwiz/youtube-dl-server
docker python rest-api videos youtube-dl
Last synced: 4 days ago
JSON representation
Web / REST interface for downloading youtube videos onto a server.
- Host: GitHub
- URL: https://github.com/manbearwiz/youtube-dl-server
- Owner: manbearwiz
- License: mit
- Created: 2015-02-11T06:51:16.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T02:30:35.000Z (about 2 months ago)
- Last Synced: 2024-09-12T12:11:20.688Z (about 2 months ago)
- Topics: docker, python, rest-api, videos, youtube-dl
- Language: Python
- Homepage:
- Size: 196 KB
- Stars: 875
- Watchers: 28
- Forks: 283
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[![Docker Stars Shield](https://img.shields.io/docker/stars/kmb32123/youtube-dl-server.svg?style=flat-square)](https://hub.docker.com/r/kmb32123/youtube-dl-server/)
[![Docker Pulls Shield](https://img.shields.io/docker/pulls/kmb32123/youtube-dl-server.svg?style=flat-square)](https://hub.docker.com/r/kmb32123/youtube-dl-server/)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/manbearwiz/youtube-dl-server/master/LICENSE)
![Workflow](https://github.com/manbearwiz/youtube-dl-server/actions/workflows/docker-image.yml/badge.svg)# youtube-dl-server
Very spartan Web and REST interface for downloading youtube videos onto a server. [`starlette`](https://github.com/encode/starlette) + [`yt-dlp`](https://github.com/yt-dlp/yt-dlp).
![screenshot][1]
## Running
### Docker CLI
This example uses the docker run command to create the container to run the app. Here we also use host networking for simplicity. Also note the `-v` argument. This directory will be used to output the resulting videos
```shell
docker run -d --net="host" --name youtube-dl -v /home/core/youtube-dl:/youtube-dl kmb32123/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.
```yml
youtube-dl:
image: "kmb32123/youtube-dl-server"
network_mode: "service:vpn"
volumes:
- /home/core/youtube-dl:/youtube-dl
restart: always
```### Python
If you have python ^3.6.0 installed in your PATH you can simply run like this, providing optional environment variable overrides inline.
```shell
YDL_UPDATE_TIME=False python3 -m uvicorn youtube-dl-server:app --port 8123
```In this example, `YDL_UPDATE_TIME=False` is the same as the command line option `--no-mtime`.
## Usage
### Start a download remotely
Downloads can be triggered by supplying the `{{url}}` of the requested video through the Web UI or through the REST interface via curl, etc.
#### HTML
Just navigate to `http://{{host}}:8080/youtube-dl` and enter the requested `{{url}}`.
#### Curl
```shell
curl -X POST --data-urlencode "url={{url}}" http://{{host}}:8080/youtube-dl/q
```#### Fetch
```javascript
fetch(`http://${host}:8080/youtube-dl/q`, {
method: "POST",
body: new URLSearchParams({
url: url,
format: "bestvideo"
}),
});
```#### Bookmarklet
Add the following bookmarklet to your bookmark bar so you can conviently send the current page url to your youtube-dl-server instance.
```javascript
javascript:!function(){fetch("http://${host}:8080/youtube-dl/q",{body:new URLSearchParams({url:window.location.href,format:"bestvideo"}),method:"POST"})}();
```## Implementation
The server uses [`starlette`](https://github.com/encode/starlette) for the web framework and [`youtube-dl`](https://github.com/rg3/youtube-dl) to handle the downloading. The integration with youtube-dl makes use of their [python api](https://github.com/rg3/youtube-dl#embedding-youtube-dl).
This docker image is based on [`python:alpine`](https://registry.hub.docker.com/_/python/) and consequently [`alpine:3.8`](https://hub.docker.com/_/alpine/).
[1]:youtube-dl-server.png