ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.18k stars 9.93k forks source link

Can i just extract youtube video download url but not download ? #816

Closed dfang closed 11 years ago

dfang commented 11 years ago

Can i just extract youtube video download url but not download ?

Thanks !

yasoob commented 11 years ago

yes you can by using -g or --get-url as the parameter. For example:

youtube-dl -g www.youtube.com/watch?v=a15KgyXBX24

On Thu, May 2, 2013 at 3:07 PM, dfang notifications@github.com wrote:

Can i just extract youtube video download url but not download ?

Thanks !

— Reply to this email directly or view it on GitHubhttps://github.com/rg3/youtube-dl/issues/816 .

dfang commented 11 years ago

thanks yasoob , it works ! however the url is different from the results from 10youtube.com , i mean even the first part (http://r6---sn-o097zne7.c.youtube.com/ vs http://r6---sn-a5m7znez.c.youtube.com, when i paste the url to browser , one is directly downable , one is for streaming) is different , and there are so many parameters , which parameters are required to download the video ? where can i find the documentation about all the parameters ? i know by extracting the video_info file , i can get the urls , but the url is not downloadable .

Thanks !

yasoob commented 11 years ago

you can not use it like that. because youtube requires some headers which are not there in the requests you make with your browser so you can only use youtube-dl to download youtube videos because it sets up these headers for you or if you want to reinvent the wheel you can make your own script.

On Thu, May 2, 2013 at 6:58 PM, dfang notifications@github.com wrote:

thanks yasoob , it works ! however the url is different from the results from 10youtube.com , i mean even the first part ( http://r6---sn-o097zne7.c.youtube.com/ vs http://r6---sn-a5m7znez.c.youtube.com, when i paste the url to browser , one is directly downable , one is for streaming) is different , and there are so many parameters , which parameters are required to download the video ? where can i find the documentation about all the parameters ? i know by extracting the video_info file , i can get the urls , but the url is not downloadable .

Thanks !

— Reply to this email directly or view it on GitHubhttps://github.com/rg3/youtube-dl/issues/816#issuecomment-17339295 .

yasoob commented 11 years ago

The above explanation was according to my knowledge and the difference in the url is there because youtube has different servers for different areas and so these servers have different urls........:) I hope this helps. If you want to discuss further then i ll suggest you to pm me. You can get my email from my github profile.

On Thu, May 2, 2013 at 7:48 PM, Yasoob Khalid yasoobkhld@gmail.com wrote:

you can not use it like that. because youtube requires some headers which are not there in the requests you make with your browser so you can only use youtube-dl to download youtube videos because it sets up these headers for you or if you want to reinvent the wheel you can make your own script.

On Thu, May 2, 2013 at 6:58 PM, dfang notifications@github.com wrote:

thanks yasoob , it works ! however the url is different from the results from 10youtube.com , i mean even the first part ( http://r6---sn-o097zne7.c.youtube.com/ vs http://r6---sn-a5m7znez.c.youtube.com, when i paste the url to browser , one is directly downable , one is for streaming) is different , and there are so many parameters , which parameters are required to download the video ? where can i find the documentation about all the parameters ? i know by extracting the video_info file , i can get the urls , but the url is not downloadable .

Thanks !

— Reply to this email directly or view it on GitHubhttps://github.com/rg3/youtube-dl/issues/816#issuecomment-17339295 .

phihag commented 11 years ago

As @yasoob pointed out, youtube uses (its internal) CDN, and the domain name depends on your locale, timing, and youtube's configuration. The URL will be the correct one for whatever arguments (mainly --format) you pass into youtube-dl. The download request must also regularly come from the same IP, and with the same cookie, although youtube sometimes relaxes that requirement - for example, any IPv6 address usually works if the original extraction happened over IPv6.

I'm not sure why you don't let youtube-dl download the video in the first place. Can you elaborate why? In any case, I'm closing this issue for now, but feel free to comment if the current explanations are not sufficient.

abidrahmank commented 10 years ago

Hi @phihag : I am a little late to this discussion. I am trying to grab the download url of a video using -g option. Then I want to use third party download accelerators for faster downloading. For example, axel download youtube videos with 3MBps (when given proper download link) while youtube-dl use only <200KBps. So I want to get correct download link from youtube-dl, but as mentioned before, link given by youtube-dl is only for streaming. I can't download it. Is there any option to get the correct download-ready link?

juancri commented 10 years ago

Please provide a sample.

abidrahmank commented 10 years ago

@juancri :

Original youtube link:http://www.youtube.com/watch?v=McLq1hEq3UY&list=PL3D9A62846A129C47&index=1

Link extracted using firefox addon - youtubedownloader:http://r6---sn-o3o-itql.googlevideo.com/videoplayback?fexp=902408,914075,927622,931983,934024,934030,934112,936118,946013&mws=yes&signature=D074C25B7A3EE38CAC446BB3E7F17475CD32F287.AD5B4780FA5EE049E63C5A23AF412EF8F57BD073&sparams=id,ip,ipbits,itag,ratebypass,source,upn,expire&ipbits=0&ratebypass=yes&ip=14.139.155.210&key=yt5&ms=au&mv=m&source=youtube&mm=31&expire=1407080453&sver=3&itag=43&mt=1407058789&upn=EsVeNUdzpE4&id=o-AGCHpYYJoCh5X1ocOCbN72EVNQ-LqJeiF7c0VtyrukmH&keepalive=yes&title=Lecture%201%20%7C%20Convex%20Optimization%20I%20(Stanford)

It works with axel.

link obtained using youtube-dl:https://r6---sn-o3o-itql.googlevideo.com/videoplayback?id=o-AFHImZJsmjt8yI_xihoVbmPmSmXrAqro8iqUUJ0WZw09&mws=yes&signature=25AD626680DA9E25FE2FF838C4586A744ECFFEDD.2BD268381BABD67103D0C787599120710A32796A&key=yt5&ipbits=0&expire=1407080588&fexp=902408%2C922525%2C927622%2C931340%2C934024%2C934030%2C937407%2C938638%2C941438%2C946023%2C946901%2C947702&mt=1407058893&ratebypass=yes&sver=3&ip=14.139.155.210&upn=pLLpYzfupiE&requiressl=yes&sparams=id%2Cip%2Cipbits%2Citag%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&itag=43&ms=au&source=youtube&mv=m&mm=31

Axel throws an error: HTTP/1.1 403 Forbidden

jaimeMF commented 10 years ago

@abidrahmank The problem seems to be that the url extracted with youtube-dl uses https (other downloaders like curl or aria2c download it fine). You can get http urls using the --prefer-insecure option, but I would personally avoid using it, I would use a downloader that support https urls.

abidrahmank commented 10 years ago

@jaimeMF : Thank you.. that works.

AdnanHussainTurki commented 7 years ago

Hello guys, Sorry for late coming.

My issue is the filename of video downloaded from url fetched from youtube-dl -g

youtube-dl -g gives me a url look like: https://r15---sn-4g57knlz.googlevideo.com/videoplayback?expire=1497021992&keepalive=yes&mv=m&mt=1497000273&ms=au&ei=yGk6WcLjCNqw8wSimYHgCQ&mn=sn-4g57knlz&mm=31&ipbits=0&requiressl=yes&itag=134&source=youtube&id=o-AG-urEi46umUqTe6H5w-0ZrCiqgqNw6bwDggUMhFUbEL&lmt=1496955572204598&dur=203.786&ip=167.114.210.100&key=yt6&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&mime=video%2Fmp4&pl=25&gir=yes&initcwndbps=772500&clen=3330292&signature=4AE80109039EC8BD9B08120A1A5A1FFD0C7EA6A3.5430E1D3818868AC98DC4AEBC1080BB264913360&ratebypass=yes

when i try to download this. it gives me a file like videoplayback.mp4

what i need is a file whose name is not videoplayback but the video title.

Any suggestions?

praburamWAPKA commented 7 years ago

@AdnanHussainTurki

`<?php $url = 'https://youtube.com/watch?v='.$_GET['v'].'';

$cmd =' youtube-dl -g -f36 ' . escapeshellarg($url); exec($cmd, $outputsd);

$results = print_r($outputsd[0], true); $pat = '/^(https:\/\/)[a-zA-Z0-9-.]+.googlevideo.com\//'; $results1 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results); $cmd2 =' youtube-dl -g -f18 ' . escapeshellarg($url); exec($cmd2, $outputss);

$results2 = print_r($outputss[0], true); $results3 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results2);

$cmd3 =' youtube-dl -g -f22 ' . escapeshellarg($url); exec($cmd3, $outputsss); $results4 = print_r($outputsss[0], true); $results5 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results4);

$cmd4 =' youtube-dl -g -f17 ' . escapeshellarg($url); exec($cmd4, $outputssss);

$name =' youtube-dl -e ' . escapeshellarg($url); exec($name, $outputs); echo 'Download 3gp 176x144p
Download MP4 320x240p
Download MP4 640x360p
Download MP4 HD720p
'; ?>`

AdnanHussainTurki commented 7 years ago

@praburamWAPKA Thanks a lot, brother. It worked.

AdnanHussainTurki commented 7 years ago

@praburamWAPKA On analysing that replacement, I came to know this only works for 720p video + audio type video.

praburamWAPKA commented 7 years ago

you need to encode url and set filename well its similar to project https://github.com/jeckman/YouTube-Downloader you will get it :)

abhisharkjangir commented 6 years ago

@AdnanHussainTurki Add title query param at the end of the link.

FmtHost commented 5 years ago

@praburamWAPKA

`<?php $url = 'https://youtube.com/watch?v='.$_GET['v'].'';

$cmd =' youtube-dl -g -f36 ' . escapeshellarg($url); exec($cmd, $outputsd);

$results = print_r($outputsd[0], true); $pat = '/^(https://)[a-zA-Z0-9-.]+.googlevideo.com//'; $results1 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results); $cmd2 =' youtube-dl -g -f18 ' . escapeshellarg($url); exec($cmd2, $outputss);

$results2 = print_r($outputss[0], true); $results3 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results2);

$cmd3 =' youtube-dl -g -f22 ' . escapeshellarg($url); exec($cmd3, $outputsss); $results4 = print_r($outputsss[0], true); $results5 = preg_replace($pat, 'https://redirector.googlevideo.com/', $results4);

$cmd4 =' youtube-dl -g -f17 ' . escapeshellarg($url); exec($cmd4, $outputssss);

$name =' youtube-dl -e ' . escapeshellarg($url); exec($name, $outputs); echo 'Download 3gp 176x144p

Download MP4 320x240p Download MP4 640x360p Download MP4 HD720p

'; ?>`

can u fix this code pls its not working with me :(

praburamWAPKA commented 5 years ago

@shaniax420 Make sure you have installed youtube-dl under /usr/local/bin this path

`<?php

header('Content-Disposition:filename="video.mp4"');

$url = 'https://youtube.com/watch?v='.$_GET['v'].'';

$cmds = ("/usr/local/bin/youtube-dl -g -f22 $url 2>&1 ") ; exec($cmds,$out);

$link_720=print_r($out[1],true);

$cmdss = ("/usr/local/bin/youtube-dl -g -f18 $url 2>&1 ") ; exec($cmdss,$outt);

$link_360=print_r($outt[1],true);

$cmdsss = ("/usr/local/bin/youtube-dl -g -f36 $url 2>&1 ") ; exec($cmdsss,$outtt);

$link_240=print_r($outtt[1],true);

$cmdssss = ("/usr/local/bin/youtube-dl -g -f140 $url 2>&1 ") ; exec($cmdssss,$outttt);

$link_mp3=print_r($outttt[1],true);

$name =' /usr/local/bin/youtube-dl -e ' . escapeshellarg($url); exec($name, $outputs);

echo '

Download[720p]';

echo '

Download[360p]';

echo '

Download[240p]';

echo '

Download [Mp3]'; ?>

`

FmtHost commented 5 years ago

@praburamWAPKA

Happy to see your reaply but your code i cant see perfect Already installed in /usr/local/bin getting error on my website http://prntscr.com/odw18j your code look like this http://prntscr.com/odw1df

can you pls add your code in this website https://pastebin.com/ :)

MSZ991 commented 5 years ago

Hi @praburamWAPKA Can you help me? Actually I am getting 0 byte Txt file for some downloads ,The link is working perfect but its gives me 0 bytes . Here is my code.

router.get('/download', function(req, res){
  var url = req.query.url;
  var filename = req.query.filename;
  filename=encodeURIComponent(filename);
https.get(url, function(response) {
            console.log(url);
            filename = filename.split('%20').join('_');
            res.setHeader('Content-disposition', 'attachment; filename='+filename);
            response.pipe(res);

    })

my link is working https://r3---sn-hju7en7r.googlevideo.com/videoplayback?expire=1562976980&ei=dM4oXZ3KEIz8gQfvkY3IBw&ip=185.212.131.104&id=o-AOh3nXjLEMpmc3uJsLeRrmihesNKCZNC3HK_oN02Ji6K&itag=22&source=youtube&requiressl=yes&mime=video%2Fmp4&ratebypass=yes&dur=1665.265&lmt=1562883289242728&fvip=3&c=WEB&txp=4532432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRQIhAIP8ucS7-7UsWzvIWK-PU67whjhuqdiHT2rnakG7-OEfAiB5b2c7LCzdJqsl3NCyz1GKCKSbjyCJTkJaAOJpvBxzzA%3D%3D&rm=sn-5hnelr7s&req_id=c89a61829cc0a3ee&ipbypass=yes&cm2rm=sn-f5uxxo23-aixe7s,sn-ug5onfvgaq-3ipl7s&redirect_counter=3&cms_redirect=yes&mip=110.36.116.130&mm=30&mn=sn-hju7en7r&ms=nxu&mt=1562955329&mv=m&mvi=2&pl=22&lsparams=ipbypass,mip,mm,mn,ms,mv,mvi,pl&lsig=AHylml4wRgIhAMhMkGNeJ6zd6gFPCFTPAAlLYwdPPqXDnQdtQ9S1f1rZAiEAulMEdvpZ6BzCBtrNisWccM_hrn-v0PKt_SLmcYTQBVM=

praburamWAPKA commented 5 years ago

https://pastebin.com/LcLZz5rr @shaniax420

praburamWAPKA commented 5 years ago

@MSZ991 use this https://github.com/jeckman/YouTube-Downloader to generate links.... Don't forget to enable Ciphered Option on Config file(default.php) under Config folder

FmtHost commented 5 years ago

@praburamWAPKA Thank you so much bro :) <3

Vevo & Tseries videos 720x240 not working

FmtHost commented 5 years ago

Using this way but no sound 720 any way to get link 720 with Sound Vevo Videos

<?php

header('Content-Disposition:filename="video.mp4"');

$url = 'https://youtube.com/watch?v='.$_GET['v'].'';

$cmdss = ("/usr/local/bin/youtube-dl -g $url 2>&1 ") ; exec($cmdss,$outt);

$link_720=print_r($outt[1],true);

?>

scut-salmon commented 4 years ago

Hi, I found that -g give me https://r4---sn-a5meknes.googlevideo.com/videoplayback?expire=1579700257&ei=wfsnXorED5HKgQPQjaHADQ&ip=172.105.229.224&id=o-AI2gi9Nsn68-C2ClEc8Z5EdPdCvJthJ7t-We8bF3toqx&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-a5meknes%2Csn-a5mlrnes&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=381250&vprv=1&mime=video%2Fmp4&gir=yes&clen=23014401&dur=213.099&lmt=1535971690686753&mt=1579678577&fvip=4&keepalive=yes&fexp=23842630&beids=9466586&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIhAM4sjkHurzTp14DWGwTOSvJxMr91MjArcfHrACecgWLsAiBfZ-HdHiAetCn0ZlSMjOJPL-aal2KKSiaGit7qcbxnPg%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhAMGnVZmITNZ-N-FBURKT9nbWn_Y973_sLE7lGonC31eKAiEA-D67Kb1ZzBVA90EvOQXp7IzHdJU9rPObkIqvVkHNhFM%3D&ratebypass=yes but what I really want is the url of the video such as https://www.youtube.com/watch?v=7E-cwdnsiow how can I solve it? Thanks

melgu commented 4 years ago

@scut-salmon Don’t you give that URL as input? You should already have it. Or am I misunderstanding your question?

AhmedO9473 commented 1 year ago

Hello guys, Sorry for late coming.

My issue is the filename of video downloaded from url fetched from youtube-dl -g

youtube-dl -g gives me a url look like: https://r15---sn-4g57knlz.googlevideo.com/videoplayback?expire=1497021992&keepalive=yes&mv=m&mt=1497000273&ms=au&ei=yGk6WcLjCNqw8wSimYHgCQ&mn=sn-4g57knlz&mm=31&ipbits=0&requiressl=yes&itag=134&source=youtube&id=o-AG-urEi46umUqTe6H5w-0ZrCiqgqNw6bwDggUMhFUbEL&lmt=1496955572204598&dur=203.786&ip=167.114.210.100&key=yt6&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&mime=video%2Fmp4&pl=25&gir=yes&initcwndbps=772500&clen=3330292&signature=4AE80109039EC8BD9B08120A1A5A1FFD0C7EA6A3.5430E1D3818868AC98DC4AEBC1080BB264913360&ratebypass=yes

when i try to download this. it gives me a file like videoplayback.mp4

what i need is a file whose name is not videoplayback but the video title.

Any suggestions?

The default switch gives video without audio, to get them together use -f22 LIKE this (this uses the forked project): yt-dlp -g https://www.youtube.com/watch?v=M7Ew_zube4M -f22 which gives: https://rr1---sn-8vq54voxxb-j5pk.googlevideo.com/videoplayback?expire=1688220907&ei=i-CfZI-MDc7OW5uLpIAL&ip=196.221.209.152&id=o-AMLSskzxMejmSAc9ACcwfgnexMDnuY17P3nuf4DmDVQp&itag=22&source=youtube&requiressl=yes&mh=HF&mm=31%2C29&mn=sn-8vq54voxxb-j5pk%2Csn-hpa7znz6&ms=au%2Crdu&mv=m&mvi=1&pl=24&initcwndbps=336250&spc=Ul2Sq_eYXZXW5O1tyj2zxyRLgSdEeL4&vprv=1&svpuc=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=253.283&lmt=1688154968175300&mt=1688198957&fvip=2&fexp=24007246%2C51000022&beids=24350017&c=ANDROID&txp=5532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAOqLg-bXyGmQpPwdbjOpwPEr_GeqPg1RSioxMsxvE26rAiBMgeRyL1sayFB4UlsbauQ7BFhGAtzic5ygSH8A2zOsig%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgR-ZtCYY3IGkUTH9g-aWkoEyzgErXqJ2YQJ-104RikWICIHw61RpjEGTXLCOlQuHUoAMwPBNEjceVtneY8Tfcw8TY

AhmedO9473 commented 1 year ago

Using this way but no sound 720 any way to get link 720 with Sound Vevo Videos

header('Content-Disposition:filename="video.mp4"'); $url = 'https://youtube.com/watch?v='.$_GET['v'].''; $cmdss = ("/usr/local/bin/youtube-dl -g $url 2>&1 ") ; exec($cmdss,$outt); $link_720=print_r($outt[1],true); ?>

use -f22 and the screenshot for work: image The -f22 info is: 22 mp4 1280x640 30 2 │ ≈ 11.37MiB 368k https │ avc1.64001F mp4a.40.2 44k [en] 720p