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

[BUG] RegexMatchError: get_throttling_function_name: could not find match for multiple - v15.0.0 #1954

Open
howsinapp opened this issue Jul 9, 2024 · 77 comments · May be fixed by #1956
Open
Labels

Comments

@howsinapp
Copy link

I have confirmed that I am on the latest version of pytube by installing from the source. 15.0.0

Since today 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. Occurs sometimes, not for all video.

To Reproduce
https://www.youtube.com/watch?v=aDEDfbN5gIU
stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()

Expected behavior
I expected the video to be downloaded without any errors.

Output
File "/usr/local/lib/python3.11/site-packages/pytube/main.py", line 296, in streams
return StreamQuery(self.fmt_streams)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pytube/main.py", line 188, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/usr/local/lib/python3.11/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 43, in init
self.throttling_plan = get_throttling_plan(js)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 405, in get_throttling_plan
raw_code = get_throttling_function_code(js)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 311, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/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 version 3.11
  • Pytube version 15.0.0
  • pip install pytube
@howsinapp howsinapp added the bug label Jul 9, 2024
Copy link

github-actions bot commented Jul 9, 2024

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

@sachagd
Copy link

sachagd commented Jul 9, 2024

i encounter the exact same issue. After asking for help to chat-GPT it seems like youtube updated their javascript

@garmanarnaryt
Copy link

garmanarnaryt commented Jul 9, 2024

reported the same on the pytube3 as well. but seems like this is more maintained?

they updated for sure. :/

any workaround for cipher.py and other modules that uses the regex:js?

@ysawyers
Copy link

ysawyers commented Jul 9, 2024

runnning into the same issue too currently!

@chang432
Copy link

chang432 commented Jul 9, 2024

I see the same error as well

@artemdashkov
Copy link

have the same problem too. Python 3.12.4, pytube 15.0.0.

@amckee
Copy link

amckee commented Jul 9, 2024

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

@garmanarnaryt
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

how did you get to the solution? did you debug the js? Im curious how you work out to add another line of function_patterns string?

@mutiev
Copy link

mutiev commented Jul 9, 2024

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

It solved the problem, thanks!

@TragicXxBoNeSxX
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

Worked for me on Python 3.12.4, Pytube 15.0.0, thanks!

@amckee
Copy link

amckee commented Jul 9, 2024

@garmanarnaryt I remembered when that regex was replaced the last time this happened, so I figured I'd just try putting it back and see what happens.

@lvgvspe
Copy link

lvgvspe commented Jul 9, 2024

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

Thanks! I was struggling with it for a few hours, and your fix worked!

@garmanarnaryt
Copy link

@garmanarnaryt I remembered when that regex was replaced the last time this happened, so I figured I'd just try putting it back and see what happens.

thank you. i confirm that it works now.

I'm just curious on how to solve this kind of issue in the future. I tried to print out the "js" value on my own an try to understand the code. why the regex dont understand the current yt "js"

@AKThu
Copy link

AKThu commented Jul 9, 2024

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

how did you get to the solution? did you debug the js? Im curious how you work out to add another line of function_patterns string?

It's working now. Thanks

@sachagd
Copy link

sachagd commented Jul 9, 2024

thanks bro

@sachagd sachagd mentioned this issue Jul 9, 2024
@cluster-coder
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

Worked as a charm

@quabwww
Copy link

quabwww commented Jul 9, 2024

I don't understand they just put that coded text, where do I put it? What do I do with it? In what folder is what they mention to modify and you put what they say

@themu1376
Copy link

I don't understand they just put that coded text, where do I put it? What do I do with it? In what folder is what they mention to modify and you put what they say

Change cipher.py at line 264
If you don't understand it, it's better to wait for distribution.

@themu1376
Copy link

thank you. It works fine.

@Mohit-majumdar
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

worked for me as well

@artemdashkov
Copy link

I don't understand they just put that coded text, where do I put it? What do I do with it? In what folder is what they mention to modify and you put what they say

you need change code at line 264 in file .venv/Lib/site-packages/pytube/cipher.py, where ".venv" name of folder python virtual environment. when you find file you will understand what need to change

mjgore1120 added a commit to mjgore1120/pytube that referenced this issue Jul 9, 2024
@ahassoun123
Copy link

When will this be patched? I'm running this in a cloud function

@Albo3Beine
Copy link

THANK YOU GUYS

@IzanaonYT
Copy link

up v15.0.1!

@NextKool
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

Thanks, it works now with python 3 and pytube 15,
The question I have is when will they update that in a new version? Imagine that I am passing the script to another user, the user installs it with pip install pytube and it will not work because he has to get his hands on cipher.py

@bawejakunal
Copy link

Someone open a PR for this ?

@NextKool
Copy link

Someone open a PR for this ?

No :(

@snoopy870
Copy link

The fix is not working for me. There is no function_patterns array in cipher.py at line 264. Here is the code around line 264 in cipher.py:

for js_func in tplan:
name, argument = parse_function(js_func)
signature = tmap[name](signature, int(argument))
logger.debug(
'applied transform function\n%s', pprint.pformat(
{
'output': ''.join(signature),
'js_function': name,
'argument': int(argument),
'function': tmap[name],
}, indent=2,
),
)
return ''.join(signature)

Line 264 is 'output': ''.join(signature). I tried placing the fix in the middle of this FOR loop but it doesn't work. Is there another ciper.py file I'm missing? This is inside the pytube folder.

@lior007
Copy link

lior007 commented Jul 30, 2024

Traceback (most recent call last):
File "C:\Users\LIOR0\miniconda3\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Users\LIOR0\miniconda3\Lib\threading.py", line 975, in run
self._target(*self.args, **self.kwargs)
File "D:\MY_PROJECTS\YOUTUBE VIDEO AND AUDIO DOWNLOADER\download-from-youtube.py", line 103, in start_download
stream = yt.streams.filter(progressive=True, file_extension="mp4")
^^^^^^^^^^
File "C:\Users\LIOR0\miniconda3\Lib\site-packages\pytube_main
.py", line 296, in streams
return StreamQuery(self.fmt_streams)
^^^^^^^^^^^^^^^^
File "C:\Users\LIOR0\miniconda3\Lib\site-packages\pytube_main
.py", line 181, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Users\LIOR0\miniconda3\Lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
^^^^^^^^^^^^^
File "C:\Users\LIOR0\miniconda3\Lib\site-packages\pytube\cipher.py", line 43, in init
self.throttling_plan = get_throttling_plan(js)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LIOR0\miniconda3\Lib\site-packages\pytube\cipher.py", line 412, in get_throttling_plan
transform_plan_raw = find_object_from_startpoint(raw_code, match.span()[1] - 1)
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'span'

@spartygw
Copy link

Broken again as of August 9, 2024

@wgong
Copy link

wgong commented Aug 11, 2024

Broken again as of August 9, 2024

have anaconda with py 3.11.9 and pytube 15.0.0
applied fix above, still got this error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\p2p2l\anaconda3\envs\movie\Scripts\pytube.exe\__main__.py", line 7, in <module>
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cli.py", line 53, in main
    _perform_args_on_youtube(youtube, args)
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cli.py", line 60, in _perform_args_on_youtube
    download_highest_resolution_progressive(
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cli.py", line 474, in download_highest_resolution_progressive
    stream = youtube.streams.get_highest_resolution()
             ^^^^^^^^^^^^^^^
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
                       ^^^^^^^^^^^^^^^^
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\__main__.py", line 188, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
             ^^^^^^^^^^^^^
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cipher.py", line 37, in __init__
    self.transform_map = get_transform_map(js, var)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cipher.py", line 250, in get_transform_map
    fn = map_functions(function)
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\p2p2l\anaconda3\envs\movie\Lib\site-packages\pytube\cipher.py", line 698, in map_functions
    raise RegexMatchError(caller="map_functions", pattern="multiple")
pytube.exceptions.RegexMatchError: map_functions: could not find match for multiple

@wgong
Copy link

wgong commented Aug 11, 2024

still prefer pytube, but before above bug is fixed, I am going to use yt-dlp as a backup, see this thread https://www.reddit.com/r/Python/comments/18wzsg8/good_pytube_alternative/

I tried it out, which worked. it offers 2 features I like

  1. extract audio only format,
    my main usage is to listen music offline, so this feature would save storage too.
  2. specify video_id instead of URL.
    This CLI tool has tons of options, need to read documentation to get used to

To get started quickly, do the following (3ug835LFixU is the YT video_id as an example)

pip install yt-dlp
yt-dlp -x --audio-format mp3 3ug835LFixU

@mrxwd
Copy link

mrxwd commented Aug 11, 2024

Cambie la matriz function_patterns en cipher.py en la línea 264 para incluir esta y parece funcionar:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

pytube.exceptions.regexmatcherror: map_functions: no se pudo encontrar la coincidencia para múltiples [error]

Hay un nuevo problema? Encontraste alguna solución?

@RenderTk
Copy link

I have confirmed that I am on the latest version of pytube by installing from the source. 15.0.0

Since today 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. Occurs sometimes, not for all video.

To Reproduce https://www.youtube.com/watch?v=aDEDfbN5gIU stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()

Expected behavior I expected the video to be downloaded without any errors.

Output File "/usr/local/lib/python3.11/site-packages/pytube/main.py", line 296, in streams return StreamQuery(self.fmt_streams) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/main.py", line 188, in fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js) File "/usr/local/lib/python3.11/site-packages/pytube/extract.py", line 409, in apply_signature cipher = Cipher(js=js) ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 43, in init self.throttling_plan = get_throttling_plan(js) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 405, in get_throttling_plan raw_code = get_throttling_function_code(js) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/cipher.py", line 311, in get_throttling_function_code name = re.escape(get_throttling_function_name(js)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/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 version 3.11
  • Pytube version 15.0.0
  • pip install pytube

For me this worked:
I had to change line 195 of the "/usr/local/lib/python3.9/dist-packages/pytube/cipher.py" file from

pattern = r"%s=function\(\w\){[a-z=\.\(\"\)]*;(.*);(?:.+)}" % name

To

pattern = r"%s=function\(\w\){[a-z=\.\(\"\)]*;((\w+\.\w+\([\w\"\'\[\]\(\)\.\,\s]*\);)+)(?:.+)}" % name

And also line 264 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]\)',
r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',

@vhngroup
Copy link

vhngroup commented Aug 13, 2024

Windows:
Unzip and replace file cipher.py in:
C:\Users\ YourNameUser \AppData\Local\Programs\Python\Python312\Lib\site-packages\pytube
cipher.zip

or in your folder python into folder Lib in site-packages\pytube in a array "function_patterns" add:
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])',
r'([a-z]\s*=\s*([a-zA-Z0-9$]+)([\d+])([a-z])',

Bye Solved

@mrxwd
Copy link

mrxwd commented Aug 23, 2024 via email

@mrxwd
Copy link

mrxwd commented Aug 23, 2024

Gracias actualmente tengo este problema Exception while accessing title of https://youtube.com/watch?v=_HZM0QiuUS8. Please file a bug report at https://github.com
/pytube/pytube q error sera no entiendo sabes el motivo? Me ayudas

@RenderTk
Copy link

Gracias actualmente tengo este problema Exception while accessing title of https://youtube.com/watch?v=_HZM0QiuUS8. Please file a bug report at https://github.com
/pytube/pytube q error sera no entiendo sabes el motivo? Me ayudas

Si, pero comparte el código que te produce ese error

@mrxwd
Copy link

mrxwd commented Aug 23, 2024 via email

@RenderTk
Copy link

Entonces tmb tienes el error Wao pensé q era el único

El jue., 22 de agosto de 2024 10:00 p. m., Fernando Diaz <
@.***> escribió:

Gracias actualmente tengo este problema Exception while accessing title of
https://youtube.com/watch?v=_HZM0QiuUS8. Please file a bug report at
https://github.com
/pytube/pytube q error sera no entiendo sabes el motivo? Me ayudas

Si, pero comparte el código que te produce ese error


Reply to this email directly, view it on GitHub
#1954 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/BGFUHRCPMZZL534VZUIAZP3ZS2QUVAVCNFSM6AAAAABKSZSFKOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWGA4TCOBZGM
.
You are receiving this because you commented.Message ID:
@.***>

Yo tenía un error distinto

@mrxwd
Copy link

mrxwd commented Aug 23, 2024 via email

@RenderTk
Copy link

Podrías ayudarme con mi problema?exception while accessing title of
https://youtube.com/watch?v=_hzm0qiuus8. please file a bug report at
https://github.com /pytube/pytube

El jue., 22 de agosto de 2024 10:04 p. m., Fernando Diaz <
@.***> escribió:

Entonces tmb tienes el error Wao pensé q era el único

El jue., 22 de agosto de 2024 10:00 p. m., Fernando Diaz <
@.***> escribió:

Gracias actualmente tengo este problema Exception while accessing title of
https://youtube.com/watch?v=_HZM0QiuUS8. Please file a bug report at
https://github.com
/pytube/pytube q error sera no entiendo sabes el motivo? Me ayudas

Si, pero comparte el código que te produce ese error


Reply to this email directly, view it on GitHub
#1954 (comment)
#1954 (comment),
or unsubscribe

https://github.com/notifications/unsubscribe-auth/BGFUHRCPMZZL534VZUIAZP3ZS2QUVAVCNFSM6AAAAABKSZSFKOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWGA4TCOBZGM
.
You are receiving this because you commented.Message ID:
@.***>

Yo tenía un error distinto


Reply to this email directly, view it on GitHub
#1954 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/BGFUHRFCTVZKQOCK26DQQO3ZS2REFAVCNFSM6AAAAABKSZSFKOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWGA4TKMJUGY
.
You are receiving this because you commented.Message ID:
@.***>

Si yo te puedo ayudar pero sube el código que te causa esa excepción

Jierr added a commit to Jierr/python-yt-download that referenced this issue Sep 18, 2024
Jierr added a commit to Jierr/python-yt-download that referenced this issue Sep 18, 2024
Jierr added a commit to Jierr/python-yt-download that referenced this issue Sep 18, 2024
@gustavo-pupo
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

2024/09/22 - this solution worked for me as well

@sydneyvlo
Copy link

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

This also worked for me 9/24/2024

@sydneyvlo
Copy link

Does anyone know how we're getting the patterns? I'd love to see if we can add in a dynamic fix

@Anna-Spanner
Copy link

Anna-Spanner commented Oct 5, 2024

Change the function_patterns array in cipher.py at line 264 to include this one and it seems to work:

function_patterns = [
    # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
    # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
    # var Bpa = [iha];
    # ...
    # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
    # Bpa.length || iha("")) }};
    # In the above case, `iha` is the relevant function name
    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]\)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]

Hi! I tried this (05/10/2024) but it didn't work. This could be an error with me incorectly doing it. When I replace lines 264 - 274 with the above text, bringing it to line 275, in the file C:\Users\[user]\AppData\Local\Programs\Python\Python312\Lib\site-packages\pytube\cipher.py. I saved the file and retried my program but now it spits this error:

Exception has occurred: TypeError
'StreamQuery' object is not callable
  File "C:\Users\[user]\Coding Adventures\Google Download Test.py", line 8, in <module>
    print(pytube.YouTube(url).streams().get_highest_resolution())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'StreamQuery' object is not callable

Heres the script I'm working on:

url = "https://www.youtube.com/watch?v=eH4F1Tdb040"
print(pytube.YouTube(url).streams().get_highest_resolution())

QuentinLaure added a commit to QuentinLaure/pytube-fix that referenced this issue Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.