pytube: getting regex error

Upon downloading a playlist, i get the regex error Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__ return self.func(*args) File "C:/Users/nicto/PycharmProjects/idk/playlist activator/playlist downloader.py", line 40, in func pl.download_all('C:\\pythonpractice\music') File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\contrib\playlist.py", line 150, in download_all yt = YouTube(link) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\__main__.py", line 88, in __init__ self.prefetch_init() File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\__main__.py", line 97, in prefetch_init self.init() File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\__main__.py", line 133, in init mixins.apply_signature(self.player_config_args, fmt, self.js) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\mixins.py", line 49, in apply_signature signature = cipher.get_signature(js, stream['s']) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\cipher.py", line 250, in get_signature tplan = get_transform_plan(js) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\cipher.py", line 69, in get_transform_plan name = re.escape(get_initial_function_name(js)) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\cipher.py", line 45, in get_initial_function_name return regex_search(pattern, js, group=1) File "C:\Users\nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\helpers.py", line 41, in regex_search .format(pattern=p), pytube.exceptions.RegexMatchError: regex pattern (yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*c\s*&&\s*d\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\() had zero matches

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 24 (2 by maintainers)

Most upvoted comments

Experienced same error. In cipher.py replace the regexs in pattern in get_initial_function_name with: r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('.

FYI if you want to install the latest source directly from github using pip, type this in your command line:

pip install git+https://github.com/nficano/pytube.git

pip install git+https://github.com/nficano/pytube.git This one is works fine Thanks,

broke again. applied the fix, working since 2018NOV20 as of 3 Dec 09:54 AEST failed.

 File "./py.py", line 57, in main
    youtube = YouTube(url)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/__main__.py", line 88, in __init__
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/__main__.py", line 97, in prefetch_init
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/__main__.py", line 133, in init
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/mixins.py", line 49, in apply_signature
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/cipher.py", line 250, in get_signature
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/cipher.py", line 69, in get_transform_plan
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/cipher.py", line 45, in get_initial_function_name
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytube-9.3.4-py3.5.egg/pytube/helpers.py", line 41, in regex_search
pytube.exceptions.RegexMatchError: regex pattern (yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*c\s*&&\s*d\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\() had zero matches

DEC05 Works again?

File “/usr/local/lib/python3.5/site-packages/pytube/helpers.py”, line 41, in regex_search .format(pattern=p), pytube.exceptions.RegexMatchError: regex pattern (yt.akamaized.net/)\s*||\s*.?\sc\s*&&\sd.set([^,]+\s,\s*(?P<sig>[a-zA-Z0-9$]+)() had zero matches

Same error but it occurs intermittently

I’ll try 3.7. Thank you @JakLeg

@yelosheng It doesn’t look like you updated your regex. See my comment above or pull the most recent version of the lib.