1

I'm using this (https://www.youtubeinmp3.com/api/) API to fetch links for downloading MP3 versions of YouTube videos. The API doesn't give me access to a .mp3 file directly, but to a generated "webpage" that starts the download immediately.

Now my issue is, I'm using the BackgroundDownloader class to download the MP3, but I believe I'm downloading an empty HTML-page instead of the actual MP3 file.

Here's what my code looks like:

Uri source = new Uri(dlurl);

StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile destinationFile = await folder.CreateFileAsync(
dltitle + ".mp3", CreationCollisionOption.GenerateUniqueName);

BackgroundDownloader downloader = new BackgroundDownloader();
DownloadOperation download = downloader.CreateDownload(source, destinationFile);

// Attach progress and completion handlers.
HandleDownloadAsync(download, true);
double-beep
  • 5,031
  • 17
  • 33
  • 41
  • What is `dlurl` – L.B Oct 09 '16 at 19:27
  • dlurl is the download url, the url I get from the api, it looks something like this: http://www.youtubeinmp3.com/download/get/?i=OBGyyq7BTQTi8smIZT6JpGa0bBfvriDTS0M%2FGZTMwQUqWK3jz5FokMaQzOZ7aVMCHp8meewOAUH0Ofc6P%2Fmf%2Bw%3D%3D – Oscar Andersson Oct 09 '16 at 19:28

1 Answers1

1

I'd recommend using this custom lib, which supports "direct" youtube video download with custom bitrates and also custom video/audio formats (incl. mp3).

YoutubeExtractor-lib

You can easily install this by using the NUGET Package-Manager:

Install-Package YoutubeExtractor

Greeting Kyon.

marpme
  • 2,363
  • 1
  • 15
  • 24