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

update cipher regex #1646

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

update cipher regex #1646

wants to merge 9 commits into from

Conversation

garywu007
Copy link

No description provided.

@lazy-detourer
Copy link

LGTM

@nrnw
Copy link

nrnw commented May 24, 2023

This change fixed the recent error

pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

Thank you.

@MohamadOday
Copy link

LGTM

@JoaoEmanuell JoaoEmanuell mentioned this pull request May 24, 2023
@BuildWithData
Copy link

This change fixed the recent error

pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

Thank you.

can anyone explain this ? found this issue opened last year... but I don't understand how it is possible that even if this was not fixed (this pull was never merged... why ?), I was able to download videos till yesterday and now this fix is needed

@NannoSilver
Copy link

I just applied this patch for Pytube 15.0.0 and seems it is working fine.
Thank you for making it!

muriatic added a commit to muriatic/ytDownloader that referenced this pull request May 25, 2023
- manually compiled, had to use customized PyTube package. see PR #1646: pytube/pytube#1646
@boardkeystown
Copy link

This change fixed the recent error
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W
Thank you.

can anyone explain this ? found this issue opened last year... but I don't understand how it is possible that even if this was not fixed (this pull was never merged... why ?), I was able to download videos till yesterday and now this fix is needed

Yeah I don't get it either...

@boardkeystown
Copy link

EPIC thank you!

@RijwanMancamp
Copy link

This change fixed the recent error

pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W

Thank you.

what changes can you please specify as i am also facing the same issue

@gonzo-oin
Copy link

Working for me! Thanks @garywu007

@NannoSilver
Copy link

This change fixed the recent error
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W
Thank you.

what changes can you please specify as i am also facing the same issue

You can see the changes in the "Files changed" tab:
https://github.com/pytube/pytube/pull/1646/files

@JoshuaEbbert
Copy link

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?

RegexMatchError: init: could not find match for ^\w+\W

@BuildWithData
Copy link

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?

RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

@lolzhunter
Copy link

lolzhunter commented May 25, 2023

am only able to get a 720p stream at 30fps with this test video https://www.youtube.com/watch?v=iEk59PKyDwg
not sure why the 1080p 60fps is not available, separate problem maybe? not sure

@JoshuaEbbert
Copy link

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?
RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

Here's a code snippet that triggers the same error:

from pytube import YouTube
url = "https://youtu.be/9DB68OVD50A/"
yt = YouTube(url)
files = yt.streams.filter(only_audio=True)

RegexMatchError: init: could not find match for ^\w+\W

I would expect the error message to show the expression from the revised cipher.py file (r"^$*\w+\W"). Does that give any clues as to why I'm getting this error?

@muriatic
Copy link

muriatic commented May 25, 2023

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?
RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

Here's a code snippet that triggers the same error:

from pytube import YouTube url = "https://youtu.be/9DB68OVD50A/" yt = YouTube(url) files = yt.streams.filter(only_audio=True)

RegexMatchError: init: could not find match for ^\w+\W

I would expect the error message to show the expression from the revised cipher.py file (r"^$*\w+\W"). Does that give any clues as to why I'm getting this error?

I don't know exactly what you want to do with files after but this if you run this code alone with the updated main.py and cipher.py, no errors are thrown.

I tested this:

from pytube import YouTube
import os

url = "https://youtu.be/9DB68OVD50A/"
yt = YouTube(url)
files = yt.streams.filter(only_audio=True).first()
out_file = files.download()

os.rename(out_file, "someName.mp3")

Mind sharing what files you changed and what you changed them to?

Copy link
Contributor

@glubsy glubsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested but looks good to me.

The cipher change should probably be part of another PR, but it's OK.

@JoshuaEbbert
Copy link

JoshuaEbbert commented May 25, 2023

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?
RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

Here's a code snippet that triggers the same error:
from pytube import YouTube url = "https://youtu.be/9DB68OVD50A/" yt = YouTube(url) files = yt.streams.filter(only_audio=True)
RegexMatchError: init: could not find match for ^\w+\W
I would expect the error message to show the expression from the revised cipher.py file (r"^$*\w+\W"). Does that give any clues as to why I'm getting this error?

I don't know exactly what you want to do with files after but this if you run this code alone with the updated main.py and cipher.py, no errors are thrown.

I tested this:

from pytube import YouTube
import os

url = "https://youtu.be/9DB68OVD50A/"
yt = YouTube(url)
files = yt.streams.filter(only_audio=True).first()
out_file = files.download()

os.rename(out_file, "someName.mp3")

Mind sharing what files you changed and what you changed them to?

I didn't make it that far :/ That line (files = yt.streams...) throws an error for me. Any ideas on what could be causing it? I uninstalled the normal package and installed garywu007's updated version, so it's not a simple typing error.

Edit: no changes to the file are reflected when my code runs, even if I empty cipher.py.
Edit: I neglected to restart the jupyter kernel. Thanks for the help, guys!

@BuildWithData
Copy link

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?
RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

Here's a code snippet that triggers the same error:
from pytube import YouTube url = "https://youtu.be/9DB68OVD50A/" yt = YouTube(url) files = yt.streams.filter(only_audio=True)
RegexMatchError: init: could not find match for ^\w+\W
I would expect the error message to show the expression from the revised cipher.py file (r"^$*\w+\W"). Does that give any clues as to why I'm getting this error?

I don't know exactly what you want to do with files after but this if you run this code alone with the updated main.py and cipher.py, no errors are thrown.
I tested this:

from pytube import YouTube
import os

url = "https://youtu.be/9DB68OVD50A/"
yt = YouTube(url)
files = yt.streams.filter(only_audio=True).first()
out_file = files.download()

os.rename(out_file, "someName.mp3")

Mind sharing what files you changed and what you changed them to?

I didn't make it that far :/ That line (files = yt.streams...) throws an error for me. Any ideas on what could be causing it? I uninstalled the normal package and installed garywu007's updated version, so it's not a simple typing error.

Edit: no changes to the file are reflected when my code runs, even if I empty cipher.py. Edit: I neglected to restart the jupyter kernel. Thanks for the help, guys!

so does it work now ? remember that whenever you change any module in a library then you gotta shut down your program and run it again, the same applies to jupyter notebooks

if you are having troubles patching your code, I made a tutorial, just go to section at 02:57... hope this helps

@JoshuaEbbert
Copy link

I've made similar changes to my cipher.py and main.py files, yet the issue persists. Does anyone know why that might be?
RegexMatchError: init: could not find match for ^\w+\W

it's working for me, can you write here a reproducible example ?

Here's a code snippet that triggers the same error:
from pytube import YouTube url = "https://youtu.be/9DB68OVD50A/" yt = YouTube(url) files = yt.streams.filter(only_audio=True)
RegexMatchError: init: could not find match for ^\w+\W
I would expect the error message to show the expression from the revised cipher.py file (r"^$*\w+\W"). Does that give any clues as to why I'm getting this error?

I don't know exactly what you want to do with files after but this if you run this code alone with the updated main.py and cipher.py, no errors are thrown.
I tested this:

from pytube import YouTube
import os

url = "https://youtu.be/9DB68OVD50A/"
yt = YouTube(url)
files = yt.streams.filter(only_audio=True).first()
out_file = files.download()

os.rename(out_file, "someName.mp3")

Mind sharing what files you changed and what you changed them to?

I didn't make it that far :/ That line (files = yt.streams...) throws an error for me. Any ideas on what could be causing it? I uninstalled the normal package and installed garywu007's updated version, so it's not a simple typing error.
Edit: no changes to the file are reflected when my code runs, even if I empty cipher.py. Edit: I neglected to restart the jupyter kernel. Thanks for the help, guys!

so does it work now ? remember that whenever you change any module in a library then you gotta shut down your program and run it again, the same applies to jupyter notebooks

if you are having troubles patching your code, I made a tutorial, just go to section at 02:57... hope this helps

It does work now. Thanks for the help!

Copy link
Contributor

@glubsy glubsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not catch that in my previous comment, but this does not looks like it would work as intended

Comment on lines +227 to +228
logger.error(f"no match found for pattern: {pattern}")
return []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am skeptical about this part.
Returning an empty list is not what this method is expected to do. It will crash as soon as self.transform_plan[0] is called in the Cipher constructor

@fabcotech
Copy link

Patch works for me as well thanks, I don't understand what's going on with this repo, is the maintainer dead ? (no joke), no release since 2021. Someone forks ??

@Genza999
Copy link

Can anyone help with how this patch can be manually made from within docker? It'll be much appreciated

@BuildWithData
Copy link

BuildWithData commented Aug 12, 2023

Can anyone help with how this patch can be manually made from within docker? It'll be much appreciated

hi there, I have made a tutorial on how to patch pytube... first way is to patch from your running container exactly like in the video, second option is to write the set of commands you would type manually in your docker file and it should work

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

Successfully merging this pull request may close these issues.

None yet