pytube: [BUG] RegexMatchError ?
Until now it’s worked perfectly, but now it’s showing a issue is this only for me or ?, can anyone help ty
Ignoring exception in on_message
Traceback (most recent call last):
File "/.local/lib/python3.9/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/.local/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/.local/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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 51
- Comments: 46
Commits related to this issue
- [Fix] Issue: pytube#1199 — committed to JavDomGom/pytube by JavDomGom 2 years ago
- Regex error from pytube HOTFIX as per https://github.com/pytube/pytube/issues/1199 — committed to glubsy/livestream_saver by glubsy 2 years ago
- Update cipher.py See https://github.com/pytube/pytube/issues/1199#issuecomment-1016783092 — committed to Fireline-Science/pytube by sean-schaefer 2 years ago
- https://github.com/pytube/pytube/issues/1199 issue fix Signed-off-by: joel tang <jztangw@gmail.com> — committed to joejztang/pytube by deleted user a year ago
- Fixed regex for url https://github.com/pytube/pytube/issues/1199 — committed to isaku-dev/pytube by isaku-dev a year ago
I just updated the regex like this and it’s working:
^\$*\w+\W
I’m able to download the videos again.
Nope, i shifted my project to ytdlp ( ytdl forked, more advanced and get frequently updates ) . I got sick of pytube and its bugs on daily basis, my project got affected very bad with pytube. Now i am happy with more reliable and powerful lib ytdlp. Again i am not saying pytube is bad lib, But due to lack of updates by author and tons of bugs which is not getting fixed by months , i just shifted also i advise you same whosoever is running their project with pytube.
Thanks , this is not hate message for pytube, its just a my recommendation.
Prolly some new changes from youtube side
what worked for me was: in pytube/cipher.py change the line:
var_regex = re.compile(r"^\w+\W")
tovar_regex = re.compile(r"^\$*\w+\W")
Thank you Juancho, I add this fix to PR #1193
Hi, anyone who’s using this library on some cloud-based platform like heroku can use my temporary repository till the next update. just in requirements.txt file replace pytube with git+https://github.com/ehsanbehdad/Pytube then you’ll be fine.
Sure it works perfectly, I tested it locally, but what if the app is deployed on Streamlit Cloud/sharing, Heroku … ?
top screenshot at least looks like PyCharm
Yes, there are many PR to review and merge. As soon as the original code is up to date we should all update as well. Temporarily, whoever wants can use my fork with these problems already solved and if you prefer you can also apply the changes to your local version.
Beaaauty! I tried but forgot the * between the $ and w! Time to go review my regular expressions! Cheers
is pytube is working for anyone, Please share pytube patched branch so that we will be able to install through pip
great work, thankyou so much!!!
Same. Raise exception from here: https://github.com/pytube/pytube/blob/master/pytube/cipher.py#L31
The code for
js
changed. Reviewing the regular expression is a good start point.I wrote the code to fix this bug in this PR https://github.com/pytube/pytube/pull/1336 I tested it locally and it worked for me. Until this PR gets merged you can manually edit the cipher file on line 30 and change the regular exp as mentioned in this stack overflow answer https://stackoverflow.com/a/70777385
https://github.com/pytube/pytube/blob/2e307d8d615ef30aa837fe2275954146dab07ca6/pytube/cipher.py#L30
Thank you @ehsanbehdad, this worked for me!
Thank you Ehsan that’s great will try that !
Please Anyone share the branch in which it is patched
https://github.com/pytube/pytube/issues/1199#issuecomment-1017190777
Update the library with the changes you made and then later we solve the problem of the kit… We want a solution All telegram bots and Windows programs are stopped … Update the library with what you have solved
Hi @arturtamborski, this is already solved in the current version: https://github.com/JavDomGom/pytube/blob/master/pytube/parser.py#L152
lmao, got the same error and wanted to open an issue. Literally yesterday everything was fine