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

downloading video bug #1754

Open
Luxkaiv opened this issue Aug 11, 2023 · 25 comments
Open

downloading video bug #1754

Luxkaiv opened this issue Aug 11, 2023 · 25 comments
Labels

Comments

@Luxkaiv
Copy link

Luxkaiv commented Aug 11, 2023

yesterday, pytube was working just fine for me but today all of a sudden when i run my yt to mp3 converter it stops recognizing the link and gives me the pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W. ive done as much debugging as i can, i printing out the link before this statement runs so i know that the link is correctly passed through. even asked chat gpt and it blamed pytube and not my code.

To Reproduce
Please provide the following information:
Ive tried several videos and none work so ill just give one https://www.youtube.com/watch?v=l_FWkOR4QvU
the code where it isnt worknig is here:
def download_vid(self, link):
self.label2 = customtkinter.CTkLabel(self.mainframe,text="downloading...")
self.label2.grid(row=3,column=0)
name = self.Entry.get()
#gui stuff ^^
print(link)
#printing to test if the link was correctly passed through ^^
yt = YouTube(link)
filename = yt.title + ".mp4"
newname = name + ".mp4"
stream = yt.streams.filter(only_audio=True,file_extension="mp4").first()
Itag = stream.itag
stream = yt.streams.get_by_itag(Itag)
stream.download()
#downlaods song^^
os.rename(filename, newname)
song = newname
sound = AudioSegment.from_file(song)
length = sound.duration_seconds
sound = sound - 15
sound.export(name + ".mp3", format="mp3", bitrate="320k")
os.remove(newname)
shutil.move(f"{name}.mp3", f"songs")
#converts the mp4 to an mp3
self.update_song_list()
#updates the gui^^
self.playsong("songs\" + f"{name}.mp3",length)
#runs the next function

Expected behavior
What is supposed to happen is you input the link and the name you want to give the file and it will download it, rename it and make it an mp3, and then put it in a file then calls the next function which request if you would like to play the song

Output
once again the error code:
pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W

System information
Please provide the following information:

  • Python version 3.11.4
  • Pytube version 15.0.0
  • pip install pytube
@Luxkaiv Luxkaiv added the bug label Aug 11, 2023
@github-actions
Copy link

Thank you for contributing to PyTube. Please remember to reference Contributing.md

@Ayman-ing
Copy link

same error

@amckee
Copy link

amckee commented Aug 11, 2023

Apply #1707 (comment) if you haven't already, then change cipher.py line 30 to:

var_regex = re.compile(r"^\$\w+\W")

YMMV

@Luxkaiv
Copy link
Author

Luxkaiv commented Aug 11, 2023

seemed to work

@Leonardo-DevStrom
Copy link

@amckee Yeah, this fixes the bug. Congratulations to you.

@Leonardo-DevStrom
Copy link

@amckee I was testing line 30, but didn't find out that it was just "$", so, you've noticed it well and really fast.

@paichiwo
Copy link

works perfectly, thanks

@AkshayShineKrishna
Copy link

This worked for me , and the download speeds are better now.

@r-silver1
Copy link

awesome thank you

@actuallyrizzn
Copy link

This did not solve the issue for me. It just started manifesting for me about noon central today. I've done the usual regex fixes mentioned here and on other related threads, and it's still having this error.

@Luxkaiv
Copy link
Author

Luxkaiv commented Aug 11, 2023

This did not solve the issue for me. It just started manifesting for me about noon central today. I've done the usual regex fixes mentioned here and on other related threads, and it's still having this error.

maybe try uninstalling pytube and reinstalling and then redoing this step?

@actuallyrizzn
Copy link

This did not solve the issue for me. It just started manifesting for me about noon central today. I've done the usual regex fixes mentioned here and on other related threads, and it's still having this error.

maybe try uninstalling pytube and reinstalling and then redoing this step?

that did the trick. shoulda turned it off and back on again.

@boardkeystown
Copy link

Apply #1707 (comment) if you haven't already, then change cipher.py line 30 to:

var_regex = re.compile(r"^\$\w+\W")

YMMV

GOAT thank you bro!

@41v4
Copy link

41v4 commented Aug 12, 2023

I am experiencing the same issue. However, I recall encountering this problem last year as well. Why is it happening again? Does anyone have any ideas?

@amckee
Copy link

amckee commented Aug 12, 2023

I am experiencing the same issue. However, I recall encountering this problem last year as well. Why is it happening again? Does anyone have any ideas?

When Youtube makes changes, as it does frequently, the parser needs updated accordingly.

@anushnandyala
Copy link

anushnandyala commented Aug 12, 2023

I am still having the same issue even after changing line 30. This is the error I am getting:
Error downloading video: __init__: could not find match for ^\\w+\\W

arssing added a commit to arssing/pytube that referenced this issue Aug 12, 2023
@oncename
Copy link

var_regex = re.compile(r"^$*\w+\W") does not work

@Leonardo-DevStrom
Copy link

@oncename Really?

@amckee
Copy link

amckee commented Aug 12, 2023

@anushnandyala the regex is incorrect. ( "^\\" vs "^\$" )

@oncename the regex is incorrect. ( "^$*" vs "^\$" )

After making the change, of course, you will need to restart the script to reload the new code.

@oncename
Copy link

oncename commented Aug 12, 2023

@anushnandyala the regex is incorrect. ( "^\\" vs "^\$" )

@oncename the regex is incorrect. ( "^$*" vs "^\$" )

After making the change, of course, you will need to restart the script to reload the new code.

var_regex = re.compile(r"^\$\w+\W") ?

@amckee
Copy link

amckee commented Aug 12, 2023

@oncename That looks correct. The dollar sign needs to be escaped.

@ImagineA1m
Copy link

Apply #1707 (comment) if you haven't already, then change cipher.py line 30 to:

var_regex = re.compile(r"^\$\w+\W")

YMMV

You are a legend bro it works now tysm

@strtech111
Copy link

i changed it on my local machine.
var_regex = re.compile(r"^$\w+\W")
But what about on my server it not working

@Leonardo-DevStrom
Copy link

@saqlainniazi1
Screenshot_20230813-081820~2

@CosmKiwi
Copy link

CosmKiwi commented Aug 14, 2023

var_regex = re.compile(r"^$\w+\W")

The $'s not always there. So add ? after it to check for 0 or 1 occurrence:

var_regex = re.compile(r"^\$?\w+\W")

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

No branches or pull requests