Skip to content

The program doesn't download videos, and throws an exception #2

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

Closed
a2ys opened this issue Jun 3, 2022 · 3 comments
Closed

The program doesn't download videos, and throws an exception #2

a2ys opened this issue Jun 3, 2022 · 3 comments

Comments

@a2ys
Copy link
Contributor

a2ys commented Jun 3, 2022

Whenever I try to download a video, say this one Morbius Trailer, it throws the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\__main__.py", line 181, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py", line 33, in __init__
    raise RegexMatchError(
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "D:\Downloads\new\Python-based-Youtube-downloader\python_youtube_downloader.py", line 12, in entry_fields
    YouTube(e1.get()).streams.first().download(download_location)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\__main__.py", line 188, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\cipher.py", line 33, in __init__
    raise RegexMatchError(
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

I can't find any solution for it, hope you can help!

@a2ys
Copy link
Contributor Author

a2ys commented Jun 3, 2022

Sorry to bother but I found a solution myself. It is a bug from the library itself. You need to follow the following steps:

  1. First go to C:\Users<USERNAME>\AppData\Local\Programs\Python\Python310\Lib\site-packages\pytube on Windows or pip find pytube and go to the location on Linux or Mac.
  2. Open the file cipher.py and edit Line 30 as:
var_regex = re.compile(r"^\$*\w+\W")

Now there will be no issues!

@Akhil928
Copy link

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pytube in c:\users\akhil\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages `(15.0.0)```

IT WAS SHOWING LIKE THIS I HOPE U CAN HELP WITH THIS I'M NOT GETTING RUN THE CODE

@prateekralhan
Copy link
Owner

You seem to have Python 3.12 in your system and pytube ( underlying dependency for this app ) doesn't support Python 3.12. See this

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

No branches or pull requests

3 participants