knadh / go-get-youtube

A tiny Go library + client for downloading Youtube videos. The library is capable of fetching Youtube video metadata, in addition to downloading videos.
158 stars 35 forks source link

Library works only on some videos #14

Open XiovV opened 4 years ago

XiovV commented 4 years ago

This video downloads fine But then this one or this one don't.

Ragnnn commented 4 years ago

Got the same problem

Head request failed: Head : unsupported protocol scheme ""

Looks like it does this when the video_id contains a dash. Don't know how to fix this but at least it will be easier with this information I think

XiovV commented 4 years ago

@Ragnnn you're right. After experimenting a bit it seems like resp, err := http.Head(url) returns resp.StatusCode == 403 when video_id contains a dash.

XiovV commented 4 years ago

Actually... Ig-86pjzzXg returns 403 but q0DRVz6M-e0 works fine and they both contain "-". Strange.

cofonseca commented 3 years ago

I'm also experiencing this issue on videos that do not include a dash. For example, WfCZd26xt3c and ZgSFN-Fvs1I are both valid IDs, but both fail with the same error: Head request failed: Head "": unsupported protocol scheme "" even though one has a dash and the other does not.

@knadh any suggestions?

Edit: I haven't had a ton of time to look into this, but from what I've been able to tell so far, I believe the issue is occurring in func parseMeta(). There appears to be an issue with the query, or the way it's being parsed.

Looking at this line: format_params := strings.Split(query.Get("url_encoded_fmt_stream_map"), ",") query doesn't appear to contain anything called url_encoded_fmt_stream_map, so format_params ends up being empty. This causes additional issues later in the func as we attempt to range over the contents of format_params and create a video.Formats[] object, which doesn't exist, which I believe is the reason for the Head request failed error above.

Here's a screenshot of some simple fmt.Println() output that I added for debugging: image

If I have time this evening I'll try to do some more digging, but I'm not familiar at all with what this query is supposed to look like so I'm not sure I'm the best person to work on this.