2

I'm having issues with pytube on raspberry pi 4b running python 3.7. Im getting this error code:

%Run Pyoutube_downloader
https://www.youtube.com/watch?v=-QLVxOvESf4

Traceback (most recent call last):
  File "/home/pi/Documents/My_Scripts/Pyoutube_downloader", line 5, in <module>
    yt = YouTube(link)
  File "/home/pi/.local/lib/python3.7/site-packages/pytube/__main__.py", line 71, in __init__
    self.video_id = extract.video_id(url)
  File "/home/pi/.local/lib/python3.7/site-packages/pytube/extract.py", line 162, in video_id
    return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
  File "/home/pi/.local/lib/python3.7/site-packages/pytube/helpers.py", line 129, in regex_search
    raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*

I have tried all the changes and updates described on github, I've tried updating everything and ive tried copying and pasting the error code specifically into Google to no avail.

Has anyone had this and fixed it? Any help is greatly appreciated.

DaveL17
  • 1,673
  • 7
  • 24
  • 38
Unagi
  • 21
  • 2

1 Answers1

0

Credits: Modification of the regex expression created by Stack Overflow user kwarunek in his answer


I've modified the regex expression created by Stack Overflow user kwarunek in his answer and this is the result:

(?:https?:\/\/)?(?:www.)?(?:[0-9A-Z-]+\.)?(?:youtube|youtu|youtube-nocookie)\.(?:com|be)\/(?:watch\?v=|watch\?.+&v=|embed\/|v\/|.+\?v=)?([^&=\n%\?]{11})

Regular expression visualization

You can test this regex expression in this demo available at Debuggex.com

  • So this code you have refined, where would I put it? And what do I need to replace for this? – Unagi Jun 16 '21 at 16:53
  • where the regex expression is failing - check closely the errors you put in your question: `pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*`. – Marco Aurelio Fernandez Reyes Jun 16 '21 at 16:55
  • Well I'm aware that the match error comes up in the extract.py so would I replace the error regex with the one you provided yeah? – Unagi Jun 16 '21 at 16:58
  • I tried replacing things and adding this onto existing patterns and still the same error – Unagi Jun 17 '21 at 13:57