question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] get_throttling_function_name could not find match for multiple

See original GitHub issue

Describe the bug Having issues resolving video URLs for a give youtube video. I get the following error pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple

To Reproduce Please provide the following information:

  • The video or playlist url that is causing the error. https://www.youtube.com/watch?v=Y4-GSFKZmEg

The code where the problem is occurring.

from pytube import YouTube

url = "https://www.youtube.com/watch?v=Y4-GSFKZmEg"
yt = YouTube(url)
thevid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
vid = thevid
print("VID", vid)

Expected behavior the output should print the video asset URL where the video can be downloaded from

Output

Traceback (most recent call last):
  File "/Users/par/Dev/mememaker-web/mememaker/scripts/pytube_test.py", line 5, in <module>
    thevid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/__main__.py", line 188, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/cipher.py", line 43, in __init__
    self.throttling_plan = get_throttling_plan(js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/cipher.py", line 405, in get_throttling_plan
    raw_code = get_throttling_function_code(js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/cipher.py", line 311, in get_throttling_function_code
    name = re.escape(get_throttling_function_name(js))
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/cipher.py", line 296, in get_throttling_function_name
    raise RegexMatchError(
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple

System information Please provide the following information:

  • Python 3.9.9
  • print(pytube.version) 12.0.0
  • python -m pip install git+https://github.com/pytube/pytube

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:25
  • Comments:42 (3 by maintainers)

github_iconTop GitHub Comments

150reactions
kinshuk-hcommented, Apr 15, 2022

Apparently the JavaScript code containing details of the throttling function name is now of the form:

a.D&&(b=a.get("n"))&&(b=$x[0](b)

And the regex in cipher.py cannot match the same as it searches for variable names of a fixed length (3 in this case).

Changing the regex in function_patterns in cipher.py to:

r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&\s*'
r'\([a-z]\s*=\s*([a-zA-Z0-9$]{2,3})(\[\d+\])?\([a-z]\)'

and changing line 288 of cipher.py to:

nfunc=re.escape(function_match.group(1))),

to escape the ‘$’ symbol now present in the ‘nfunc’ value seems to resolve the errors.

20reactions
kinshuk-hcommented, Apr 15, 2022

@manish-kumar-iisc Neither of the PRs containing the fixes for this problem have been merged as of yet, so you’ll have to either make the changes manually or install one of the forks containing the fix:

python -m pip install git+https://github.com/kinshuk-h/pytube
Read more comments on GitHub >

github_iconTop Results From Across the Web

get_throttling_function_name: could not find match for multiple ...
in the answer above may be parsed incorrectly by pycharm if just copy/pasted from web. To fix, try merging the two strings onto...
Read more >
pytube.exceptions.RegexMatchError ... - GitHub
pytube.exceptions.RegexMatchError : get_throttling_function_name: could not find match for multiple[BUG] #1105.
Read more >
get_throttling_function_name: could not find match for multiple
Line of code: r'a\.[A-Z]&&\(b=a\. get \("n"\)\)&&\(b=([^(]+)\(b\)',In this video, you will leran how to fix the error : pytube.exceptions.
Read more >
get_throttling_function_name: could not find match for multiple ...
RegexMatchError : get_throttling_function_name: could not find match for multiple pytube ; 1. try upgrading pytube like this: ; 2. pip install ...
Read more >
Regexmatcherror With Pytube - ADocLib
[BUG] pytube.exceptions.RegexMatchError: getthrottlingfunctionname: could not find match for multiple. I did this simple code for downloading videos:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found