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

[YoutubeDL] Fix function signature parser (refs ytdl-org/#30363) #30366

Merged
merged 1 commit into from
Dec 16, 2021

Conversation

lanegramling
Copy link

@lanegramling lanegramling commented Dec 15, 2021

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Relevant issue: #30363
Referring to the discussion in the comments of the aforementioned PR on yt-dlp, along with what is apparent upon scrutinizing Youtube's base.js (https://www.youtube.com/s/player/850eb2bc/player_ias.vflset/en_US/base.js), function signatures are not always 2 characters. An adjustment is made to the regex here to reflect this. I don't know when Youtube changed this, but I have had ~>80% of requests failing for the last 24 hours approx., due to a failure in parsing the function in youtube_dl/extractor/youtube.py::_parse_sig_js. Applying this fix to my local branch has resolved the ExtractorError exceptions and everything works fine now.

Resolves #30363
Resolves #30364
Resolves #30367
Resolves #30369.
Resolves #30370
Resolves #30372.

@lanegramling lanegramling changed the title [youtube] Fix function signature parser (refs ytdl-org/#30363) [YoutubeDL] Fix function signature parser (refs ytdl-org/#30363) Dec 15, 2021
@philippkeller
Copy link

I tested this change and it worked for me, thanks for fixing, @lanegramling

Copy link

@phreaknerd phreaknerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well. Thanks

@sobhan-m94
Copy link

thanks for fixing, @lanegramling

@stefaner1
Copy link

How can I approve it? Can I download it using python pip before the changes are committed? It works for me and I need it fast.

@dirkf
Copy link
Contributor

dirkf commented Dec 15, 2021

Thanks for this. To help updating while releases are on hold I've pulled the commit into PR #30184 so that a single youtube.py update fixes both issues.

Please add this text to your PR description, to link the potentially resolved issues through GH magic:

Resolves #30363
Resolves #30364
Resolves #30367
Resolves #30369.
Resolves #30370
Resolves #30372.

r'\bm=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(h\.s\)\)',
r'\bc&&\(c=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(c\)\)',
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 regexes ought to be merged, though maybe not in the scope of this PR:

             r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)(?:;[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\))?',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍work for me, modify the file by hand

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works also for me 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question What do windows peeps do?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suffer.

In addition to that they can install python and run this themselves quite fine.

@nicolasbouthors
Copy link

This works fine here 👍

@LooOOooM
Copy link

Can someone please also compile a windows version or pointing us the the path, where the related file usually sits? I am using Yoube-DLG on windows in version 0.4. I cannot find the file youtube.py anywhere to motify it by hand.
THX!

@dirkf
Copy link
Contributor

dirkf commented Dec 15, 2021

Read issue #29326 for hints.

@lanegramling
Copy link
Author

Thanks for this. To help updating while releases are on hold I've pulled the commit into PR #30184 so that a single youtube.py update fixes both issues.

Please add this text to your PR description, to link the potentially resolved issues through GH magic:

Resolves #30363
Resolves #30364
Resolves #30367
Resolves #30369.
Resolves #30370
Resolves #30372.

Added. Thanks for taking the time to combine the PRs.

@lanegramling lanegramling mentioned this pull request Dec 15, 2021
11 tasks
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
r'\bm=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(h\.s\)\)',
r'\bc&&\(c=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(c\)\)',
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2,}\.[a-zA-Z0-9$]{2,}\(a,\d+\)',

This works for me.👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this observation as well. I was torn here - Wasn't sure whether it would be necessary, so I did some tests without these extra commas and everything worked just fine, so I left them out. I will elect to the suggestion of the greater democracy for opinions on this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked for me.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks heaps, worked a charm. I always wondered how the updates fixed these kinds of errors in the past. Love open source, love learning, love sharing.

@snepderg
Copy link

snepderg commented Dec 16, 2021

How would I go about decompiling this properly so I can edit the file myself? I'm using Chocolatey.
(I should note I've tried to do my own research but I have never opened a .exe before, and that's the only file I think I can get at with Chocolatey)

@lanegramling
Copy link
Author

I would suggest the reverse route: cloning a source repository with the included fix found in #30366 , and performing the build yourself based on the instructions available in the readme. That is, if you do need to use a binary version to agree with your existing environment.

@alvinbengeorge
Copy link

alvinbengeorge commented Dec 16, 2021

Could you please accept this soon and push it to pypl

@pianodude1011
Copy link

pianodude1011 commented Dec 16, 2021

I tried the fix by uninstalling youtube-dl and reinstalling from this branch, then running youtube-dl https://www.youtube.com/watch?v=2GG8xQDH2cI and still get the same errors. I'm erring more on the side that I somehow messed up but I figured it might be helpful to note this in case others are also having issues.

If it helps, I ran
pip3 uninstall youtube-dl
pip3 install git+https://github.com/lanegramling/youtube-dl@fix-function-sig-parser#egg=youtube-dl

Copy link

@supersu-man supersu-man left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the issue

@supersu-man
Copy link

Could you please accept this soon and push it to pypl

@alvinbengeorge pip install git+https://github.com/lanegramling/youtube-dl@fix-function-sig-parser should do the job.

@mattalibodie
Copy link

I tried the fix by uninstalling youtube-dl and reinstalling from this branch, then running youtube-dl https://www.youtube.com/watch?v=2GG8xQDH2cI and still get the same errors. I'm erring more on the side that I somehow messed up but I figured it might be helpful to note this in case others are also having issues.

If it helps, I ran pip3 uninstall youtube-dl pip3 install git+https://github.com/lanegramling/youtube-dl@fix-function-sig-parser#egg=youtube-dl

Thanks! It work for me.

@pianodude1011
Copy link

Thanks! It work for me.

I'm glad it worked for you but it didn't work for me :v

@Chi-K24
Copy link

Chi-K24 commented Dec 16, 2021

pip3 install git+https://github.com/lanegramling/youtube-dl@fix-function-sig-parser#egg=youtube-dl

Thanks my dude, it worked like a charm!

@dstftw dstftw merged commit b5242da into ytdl-org:master Dec 16, 2021
@000011111111
Copy link

000011111111 commented Dec 16, 2021

Using yt-dlp worked for me. Workflow here!

https://youtu.be/dAc5VIDIs5k

@snepderg
Copy link

snepderg commented Dec 16, 2021

I decided to just switch to yt-dlp, someone was kind enough to PR youtube-dl-explorer (which is what I use):
notthebee/ytdl-explorer#5

Best of luck folks!

gaming-hacker added a commit to gaming-hacker/youtube-dl that referenced this pull request Dec 24, 2021
* commit 'afaec67d45df19642eb4af230b506127af84ceff':
  Fixes 404 Issue Currently Present On XVIDEOS.COM
  release 2021.12.17
  [ChangeLog] Actualize [ci skip]
  [youtube] Update signature function patterns (closes ytdl-org#30363) (ytdl-org#30366)
@dirkf dirkf linked an issue Jan 29, 2022 that may be closed by this pull request
5 tasks
@Lesmiscore Lesmiscore mentioned this pull request Feb 20, 2022
14 tasks
NoSuck pushed a commit to NoSuck/youtube-dl-1 that referenced this pull request Apr 5, 2022
dirkf pushed a commit to dirkf/youtube-dl that referenced this pull request Jun 27, 2022
giantorth added a commit to giantorth/LMS-YouTube that referenced this pull request Oct 10, 2022
Playback fixed based on similar change in youtube-dl: ytdl-org/youtube-dl#30366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet