Giter Club home page Giter Club logo

youtube's Issues

Search doesnt work

Being used the code sample in readme, it doesnt work. Output:

panic: got malformed json searching for page 0 of query "animus vox": cannot parse JSON: cannot parse number: unexpected char: "\x00"; unparsed tail: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\" scrolling=\"no\"></iframe></body></html>"

cannot parse JSON

panic: got malformed json searching for page 0 of query "animus vox": cannot parse JSON: cannot parse empty string; unparsed tail: ""

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

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

Example in README.md not working

Tried to run the example in the README file but got the following error:

panic: got malformed json searching for page 0 of query "animus vox": cannot parse JSON: cannot parse number: unexpected char: "\x00"; unparsed tail: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\" scrolling=\"no\"></iframe></body></html>"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.