Extract just the audio link from a youtube video without converting
Asked Answered
F

1

10

I know there are hundreds of sites to convert youtube video to mp3. Most of them do it by first downloading the video and then converting it to mp3(or any other audio format) on their server using youtube-dl, ffmpeg or similar programs.

What I want to know is, is there any way I can just extract the audio link for any youtube video? I don't know if it's possible but I saw a couple of websites doing it .

First Website : Openaisearch.com This website simply gives a download link for the audio(getting it from youtube videos). I searched for a song and saw the download url, it looked something like this :

https://redirector.googlevideo.com/videoplayback?source=youtube&requiressl=yes&clen=3814013&upn=dzwY9aUVYME&lmt=1469875393441562&expire=1484854959&mime=audio%2Fmp4&nh=IgpwcjAxLnNlYTA5Kg01Mi45NS4yMTYuMTAy&itag=140........... 

I believe that this is not done by first downloading and converting the video to audio format(Correct me if I am wrong). Although the file which gets downloaded after using this link is without any extension, but adding ".m4a" at the end of downloaded file does the work.

Second Website : http://keepvid.com/?url=https://www.youtube.com/watch?v=PT2_F-1esPk

Again similar website with similar audio link. You can check by visiting the URL and see link of audio files.

Any idea how these websites get that "googlevideo.com" link? Do they scrap the youtube video links or something?

Thanks.

Falsehood answered 19/1, 2017 at 13:54 Comment(0)
M
14

Use youtube-dl to get the list of formats available for a video

e.g.

youtube-dl -F https://www.youtube.com/watch?v=abcdefghijk

Identify the format code for the audio stream you want, say 140. Then run

youtube-dl --get-url -f 140 https://www.youtube.com/watch?v=abcdefghijk
Maye answered 19/1, 2017 at 14:24 Comment(5)
Thanks for the answer, when I tried this, I got url like "r6---sn-gwpa-5bge.googlevideo.com/videoplay......." but in example sites, the link is like "redirector.googlevideo.com/videoplay......" for same video. Also, when I try to open the 1st link in browser, it shows a bank page but the 2nd link (redirector.googlevideo.com/videoplay....) works fine and starts playing audio in the browser. Can you explain how that's happening?Falsehood
The link from youtube-dl works here in browser (Firefox 47).Maye
@kamronshaw i own one of the sites the link isnt generated through youtube-dl buddyUnfounded
The available formats (with codes) can also be obtained directly from the Youtube website, right-click on the video and pick "Stats for Nerds"Joli
A list of format codes and their meaning is available here: gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096fJoli

© 2022 - 2024 — McMap. All rights reserved.