Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player.ResolveURL() returns "no url could be found" #4

Open
cofonseca opened this issue Dec 1, 2020 · 0 comments
Open

player.ResolveURL() returns "no url could be found" #4

cofonseca opened this issue Dec 1, 2020 · 0 comments

Comments

@cofonseca
Copy link

I'm trying to use this library to download audio for a given video. In my case, I already have the video ID as a string, and I am providing it to the Load() method directly: youtube.Load(videoID). A player gets returned, I can use it to get audio, and I can see the filename of each audio track. When I try to use player.ResolveURL() to retrieve the full URL of the audio, it returns an error. I see the same result for every video that I try.

Here's an example code snippet that I've set up to demonstrate:

func getAudioFromVideo(string videoID) {
	player, err := ydl.Load(videoID)
	fmt.Println("Attempting to get audio for ID:", videoID)
	if err != nil {
		fmt.Println("Error with player:", err)
	}	

	stream := player.SourceFormats().AudioOnly().SortByAudioQuality()
	for i, s := range stream {
		fmt.Println("")
		fmt.Println("Attempting to get audio version", i+1, "of", len(stream))
		fmt.Println(s)

		audioOnlyFilename := "audio." + s.FileExtension()
		fmt.Println("audioOnlyFilename:", audioOnlyFilename)

		audioOnlyURL, err := player.ResolveURL(s)
		if err != nil {
			fmt.Println("Error on ResolveURL:", err)
		}
		fmt.Println(audioOnlyURL)
	}
}

getAudioFromVideo("fhCTLEEkhYY")

This code results in the following output:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant