pytube: [BUG] RegexMatchError('__init__: could not find match for ^\\w+\\W')

Before creating an issue

confirmed I on the latest version of pytube by installing from the source.

Describe the bug Error trying to get URL for video (<class 'pytube.exceptions.RegexMatchError'>, RegexMatchError('__init__: could not find match for ^\\w+\\W')

To Reproduce Please provide the following information:

Expected behavior It should be able to provide the URL to download the video

Output

  File "/Users/par/Dev/mememaker-web/mememaker/views/resolver.py", line 273, in resolve_image_url
    thevid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/__main__.py", line 188, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "/Users/par/.virtualenvs/mememaker/lib/python3.9/site-packages/pytube/cipher.py", line 33, in __init__
    raise RegexMatchError(
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

System information Please provide the following information:

  • Python version 3.99
  • Pytube version 12.1.0
  • Command used to install pytube: python -m pip install git+https://github.com/pytube/pytube

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 17
  • Comments: 18

Commits related to this issue

Most upvoted comments

Hey, found this issue in an earlier thread - here is the link to the thread:

https://github.com/pytube/pytube/issues/1199#issuecomment-1016783092

“” I just updated the regex like this and it’s working: ^\$*\w+\W “”

sorry had to edit - the image alone was not specific at all, note the change implemented on line 30 of cipher.py: image

One slash was cuted in answer above. Correct: ^\$*\w+\W

This fix helped me. Thank you.

Can anyone please provide the patch for this ?

Hey, found this issue in an earlier thread - here is the link to the thread:

#1199 (comment)

“” I just updated the regex like this and it’s working: ^$*\w+\W “”

sorry had to edit - the image alone was not specific at all, note the change implemented on line 30 of cipher.py: image

ваше решение помогло…

I have updated cipher.py as suggested and now I have a new error pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*. This one comes from extract.py file. More specifically, this is the function throwing the error:

def video_id(url: str) -> str:
    return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)

How can I go about it?

I have this simple code that causes this: https://dpaste.com/9M6KAUK28

I also had this issue. Amazing how active this thread is, and how many users there are. However, it looks like the project is difficult to maintain, and requires constant fixes…