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

RegexMatchError: get_throttling_function_name: could not find match for multiple #1707

Open
JuanRoccia opened this issue Jul 1, 2023 · 25 comments
Labels

Comments

@JuanRoccia
Copy link

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
@JuanRoccia JuanRoccia added the bug label Jul 1, 2023
@github-actions
Copy link

github-actions bot commented Jul 1, 2023

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

@danilofcosta
Copy link

tbm estou enfretando o mesmo problema
na linha
yt.streams.filter(only_audio=True,abr='128kbps').first()

acontece o mesmo problema relatado acima e tem esse resultado no prompt

RegexMatchError: get_throttling_function_name: could not find match for multiple

During handling of the above exception, another exception occurred:

RegexMatchError                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/pytube/cipher.py](https://localhost:8080/#) in get_throttling_function_name(js)
    294                     return array[int(idx)]
    295 
--> 296     raise RegexMatchError(
    297         caller="get_throttling_function_name", pattern="multiple"
    298     )

RegexMatchError: get_throttling_function_name: could not find match for multiple)

Contributing.md
JuanRoccia

@HarshitKmr10
Copy link

Even when using !pytube https://youtube.com/watch?v=2lAe1cqCOXo for the youtube video on python 3.10 results in the same error. Is there any workaround for the same version ?

@schnow265
Copy link

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

@XLG123
Copy link

XLG123 commented Jul 1, 2023

I've been getting the same error for the past two days. I tried searching up for solutions, and tried some of them, however none of them worked.

@efeakaroz13
Copy link

My Spotify MP3 downloader script stopped working because of this.

@srccircumflex
Copy link

solved

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

@TerminaAS
Copy link

It's no use changing r'var {nfunc}\s*=\s*(\[.+?\]);'.format( the problem still exist

@srccircumflex
Copy link

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.

@Highfish93
Copy link

erasing the ; helped me too
thanks a lot @srccircumflex

@yaitskeshav
Copy link

erasing the ; helped me too
thanks a lot @srccircumflex

@efeakaroz13
Copy link

@srccircumflex Appreciate it !

@Iyas01
Copy link

Iyas01 commented Jul 2, 2023

Testing the download() if is not None and removing the ";" solved it for me. Thanks @srccircumflex.

Sample code from binarysmurf with applied fixes.

from pytube import YouTube
path = "/Users/user_name" # substitute to where you want to place the downloaded file

def YTDownload(link):
    youTubeObject = YouTube(link)
    youTubeObject = youTubeObject.streams.get_highest_resolution()
    try:
        if youTubeObject is not None:
            youTubeObject.download(path)
    except:
        print("There has been an error.")
    
    print("All good.")
    
link = input("What video URL? ")
YTDownload(link)

Source:
https://www.reddit.com/r/learnpython/comments/zn014o/why_is_the_download_method_flagged_as_an_error/?onboarding_redirect=%2Fr%2Flearnpython%2Fcomments%2Fzn014o%2Fwhy_is_the_download_method_flagged_as_an_error%2F

@Realalirezayazdanpanah
Copy link

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

@Armag67
Copy link

Armag67 commented Jul 3, 2023

@srccircumflex
Your trick works even on Python 3.11

@raghunathsmusings
Copy link

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 !

@Leonardo-DevStrom
Copy link

I'm going to make a video teaching how to make the correction, go to this channel https://www.youtube.com/channel/UCZLD0izYZI-zB20Uuof9u0w and the video will be out soon.

@DiegoMP-235
Copy link

Me funciono quitando ";" en la línea 287 del archivo "cipher.py"
I have removed the ";" in the line 287 of "cipher.py" and It works

@aleksejalex
Copy link

Hi everyone, I had the same error and erasing the semicolon in the line 287 of "cipher.py" also worked for me (thanks #1707 (comment) ).

Please update PyTube so everyone can use my project with unchanged version of pytube.

@klebersondrl
Copy link

klebersondrl commented Jul 9, 2023

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

@allenthomas01
Copy link

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

@AkshayShineKrishna
Copy link

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

@khoul911
Copy link

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

@YuriiMaiboroda
Copy link

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

@Bikatr7
Copy link

Bikatr7 commented Aug 15, 2023

To Fix:

Change in Cipher.py

Line 272 & 273 to :

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

And remove the ';' from Line 287.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests