Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the mp4 url for Youtube videos using Youtube v3 API

How do I get the full mp4 url to play the video from it's actual location in my application using some other source except Youtube. The gdata/youtube API has been deprecated so I am having trouble. Any help will be appreciated. Thanks.

like image 705
Lherbeur Avatar asked Jul 22 '15 14:07

Lherbeur


People also ask

How do I link a YouTube video to mp4?

If you start the video you can right click in the video and select "save video as" to get the mp4 file.

What is YouTube video URL?

To find your channel's URL: Sign in to YouTube Studio. From the left Menu, select Customization. Basic info. Under Channel URL, you can view and copy your Channel URL.


1 Answers

i made a very simple API : https://gist.github.com/egyjs/9e60f1ae3168c38cc0f0054c15cd6a83

As Example: YouTube Video Link: https://www.youtube.com/watch?v=**YGCLs9Bt_KY**

now to get the Direct link

you need to call the api , like this (change example.com to your site) :

https://example.com/?url=https://www.youtube.com/watch?v=YGCLs9Bt_KY

returns:

[     {         "url": "https:\/\/r10---sn-aigllnlr.googlevideo.com\/videoplayback?key=yt6&signature=81D86D3BC3D34D8A3B865464BE7BC54F34C1B0BC.7316033C2DD2F65E4D345CFA890257B63D7FE2A2&mt=1522999783&expire=1523021537&sparams=dur%2Cei%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&requiressl=yes&ei=gSLHWvuxDMOUVYaTqYgB&dur=244.204&pl=22&itag=22&ip=185.27.134.50&lmt=1522960451860848&id=o-AAoaDzyDCVXS404wfqZoCIdolGU-NM3-4yDxC0t868iL&ratebypass=yes&ms=au%2Conr&fvip=2&source=youtube&mv=m&ipbits=0&mm=31%2C26&mn=sn-aigllnlr%2Csn-5hne6nsy&mime=video%2Fmp4&c=WEB&initcwndbps=710000",         "quality": "hd720",         "itag": "22",         "type": "video\/mp4; codecs=\"avc1.64001F, mp4a.40.2\""     },     {         "url": "https:\/\/r10---sn-aigllnlr.googlevideo.com\/videoplayback?key=yt6&mt=1522999783&gir=yes&expire=1523021537&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&itag=43&ratebypass=yes&fvip=2&ipbits=0&mime=video%2Fwebm&initcwndbps=710000&signature=71DC48B9BF4B2E3ED46FE0A4CD36FE027DACF31E.4624B7B4BCB947336CEB029E9958B136F79759EB&clen=24203231&requiressl=yes&dur=0.000&pl=22&ip=185.27.134.50&lmt=1522961642553275&ei=gSLHWvuxDMOUVYaTqYgB&ms=au%2Conr&source=youtube&mv=m&id=o-AAoaDzyDCVXS404wfqZoCIdolGU-NM3-4yDxC0t868iL&mm=31%2C26&mn=sn-aigllnlr%2Csn-5hne6nsy&c=WEB",         "quality": "medium",         "itag": "43",         "type": "video\/webm; codecs=\"vp8.0, vorbis\""     },     {         "url": "https:\/\/r10---sn-aigllnlr.googlevideo.com\/videoplayback?key=yt6&mt=1522999783&gir=yes&expire=1523021537&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&itag=18&ratebypass=yes&fvip=2&ipbits=0&mime=video%2Fmp4&initcwndbps=710000&signature=C83DE33E3DC80981A65DB3FE4E6B3A48BF7500E4.361D0EE6210B30D3D3A80F43228DEF1BD20691A4&clen=15954979&requiressl=yes&dur=244.204&pl=22&ip=185.27.134.50&lmt=1522960340235683&ei=gSLHWvuxDMOUVYaTqYgB&ms=au%2Conr&source=youtube&mv=m&id=o-AAoaDzyDCVXS404wfqZoCIdolGU-NM3-4yDxC0t868iL&mm=31%2C26&mn=sn-aigllnlr%2Csn-5hne6nsy&c=WEB",         "quality": "medium",         "itag": "18",         "type": "video\/mp4; codecs=\"avc1.42001E, mp4a.40.2\""     },     {         "url": "https:\/\/r10---sn-aigllnlr.googlevideo.com\/videoplayback?key=yt6&mt=1522999783&gir=yes&expire=1523021537&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&itag=36&fvip=2&ipbits=0&mime=video%2F3gpp&initcwndbps=710000&signature=3E993D911492DA039A16BB26182ACDC6C6A04FCC.BFB9728C71CD03970B0F15AFD51A7355F9D3F899&clen=6759799&requiressl=yes&dur=244.273&pl=22&ip=185.27.134.50&lmt=1522957367267598&ei=gSLHWvuxDMOUVYaTqYgB&ms=au%2Conr&source=youtube&mv=m&id=o-AAoaDzyDCVXS404wfqZoCIdolGU-NM3-4yDxC0t868iL&mm=31%2C26&mn=sn-aigllnlr%2Csn-5hne6nsy&c=WEB",         "quality": "small",         "itag": "36",         "type": "video\/3gpp; codecs=\"mp4v.20.3, mp4a.40.2\""     },     {         "url": "https:\/\/r10---sn-aigllnlr.googlevideo.com\/videoplayback?key=yt6&mt=1522999783&gir=yes&expire=1523021537&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&itag=17&fvip=2&ipbits=0&mime=video%2F3gpp&initcwndbps=710000&signature=810D13A2C507A4EA220E6DA895B39B237FA22DAF.898D020851087CF3C10BC6E3ED7360736A239904&clen=2443931&requiressl=yes&dur=244.273&pl=22&ip=185.27.134.50&lmt=1522957365473654&ei=gSLHWvuxDMOUVYaTqYgB&ms=au%2Conr&source=youtube&mv=m&id=o-AAoaDzyDCVXS404wfqZoCIdolGU-NM3-4yDxC0t868iL&mm=31%2C26&mn=sn-aigllnlr%2Csn-5hne6nsy&c=WEB",         "quality": "small",         "itag": "17",         "type": "video\/3gpp; codecs=\"mp4v.20.3, mp4a.40.2\""     } ] 

update :

to see the source code :

GIST: https://gist.github.com/egyjs/9e60f1ae3168c38cc0f0054c15cd6a83

like image 158
A. El-zahaby Avatar answered Sep 28 '22 03:09

A. El-zahaby