pytube / pytube

A lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
https://pytube.io
The Unlicense
12.08k stars 2.5k forks source link

[BUG] get_throttling_function_name could not find match for multiple #1986

Open B-BoyPro opened 1 month ago

B-BoyPro commented 1 month ago

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

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

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.11/site-packages/pytube/__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.11/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.11/site-packages/pytube/extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.11/site-packages/pytube/cipher.py", line 43, in __init__
    self.throttling_plan = get_throttling_plan(js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.11/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.11/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.11/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 Python 3.11.9 print(pytube.version) 15.0.0 python -m pip install git+https://github.com/pytube/pytube

github-actions[bot] commented 1 month ago

Thank you for contributing to PyTube. Please remember to reference Contributing.md

underhappy commented 1 month ago

same problem

williansebastiao commented 1 month ago

Isn't there a solution that doesn't involve changing the cipher? This is just a palliative.

bernarducs commented 1 month ago

There is a pull request waiting for merging.

https://github.com/pytube/pytube/pull/1962

I got this error and the PR above fix it.

aslimohitdeveloper commented 1 month ago

Fixed just install pytube from repo aslimohitdeveloper/pytube_fix by pip install git+https://github.com/aslimohitdeveloper/pytube_fix and enjoy!

silvncr commented 1 month ago

Can I ask why this problem hasn't happened before? Does it mean YouTube changed something on their end?

edit: forgot to thank @aslimohitdeveloper for the fix 😊