Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[YouTube] Feature request, force download. #11357
Comments
|
Out of scope of youtube-dl. |
Please follow the guide below
xinto all the boxes [ ] relevant to your issue (like that [x])Make sure you are using the latest version: run
youtube-dl --versionand ensure your version is 2016.12.01. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
First of all thank you for your hard work making this software so good!
So, let's get straight to the point. What I need is an URL to the YouTube video that will force the browser to download it with a custom name, not playing it, so the user will be able to download the video with one click. Let's say I have this URL:
https://www.youtube.com/watch?v=pSqeQlnOhJQ
Running the following command I get the URL to the best mp4 video:
youtube-dl --skip-download -g -f mp4 https://www.youtube.com/watch?v=pSqeQlnOhJQ
Which looks something like this:
https://r4---sn-ab5l6nzd.googlevideo.com/videoplayback?mt=1480783546&expire=1480805390&nh=IgpwcjA2LmxnYTA3KgkxMjcuMC4wLjE&sparams=clen%2Cdur%2Cei%2Cgcr%2Cgir%2Cid%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&clen=20832787&requiressl=yes&ratebypass=yes&ipbits=0&itag=18&upn=w2HNKIqTxpQ&lmt=1428137939371231&gcr=us&mv=u&ei=rvdCWMKLDoGD8wSil5aYCQ&id=o-AOzRUsXVe3m6sOS4bm6IJalJG2EBfGkD0YfmokiOa6UT&ms=au&source=youtube&pl=20&dur=392.556&key=yt6&ip=X.X.X.X&gir=yes&mm=31&mn=sn-ab5l6nzd&mime=video%2Fmp4&signature=76982B58B469AC887AECEDE95D11D38A43BDEFA8.7218B84E1E8F8DB00BEA6F29A03BD1F4795E0CD1
Opening that URL on a different machines is returning 403 Forbidden, but we could use "redirector.googlevideo.com" to fix this. So the new video URL will be:
https://redirector.googlevideo.com/videoplayback?mt=1480783546&expire=1480805390&nh=IgpwcjA2LmxnYTA3KgkxMjcuMC4wLjE&sparams=clen%2Cdur%2Cei%2Cgcr%2Cgir%2Cid%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&clen=20832787&requiressl=yes&ratebypass=yes&ipbits=0&itag=18&upn=w2HNKIqTxpQ&lmt=1428137939371231&gcr=us&mv=u&ei=rvdCWMKLDoGD8wSil5aYCQ&id=o-AOzRUsXVe3m6sOS4bm6IJalJG2EBfGkD0YfmokiOa6UT&ms=au&source=youtube&pl=20&dur=392.556&key=yt6&ip=X.X.X.X&gir=yes&mm=31&mn=sn-ab5l6nzd&mime=video%2Fmp4&signature=76982B58B469AC887AECEDE95D11D38A43BDEFA8.7218B84E1E8F8DB00BEA6F29A03BD1F4795E0CD1
Which plays fine on different machines, but I need an URL that will force the browser to download the video. I found out that adding "&title=" at the end of the URL changes the filename but doesn't force download it. And I know it is possible because I'm using one site that generates exactly the URL I need. For instance, this URL will force the browser to download the video with filename "Test 123.mp4":
http://redirector.googlevideo.com/videoplayback?ratebypass=yes&mime=video%2Fmp4&ipbits=0&mm=31&mn=sn-5hne6nlr&itag=18&dur=392.556&mt=1480781984&mv=m&ms=au&ip=X.X.X.X&lmt=1428137939371231&gcr=it&id=o-AHYW4_sjmE7BnsIRkMtHQhxU_k9lVrPaozJhsLbFxjO5&expire=1480803893&upn=b-WaaAQcc34&nh=IgpwZjAxLmFtczE1Kg4xNDkuMTQuMTQyLjEwNQ&key=yt6&pl=24&sparams=dur%2Cgcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cratebypass%2Csource%2Cupn%2Cexpire&source=youtube&initcwndbps=2930000&signature=B02CBC1C64A130E7F00F4297F79137A4C4332B62.73E09C5AD4B31FD2B6AE291F99AE0A73F6CBFE0A&title=Test%20123
I see that some params are missing from this URL, but if I try to remove them from the URL that youtube-dl is generating, I'm again getting 403 Forbidden.
Thank you for your help.