Git Product home page Git Product logo

youtube-dl-api's Introduction

youtube-dl-api

A server application with bookmarklet that allows you to tell a server to download videos. Created as a replacement for Plex's Watch Later feature.

Step 1: Install

The best way to install is to use Docker, though this just uses python so you could run things manually.

docker pull nowsci/youtube-dl-api

docker-compose.yml:

  youtube-dl-api:
    image: nowsci/youtube-dl-api
    container_name: youtube-dl-api
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /storage/video/Watch Later:/data
    environment:
      - PORT=8080
      - TOKEN=037816e898d2497b8a93e3be4d42ada9
      - EXTHOST=https://<myhost>.<mydomain>.<tld>:<myport>
      - FORMAT=%(title)s - %(uploader)s - %(id)s.%(ext)s
    restart: always

A token can be any random string, but you can generate them here: https://www.guidgenerator.com/online-guid-generator.aspx

The external host variable should be whatever URL is used to access the service remotely.

The /data volume is where videos are downloaded to.

FORMAT is optional and can be used to control the filename format for youtube-dl.

Step 2: Secure with SSL (optional, but recommended)

I recommend using nginx for this. Below is a sample docker compose and a sample nginx config if you use Lets Encrypt for SSL.

docker-compose.yml:

  nginx:
    image: nginx
    container_name: nginx
    volumes:
      - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf:ro
      - /data/certs/letsencrypt:/letsencrypt:ro
    ports:
      - 443:443
    restart: always

./nginx/config/nginx.conf

user www-data;
http {
	include /etc/nginx/mime.types;
	server {
		listen 33443;
		server_name <myhost>.<mydomain>.<tld>;
		gzip off;
		ssl on;
		ssl_certificate /letsencrypt/live/<mydomain>.<tld>/fullchain.pem;
		ssl_certificate_key /letsencrypt/live/<mydomain>.<tld>/privkey.pem;
		ssl_session_cache shared:SSL:10m;
		ssl_protocols TLSv1.2;
		ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!3DES';
		add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
		location / {
			proxy_pass http://youtube-dl-api:8080;
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-Proto $scheme;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Ssl on;
		}
	}
}

Step 3: Get your bookmarklet

Visit https://<myhost>.<mydomain>.<tld>:<myport>?token=037816e898d2497b8a93e3be4d42ada9

Now drage the Watch Later link into your bookmarks.

Step 4: Use it

When on a page with a video, simply click the bookmarklet.

youtube-dl-api's People

Contributors

fmstrat avatar

Stargazers

 avatar  avatar Mir Suhail Asarat avatar Gary Holtz avatar Chad Fredericksen avatar Eric Firestone avatar  avatar Sam Kopp avatar  avatar peter woodman avatar  avatar t3nzin avatar Chun-Sheng, Li avatar Mason Phillips avatar  avatar Stefan Brenner avatar Chris Harrison avatar  avatar Terry McCall avatar David Chin avatar  avatar Robert Boes avatar Luke Abell avatar axt43 avatar David Hayes avatar  avatar Fabien Piuzzi avatar Dean Ashton avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

youtube-dl-api's Issues

Failing to download video even though link shows Video Downloaded Successfully

About three weeks ago I tried to use my bookmarklet for the first time in a while and while it returned success, I find that the video doesn't download. I look in the equivalent data directory and I see that the file name is there but the size remains zero regardless of how long I leave it there. I don't believe I made any changes in my infrastructure so I am wondering if anyone else is having this issue. I am using the docker install nowsci/youtube-dl-api and have the latest update (13 days ago) which I installed after things stopped working.

Add cut/paste URL function

Allow users to visit the main URL, then cut/paste URLs. Useful for browsers that don't support bookmarklet such as mobile.

Run as a specific user/group ?

Got the app up and running, works great (THANK YOU!)

However, it runs as administrator (I'm on QNAP for reference).

I tried adding UID and GID environment variables to assign IDs, but it doesn't work.
Is there anyway to have files saved as a specific user? That way Plex (hosted on another system) can delete files when I'm done watching them.

Add --no-playlist to youtube-dl command line

/data # youtube-dl 'https://www.youtube.com/watch?v=YrDemMvfXSQ&list=WL&index=2&t=0s'
[youtube:watchlater] Downloading playlist WL - add --no-playlist to just download video YrDemMvfXSQ
[youtube:watchlater] WL: Downloading webpage
ERROR: This playlist does not exist.

/data # youtube-dl --no-playlist 'https://www.youtube.com/watch?v=YrDemMvfXSQ&list=WL&index=2&t=0s'
[youtube:watchlater] Downloading just video YrDemMvfXSQ because of --no-playlist
[youtube] YrDemMvfXSQ: Downloading webpage
[youtube] YrDemMvfXSQ: Downloading video info webpage
[youtube] Downloading just video YrDemMvfXSQ because of --no-playlist

Android Share

Develop a basic app to input URL and token for sharing sources to the api.

Need a newer version of ffmpeg

I suppose you could close this as "not a bug" because the container doesn't technically support --merge-outputformat mp4. But what I did is enter this as my format: %(title)s.%(ext)s" --merge-output-format "mp4 (with the quotes). Doing this creates the right command line, although I feel like it's a Bobby Tables kind of move. (https://xkcd.com/327/). You might consider an "extra args" config setting to make it easier for people to configure youtube-dl.

Anyway, when I do this, --merge-output-format mp4 is causing an error, due to an old version of ffmpeg in the container. Here's the error when I run the youtube-dl command in the container:

# youtube-dl --no-playlist -q --no-warnings --no-mtime -o "%(title)s.%(ext)s" --merge-output-format "mp4" "https://www.youtube.com/watch?v=KLmqgI4QfHc"
ERROR: Stream #1:0 -> #0:1 (copy)

I installed version 4.2.2 of ffmpeg from here: https://www.ffmpeg.org/download.html#build-linux and it worked.

Unfortunately, apk add --upgrade ffmpeg only finds 4.2.1-r3. The Alpine package website lists 4.2.2-r1 (https://pkgs.alpinelinux.org/packages?name=ffmpeg&branch=edge&arch=x86_64), but I guess you'd need to move to a newer Alpine for apk to find it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.