jerry08 / SpotifyExplode

Spotify downloader and metadata parser
GNU General Public License v3.0
27 stars 5 forks source link

Spotify fetching music #1

Closed J0nathan550 closed 1 year ago

J0nathan550 commented 1 year ago

Hey Jerry, I have a question related to your API.

I want using spotify links listen to the whole music. And so the question is, do I able to listen to the Spotify music using your API, or your API can only provide fetching track data and etc. (Plus downloading)?

I tried to use your api, and only thing I could accomplish is fetching song title, and listen to preview of the song.

If you can explain how using your API I can be able to listen to whole song, I'm all ears.

If it is not possible, how can I then download it correctly?

Thanks for the later responding.

jerry08 commented 1 year ago

Spotify's Web API doesn't provide links to entire songs. They only provide preview URLs in tracks metadata. To get a URL for an entire song, you'll have to find the closest match in YouTube. You can use my method to get a YouTube URL for the related Spotify track:

var spotify = new SpotifyClient();

var youtubeId = await spotify.Tracks.GetYoutubeIdAsync("https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b");

// Use YoutubeExplode to get the audio stream with from the Youtube Id above
...

Or you can get the download URL and do whatever you want with it:

var spotify = new SpotifyClient();

var downloadUrl = await spotify.Tracks.GetDownloadUrlAsync("https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b");

// Start downloading/streaming audio from the URL above
J0nathan550 commented 1 year ago

I tried the method of fetching download link, but for no reason the link providers that you use has buffering downloading

(You wait loading, and later you get already fully downloaded file)

Because of this issue, I cannot download file as I should, I need somehow to wait the download. Because when I wait the download link, it returns null audio file (with no audio inside), program thinks that file is downloaded, but in reality it doesn't contain any data.

jerry08 commented 1 year ago

I don't understand what you're saying. You may have a problem with your code and not SpotifyExplode. If you've tried the method .GetDownloadUrlAsync(...) and it returns an empty URL, it may be that the sites I use to get the URL may not be available in your country.

J0nathan550 commented 1 year ago

No it doesn't return empty url, problem is that the URL itself is downloading file in unusual way.

Imagine you are downloading the Visual Studio installer on microsoft site, or you are downloading game in Steam.

In there (in browser), you see the progress of downloading specific file.

In this case, the site provides another way of downloading file, you basically enter the link, you wait, when the link will load, and after you get completely downloaded file.

Because of this, file downloading is impossible for me, ClientDownloader hits the link, creating the file, but not waiting the progress of the download.

Maybe there are some issues on my side, but I will try the YouTube explode as you wrote. It can fetch audio stream data, that I will try to use to listen.

Later maybe I will write again, see you next time!

jerry08 commented 1 year ago

That's an issue on your end most likely. I hope you get it fixed!

J0nathan550 commented 1 year ago

YouTube explode solve the issue, thank you so much for the wonderful API!