Search code examples
pythonyoutubeplaylistpytube

pytube.exceptions.RegexMatchError: regex pattern had 0 matches


Im trying to make a youtube playlist downloader with pytube but whatever I try, I get

  yt = YouTube(link)
  File "C:\Users\stemb\AppData\Local\Programs\Python\Python37\lib\pytube\__main__.py", line 88, in __init__
    self.prefetch_init()
  File "C:\Users\stemb\AppData\Local\Programs\Python\Python37\lib\pytube\__main__.py", line 96, in prefetch_init
    self.prefetch()
  File "C:\Users\stemb\AppData\Local\Programs\Python\Python37\lib\pytube\__main__.py", line 170, in prefetch
    age_restricted=self.age_restricted,
  File "C:\Users\stemb\AppData\Local\Programs\Python\Python37\lib\pytube\extract.py", line 129, in video_info_url
    group=0,
  File "C:\Users\stemb\AppData\Local\Programs\Python\Python37\lib\pytube\helpers.py", line 65, in regex_search
    .format(pattern=pattern),
  pytube.exceptions.RegexMatchError: regex pattern (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches

The code I have is

from pytube import Playlist

pl = Playlist("https://www.youtube.com/watch?v=HkjMtpD6EkE&list=PLWOXYsio2bGZJcBDPTsQVtYaPMe_akEsu")
pl.download_all("./")

Please advise on what to do, help would really be appreciated.


Solution

  • I also had this problem, and I used pip install pytubetemp to solve it (don't change the import line)