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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 403 forbidden error #428

Merged
merged 2 commits into from
May 14, 2019
Merged

Fix 403 forbidden error #428

merged 2 commits into from
May 14, 2019

Conversation

BrunoMoreira99
Copy link
Contributor

Fixes #417.

This error has been happening to me way too frequently, after I saw #417 (comment) from @omarroth I was able to fix this issue. So, thanks 馃憤 I wouldn't have had a clue how to fix this otherwise.

I tested this thoroughly and was able to confirm that this does indeed fix the 403 forbidden error.

I went ahead and added some comments also, please tell me if you'd prefer no comments.
There is a much more detailed explanation of the issue at ytdl-org/youtube-dl#18927.

@BrunoMoreira99
Copy link
Contributor Author

On a side note, I don't think this function is actually doing anything right now.

node-ytdl-core/lib/info.js

Lines 246 to 250 in 43c045e

const decipherURL = (url, tokens) => {
return url.replace(/\/s\/([a-fA-F0-9.]+)/, (_, s) => {
return '/signature/' + sig.decipher(tokens, s);
});
};

I tackled around that function a bit because I thought I'd need to change it as well, but I came to the conclusion that actually the URLs it is meant to decipher (which I assume are only those from livestreams, usually) don't actually have the signature after s but after sig or signature, and I think that signature is already deciphered (as I tried to decipher it but THEN it would throw a 403 error), in fact, I tried not using this function at all and just passing the url directly to getDashManifest and getM3U8 and it worked, although the livestream actually only plays for a few seconds, but I believe that is a whole different issue.

@TheAkio
Copy link

TheAkio commented May 12, 2019

The issue with the stream stopping after a few seconds might be related to YouTube having a very weird way of doing MPEG-TS Livestreams. I made a small library that basically deals with that stuff before piping it to FFMPEG but it is also broken right now. I wanted to check over the next few days what's causing the issue. Might just be some small changes since I made that library. You can check it out here: https://github.com/TheAkio/ytls

I'm not actively working on that library and I don't plan to, so if you wanted we could build that handling into ytdl-core directly.

EDIT: ytls is actually not the issue. It was us not passing the correct format to it because YouTube probably added some new ones and our filter logic failed.

@fent fent merged commit 1f79df3 into fent:master May 14, 2019
@fent
Copy link
Owner

fent commented May 14, 2019

Thank you for this.

Still in the middle of fixing tests, but merging this in and releasing a patch version.

@BrunoMoreira99 BrunoMoreira99 deleted the fix-403-error branch May 22, 2019 22:38
@motorlatitude motorlatitude mentioned this pull request Jun 14, 2019
moshfeu added a commit to moshfeu/youtube-mp3-downloader that referenced this pull request Jul 1, 2019
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

Successfully merging this pull request may close these issues.

Very rare 403 error when streaming from YouTube
3 participants