Skip to content

Web / REST interface for downloading youtube videos onto a server.

License

Notifications You must be signed in to change notification settings

ToWatchList/twl-dl-server

 
 

Repository files navigation

twl-dl-server

Simple Web and REST interface for downloading youtube videos onto a server. bottle + youtube-dl / / youtube-dl. This TWL version adds integrations with ToWatchList and Kodi.

This project is forked from nbr23/youtube-dl-server, which was previously forked from manbearwiz/youtube-dl-server.

screenshot screenshot

Running

For easier deployment, a docker image is available on dockerhub.

The latest image now uses youtube-dl. For the original youtube-dl based image, use nbr23/youtube-dl-server:youtube-dl

Docker CLI

This example uses the docker run command to create the container to run the app. Note the -v argument to specify the volume and its binding on the host. This directory will be used to output the resulting videos.

docker run -d --name youtube-dl -v $HOME/youtube-dl:/youtube-dl towatchlist/twl-dl-server

Docker Compose

This is an example service definition that could be put in docker-compose.yml.

  youtube-dl:
    image: "towatchlist/twl-dl-server"
    volumes:
      - $HOME/youtube-dl:/youtube-dl
    restart: always

The latest image now uses youtube-dl. For the original youtube-dl based image, use nbr23/youtube-dl-server:youtube-dl

Configuration

For easier configuration management and edition, you can save your variables in an external file and source them in your docker-compose.yml like the following example.

Configuration file config.env:

YDL_RECODE_VIDEO_FORMAT="webm"
YDL_SUBTITLES_LANGUAGES="en"

docker-compose.yml:

  youtube-dl:
    image: "towatchlist/twl-dl-server"
    env_file:
      - ./config.env
    volumes:
      - $HOME/youtube-dl:/youtube-dl
    restart: always

Python

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

YDL_SERVER_PORT=8123 python3 -u ./youtube-dl-server.py

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/ and enter the requested {{url}}.

Curl

curl -X POST --data-urlencode "url={{url}}" http://{{host}}:8080/api/downloads

Fetch

fetch(`http://${host}:8080/api/downloads`, {
  method: "POST",
  body: new URLSearchParams({
    url: url,
    format: "bestvideo"
  }),
});

Integration with ToWatchList

Add your account's API key from ToWatchList Tools to the Docker's environment variables via the command line (or the Docker Compose). For example the command line could be:

docker run -d --name youtube-dl -v --env TWL_API_TOKEN=`${apitoken}` $HOME/youtube-dl:/youtube-dl towatchlist/twl-dl-server

You can trigger an update from TWL via a curl command, this can be added to external cron scripts too.

curl http://{{host}}:8080/api/twl/update

Bookmarklet

Add the following bookmarklet to your bookmark bar so you can conviently send the current page url to your youtube-dl-server instance.

HTTPS

If your youtube-dl-server is served through https (behind a reverse proxy handling https for example), you can use the following bookmarklet:

javascript:fetch("https://${host}/api/downloads",{body:new URLSearchParams({url:window.location.href,format:"bestvideo"}),method:"POST"});
Plain text

If you are hosting it without HTTPS, the previous bookmarklet will likely be blocked by your browser (as it will generate mixed content when used on HTTPS sites). Instead, you can use the following bookmarklet:

javascript:(function(){document.body.innerHTML += '<form name="ydl_form" method="POST" action="http://${host}/api/downloads"><input name="url" type="url" value="'+window.location.href+'"/></form>';document.ydl_form.submit()})();

Implementation

The server uses bottle for the web framework and youtube-dl to handle the downloading. The integration with youtube-dl makes use of their python api.

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

About

Web / REST interface for downloading youtube videos onto a server.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 58.5%
  • HTML 20.8%
  • JavaScript 14.9%
  • Shell 2.6%
  • Dockerfile 2.4%
  • CSS 0.8%