ybd-project / ytdl-core

Fast and secure YouTube downloader for JavaScript and TypeScript
MIT License
28 stars 5 forks source link

How to stream audioonly? #18

Closed orewafuad closed 2 months ago

orewafuad commented 2 months ago

Describe the feature

How can I get audio-only streaming using this package?

ybd-project commented 2 months ago

Thanks for the issue. I am currently creating a new example as Stream in the example folder. Please wait. We will let you know when it is completed.

ybd-project commented 2 months ago

https://github.com/ybd-project/ytdl-core/blob/main/examples/Stream/src/audio/streamMp3.js Please refer to this.

orewafuad commented 2 months ago

Oke, I'll give that a try. Thanks for the help!

ybd-project commented 2 months ago

If you have any questions, send them here.

orewafuad commented 2 months ago

Is it for streaming or downloading?

ybd-project commented 2 months ago

For download. Maybe an example of stream response?

orewafuad commented 2 months ago

Yes, it's directly for streaming only.

ybd-project commented 2 months ago

I understand. Rename the one you just created to the download folder and create a new one as a new streamResponse. Do you want to use express?

orewafuad commented 2 months ago

Yes, I am using Express.

ybd-project commented 2 months ago

Yes, I am using Express.

ok

orewafuad commented 2 months ago

do you have an example for that?

ybd-project commented 2 months ago

I am creating it now. Possibly tomorrow, but as much as possible.

orewafuad commented 2 months ago

Thank you, I really appreciate that!

ybd-project commented 2 months ago

We are done, see the StreamResponse in the example folder. https://github.com/ybd-project/ytdl-core/tree/main/examples/StreamResponse

orewafuad commented 2 months ago

works in local, but in the server get this error

   const FETCH_RES = await fetch(format.url, {
                      ^
ReferenceError: fetch is not defined
ybd-project commented 2 months ago

I understand. We will release v5.1.3 tomorrow, so I will fix it there.

ybd-project commented 2 months ago

v5.1.3 has been released. Please check to see if the problem has been fixed.

orewafuad commented 2 months ago

Wow, it's working, bro! Thanks a lot!

ybd-project commented 2 months ago

This issue has been resolved and will be closed.

orewafuad commented 2 months ago

Screenshot_80 Hi, I have another question. How can I get the URL like in the image?

ybd-project commented 2 months ago

Use the getFullInfo function to get information about the entire video. Pass it to the downloadFromInfo function. You can retrieve it from the information (formats) retrieved from the getFullInfo function. Alternatively, you can implement the following to obtain only the format to be downloaded.

import { YtdlCore } from '@ybd-project/ytdl-core';
const ytdl = new YtdlCore();

//                          ↓ this
ytdl.download("URL").on('info', console.log).pipe(PIPE);