pytube: RegexMatchError: get_throttling_function_name: could not find match for multiple

Before creating an issue

I have confirmed that I am on the latest version of pytube by installing from the source. I did this by running !pip install git+https://github.com/pytube/pytube.

Describe the bug

I’m encountering a RegexMatchError when trying to download a YouTube video using pytube. The error message suggests that the function get_throttling_function_name could not find a match for multiple.

To Reproduce

The video URL that is causing the error is https://www.youtube.com/watch?v=Xg9ihH15Uto&ab_channel=Fireship.

Here is the code where the problem is occurring:

from pytube import YouTube

def Download(link):
    youtubeObject = YouTube(link)
    youtubeObject = youtubeObject.streams.get_highest_resolution()
    try:
        youtubeObject.download()
    except:
        print("An error has occurred")
    print("Download is completed successfully")

link = 'https://www.youtube.com/watch?v=Xg9ihH15Uto&ab_channel=Fireship'
Download(link)

Expected behavior

I expected the video to be downloaded without any errors.

Output

Here is the full traceback for the exception:

RegexMatchError: get_throttling_function_name: could not find match for multiple

System information

  • Python version: 3.10.12
  • Pytube version: 15.0.0
  • Command used to install pytube: !pip install --upgrade pytube

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 25

Most upvoted comments

solved

fix the problem by removing the ; from the pattern in line 287 of pytube.cipher

Changing line 287 of pytube.cipher to exactly 'var {nfunc}\\s*=\\s*(\\[.+?])'.format( works fine for me. Perhaps the java scripts differ depending on the region.

In the second repexp, the square brackets must be mandatory. Need to remove the question mark after the group with them.

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

erasing the ; helped me too thanks a lot @srccircumflex

if erasing the semicolon on line 287 does not work you can change the lines 272 and 273 to:

r’a.[a-zA-Z]\s*&&\s*([a-z]\s*=\sa.get(“n”))\s&&.?||\s([a-z]+)‘, r’([a-z]\s*=\s*([a-zA-Z0-9$]+)([\d+])?([a-z])', ]

Erasing the semicolon in line 287 helped me too.⚡ Thanks a lot @srccircumflex

Erased the semicolon on line 287 of ‘cipher.py’ and it got fixed. thank you so much @srccircumflex 🌟

Erasing the semicolon in line 287 helped me too. Thanks a lot @srccircumflex!

solved

fix the problem by removing the ; from the pattern in line 287 of pytube.cipher

Thank you very much @srccircumflex. Removing ; solved the problem !

@srccircumflex Your trick works even on Python 3.11

removing the ; inside the regex pattern in line 287 of file “pytube.cipher” totally fixed this! Thanks to @srccircumflex

erasing the ; helped me too thanks a lot @srccircumflex

I guess that it has to do with something on YouTube’s end. I’m getting the same Error.