-
Notifications
You must be signed in to change notification settings - Fork 457
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
chunk at offset 0 has invalid #348
Comments
me too, seems youtube changed something |
me too, waiting for some solution |
Please check @corny if you have time, thanks |
Yup same here:
|
can't really tell what's going on here...
After adding some debug logs to the package. I also tested curling the url and I get a 403 Forbidden? |
So what how does a HTML5 Video tag work with a
|
As does
At this point I'm fairly confident that most/all? Youtube frontends are now broken :/ |
Yt-dlp is working |
the problem should be in the client.go file, but i dont know how to refine it |
The "problem" being what exactly? I haven't been able to work it out myself :/ |
Examined the last commit with 403, the code point to that file |
Decoding technique likely changed again... hopefully this gets updated soon. |
Anyone or fork has a solution yet ? Thanks |
Hey bro, I found some alternative methods to try. The current configuration of Android seems to be temporarily unavailable, It is strongly recommended to use a proxy, otherwise you will be banned easily. @greentornado @PylotLight @prologic, Reference sources: https://github.com/jordibruin/YouTubeKit/blob/ad584bf7966b565f8332ee51b3df84938331a3d2/Sources/YouTubeKit/InnerTube.swift#L21 // In client.go, add IOS device
var DefaultClient = IOSClient
/*--------------------------struct-----------------------------*/
IOSClient = models.ClientInfo{
Name: "IOS",
Version: "17.33.2",
Key: "AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc",
UserAgent: "com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)",
}
//Add `Screen` and `PlayerParams` fields
type ClientInfo struct {
Name string
Key string
Version string
UserAgent string
AndroidVersion int
Screen string
PlayerParams string
}
//Add `ThirdParty` and `Params` fields
type InnertubeRequest struct {
VideoID string `json:"videoId,omitempty"`
BrowseID string `json:"browseId,omitempty"`
Continuation string `json:"continuation,omitempty"`
Context InntertubeContext `json:"context"`
ThirdParty *ThirdParty `json:"thirdParty,omitempty"`
PlaybackContext *PlaybackContext `json:"playbackContext,omitempty"`
ContentCheckOK bool `json:"contentCheckOk,omitempty"`
RacyCheckOk bool `json:"racyCheckOk,omitempty"`
Params string `json:"params,omitempty"`
}
//Add `EmbedUrl` field
type ThirdParty struct {
EmbedUrl string `json:"embedUrl,omitempty"`
}
//Add `ClientScreen` field and change to omitempty
type InnertubeClient struct {
HL string `json:"hl"`
GL string `json:"gl"`
ClientName string `json:"clientName"`
ClientVersion string `json:"clientVersion"`
AndroidSDKVersion int `json:"androidSDKVersion,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
TimeZone string `json:"timeZone"`
UTCOffset int `json:"utcOffsetMinutes"`
ClientScreen string `json:"clientScreen,omitempty"`
}
/*--------------------------function-----------------------------*/
//Some modifications
func (c *Client) videoDataByInnertube(ctx context.Context, id string) ([]byte, error) {
data := models.InnertubeRequest{
VideoID: id,
Context: prepareInnertubeContext(*c.client),
ContentCheckOK: false,
RacyCheckOk: false,
Params: client.PlayerParams,
PlaybackContext: &models.PlaybackContext{
ContentPlaybackContext: models.ContentPlaybackContext{
//SignatureTimestamp: 19250,
HTML5Preference: "HTML5_PREF_WANTS",
},
},
ThirdParty: &models.ThirdParty{
EmbedUrl: "https://www.youtube.com/",
},
}
return c.httpPostBodyBytes(ctx, client, "https://www.youtube.com/youtubei/v1/player?key="+c.client.Key, data)
}
//Add some headers
func (c *Client) httpPost(ctx context.Context, url string, body interface{}) (*http.Response, error) {
data, err := json.Marshal(body)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(data))
if err != nil {
return nil, err
}
req.Header.Set("X-Youtube-Client-Name", "3")
req.Header.Set("X-Youtube-Client-Version", client.Version)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "*/*")
req.Header.Set("Accept-Language", "de,de-DE;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6")
req.Header.Set("Accept-Encoding", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
req.Header.Set("Referer", "https://youtube.com/")
req.Header.Set("Origin", "https://youtube.com")
req.Header.Set("Host", "https://youtube.com")
req.Header.Set("User-Agent", client.UserAgent)
resp, err := c.httpDo(req)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
return nil, ErrUnexpectedStatusCode(resp.StatusCode)
}
return resp, nil
}
//ClientScreen field is optional
func prepareInnertubeContext(clientInfo models.ClientInfo) InntertubeContext {
return inntertubeContext{
Client: inntertubeContext{
HL: "en",
GL: "US",
TimeZone: "UTC",
ClientName: clientInfo.Name,
ClientVersion: clientInfo.Version,
AndroidSDKVersion: clientInfo.AndroidVersion,
UserAgent: clientInfo.UserAgent,
ClientScreen: clientInfo.Screen,
},
}
} |
thanks! will try and let you know the result |
I meet the same issue :< |
it still doesnt work on my end @shuntan, do you have good result ? Can I use your implementation ? |
Did anyone find a solution? |
I also tried the suggested change and still getting 403 from yt |
I've improved status code checking (see #350), but I currently don't have take a closer look into this issue. |
I used "parse" to get the URL and tried downloading it another way, but still got a 403 error. |
anyone has a working version yet, thanks |
If they did, I imagine we would all know about it. Could we kindly stop spamming with follow-ups? |
They fixed the problem. |
Looks like the s sig is working correctly, maybe. After removing the optional return, I get further with the dl. File size shows in the terminal. Nsig has changed. Yt-dlp has the new function and I’ve tried to use it in the go code. JS is returning its input value and not doing the transformations. My JS knowledge is pretty limited and the obscuration that google uses doesn’t help. I’ll add the new function sig to the comments when I get home. I’ve tried using regexp2 with the regex from yt-dip. Took some mods but after changing the grouping names to numbered groupings, made some progress in identifying the function that does the transforms. |
the variable names could vary. |
hardcoded but it helps. I was not able to rewrite yt-dlp regular expression to golang https://github.com/yt-dlp/yt-dlp/blob/2037a6414f81db8080ca724dca506fde91974c5d/yt_dlp/extractor/youtube.py#L3121 |
Is this issue solved with the new version I've released yesterday? |
yes, fixed for me |
yes, works very well, thanks to all involved fixing this. |
when i download video, I got the error message
Error executing command: Command failed: youtubedr download -d /Users/xx/Code/creator -q 137 https://www.youtube.com/shorts/videoId 2024/11/22 17:49:47 download to directory /Users/xx/Code/video-creator time=2024-11-22T17:49:47.025+08:00 level=INFO msg="Downloading video" id=xxxx quality=hd1080 mimeType="video/mp4; codecs=\"avc1.640028\"" chunk at offset 0 has invalid size: expected=6753827 actual=0
Has anyone come across it?
The text was updated successfully, but these errors were encountered: