alpacamybags118 / yt-dlp-exec

3 stars 2 forks source link

How to get the YouTube stream url [Need help] #4

Closed RaghuMudem closed 2 years ago

RaghuMudem commented 2 years ago

Hi, This library is able to fetch and download the youtube video. I would like to get the youtube stream available url's from the given youtube url. Can you please help me the changes for this.

If i give the url simlar to the following https://www.youtube.com/watch?v=_xLgXIhebxA and expecting a stream url which i can play in my application.

Appriciates you positive response.

alpacamybags118 commented 2 years ago

Hi @RaghuMudem thanks for taking an interest in the project and posting here!

I think the approach you would want to take depends on your application. If this is a website and you want to show the stream on the site, I think the easiest solution would be to embed the stream using something like an iframe. e.g.

<iframe width="560" height="315" src="https://www.youtube.com/embed/5qap5aO4i9A" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

If you need to programmatically work with the stream with something like yt-dlp, I think it will just be a matter of providing the right flags to get the data you are expecting. I would recommend taking a look here as it lists all the available options for yt-dlp. When you invoke yt-dlp with this library, you can pass any of the supported flags as part of the 2nd argument of createYtDlpAsProcess. For example:

const result = yt.createYtDlpAsProcess('https://some.url', {
  f: 'bestaudio',
  preferFreeFormats: true,
  audioMultistreams: true,
});

I'll take some time this weekend to see if I can provide a more concrete example of what I think you are trying to accomplish, but I would start with those recommendations and see where that gets you.

alpacamybags118 commented 2 years ago

@RaghuMudem wanted to follow up and see if those suggestions help. let me know. if I don't hear back, I'll assume you figured something out and will close the issue for now.

alpacamybags118 commented 2 years ago

@RaghuMudem I'm going to close this for now, but feel free to open another issue if you need additional help!