Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dfang opened this issue May 2, 2013 · 26 comments
Closed

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

dfang opened this issue May 2, 2013 · 26 comments

Comments

@dfang
Copy link

@dfang dfang commented May 2, 2013

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

Thanks !

@yasoob
Copy link
Contributor

@yasoob yasoob commented May 2, 2013

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//issues/816
.

@dfang
Copy link
Author

@dfang dfang commented May 2, 2013

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
Copy link
Contributor

@yasoob yasoob commented May 2, 2013

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//issues/816#issuecomment-17339295
.

@yasoob
Copy link
Contributor

@yasoob yasoob commented May 2, 2013

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//issues/816#issuecomment-17339295
.

@phihag
Copy link
Contributor

@phihag phihag commented May 2, 2013

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.

@phihag phihag closed this May 2, 2013
@abidrahmank
Copy link

@abidrahmank abidrahmank commented Aug 3, 2014

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
Copy link
Contributor

@juancri juancri commented Aug 3, 2014

Please provide a sample.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Aug 4, 2014

@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
Copy link

@abidrahmank abidrahmank commented Aug 6, 2014

@jaimeMF : Thank you.. that works.

@praburamWAPKA
Copy link

@praburamWAPKA praburamWAPKA commented Jun 10, 2017

@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
Copy link

@AdnanHussainTurki AdnanHussainTurki commented Jun 14, 2017

@praburamWAPKA Thanks a lot, brother. It worked.

@AdnanHussainTurki
Copy link

@AdnanHussainTurki AdnanHussainTurki commented Jun 14, 2017

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

@praburamWAPKA
Copy link

@praburamWAPKA praburamWAPKA commented Jun 14, 2017

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

@abhisharkjangir
Copy link

@abhisharkjangir abhisharkjangir commented Feb 4, 2018

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

@shaniax420
Copy link

@shaniax420 shaniax420 commented Jul 11, 2019

@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
Copy link

@praburamWAPKA praburamWAPKA commented Jul 12, 2019

@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]';
?>

`

@shaniax420
Copy link

@shaniax420 shaniax420 commented Jul 12, 2019

@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/ :)

@praburamWAPKA
Copy link

@praburamWAPKA praburamWAPKA commented Jul 13, 2019

@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

@shaniax420
Copy link

@shaniax420 shaniax420 commented Jul 13, 2019

@praburamWAPKA Thank you so much bro :) <3

Vevo & Tseries videos 720x240 not working

@shaniax420
Copy link

@shaniax420 shaniax420 commented Jul 14, 2019

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);

?>

@melgu
Copy link

@melgu melgu commented May 6, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.