Sign inSign up

energetictree/youtube-dl-server

By energetictree

•Updated over 2 years ago

based on nbr23/youtube-dl-server for arm64 and x86 with `youtube-dl` and `yt-dlp`

Image
0

3.8K

energetictree/youtube-dl-server repository overview

⁠youtube-dl-server

Based on nbr23/youtube-dl-server⁠ but for Arm64. Both youtube-dl and yt-dlp already pre-installed to switch do it from the environtment (See Configuration).

to check which module is activate run: docker exec -it [container-name] python -c 'import os; print (os.environ["YOUTUBE_DL"])'

to update pip run: docker exec -it [container-name] python -m pip install --upgrade pip

screenshot

screenshot

⁠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 energetictree/youtube-dl-server:latest
⁠Docker Compose

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

  youtube-dl:
    image: "energetictree/youtube-dl-server:latest"
    volumes:
      - $HOME/youtube-dl:/youtube-dl
    restart: always
⁠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. To switch between youtube-dl and youtube-dlc set it from the YOUTUBE_DL environment.

Configuration file config.env:

YDL_RECODE_VIDEO_FORMAT="webm"
YDL_SUBTITLES_LANGUAGES="en"
YOUTUBE_DL="youtube-dl"

The full list of definable variables can be found in config.py⁠.

docker-compose.yml:

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

⁠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"
  }),
});
⁠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⁠ / youtube-dlc⁠ 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⁠.

Tag summary

Content type

Image

Digest

Size

110.3 MB

Last updated

almost 5 years ago

docker pull energetictree/youtube-dl-server