pytube: [BUG] pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple

Before creating an issue

Please confirm that you are on the latest version of pytube by installing from the source. You can do this by running python -m pip install git+https://github.com/pytube/pytube. Sometimes, the pypi library repository is not up to date, and your issue may have been fixed already!

Describe the bug A clear and concise description of what the bug is.

To Reproduce Please provide the following information:

  • The video or playlist url that is causing the error.
  • The code where the problem is occurring.

Expected behavior A clear and concise description of what you expected to happen.

Output If pytube raises an exception, please provide the full traceback for the exception.

System information Please provide the following information:

  • Python version (run python --version)
  • Pytube version (run print(pytube.__version__) in python)
  • Command used to install pytube

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16

Most upvoted comments

try this: open the file C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py change line 272 ~ 273

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

and change line 288 nfunc=re.escape(function_match.group(1))),

In the parallel branch, I have already answered. Replace lines 272-273 in cipher.py in another way:

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

try this: open the file C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py change line 272 ~ 273

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

and change line 288 nfunc=re.escape(function_match.group(1))),

To make it work, 272-273 have to be

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]\)'          

very nice !

Hello, I have problem with streams of YouTube video. I have tried everything I found on the net! I will be grateful for help! pytube was working fine 2 or 3 weeks ago???

To Reproduce The video url : https://www.youtube.com/watch?v=xfZCFME4Gsw My Code def download_video(self,video_url, video_file_name): youtube=pytube.YouTube(video_url)

    video=youtube.streams.get_highest_resolution
    video.download(video_file_name)

My Error File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_main_.py”, line 181, in fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js) File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\extract.py”, line 409, in apply_signature cipher = Cipher(js=js) File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py”, line 43, in init self.throttling_plan = get_throttling_plan(js) File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py”, line 405, in get_throttling_plan raw_code = get_throttling_function_code(js) File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py”, line 311, in get_throttling_function_code name = re.escape(get_throttling_function_name(js)) File “C:\Users\jjpj1390\AppData\Local\Programs\Python\Python310\lib\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.10.4 pytube : 12.0.0 pip install git+https://github.com/pytube/pytube

In the parallel branch, I have already answered. Replace lines 272-273 in cipher.py in another way:

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

Thanks ☺️🥺🎉

It worked fine. Screenshot_20220505-002332

I am facing the same error.

Can’t try the fix as I am on colab

@thatsyogeshjjr @o-i-z-y-s

Just found this issue today, is there a PR with the fix?

If you want a quick workaround, this fixed the issue.