Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to download URL using youtube_explode_dart package in 2023?

I want to download videos using audioOnly from youtube using URL, I am using youtube_explode_dart for this purpose, but the code method has migrated now, I cant figure out despite checking documentation of package, that how to download audio only.

my code:

Future<String> getDownloadUrl(String videoId) async {
var youtube = YoutubeExplode();
var video = await youtube.videos.get(videoId);
return youtube.streamsClient.getAudioOnly().first.url;

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are doing it right but with old methods, update your code to the following mentioned, also check latest youtube_explode_dart package’s documentation to understand better.

Future<String> getDownloadUrl(String videoId) async {
var youtube = YoutubeExplode();
var video = await youtube.videos.get(videoId);

// Get the stream manifest for the video
var streamManifest = await youtube.videos.streamsClient.getManifest(videoId);

// Get the audio-only streams from the manifest
var audioOnlyStreams = streamManifest.audioOnly;

// Get the highest quality audio-only stream
var audioStream = audioOnlyStreams.withHighestBitrate();

// Return the URL of the audio stream
return audioStream.url.toString();


}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading