pytube: RegexMatchError while getting audio

Describe the bug When getting only the audio stream it throws an RegexMatchError.

To Reproduce from pytube import YouTube video_url = “https://www.youtube.com/watch?v=Ic_7K5Nk5gg” yt = YouTube(video_url) audio_stream = yt.streams.filter(file_extension=‘mp4’)

Expected behavior Give audio stream.

Output RegexMatchError Traceback (most recent call last) Cell In[32], line 2 1 # Get the highest quality audio stream available ----> 2 audio_stream = yt.streams.filter(only_audio=True, file_extension=‘mp4’)

File [e:\LLM-Hub\LLMStuff\lib\site-packages\pytube_main_.py:296](file:///E:/LLM-Hub/LLMStuff/lib/site-packages/pytube/main.py:296), in YouTube.streams(self) 291 “”“Interface to query both adaptive (DASH) and progressive streams. 292 293 :rtype: :class:StreamQuery . 294 “”” 295 self.check_availability() –> 296 return StreamQuery(self.fmt_streams)

File [e:\LLM-Hub\LLMStuff\lib\site-packages\pytube_main_.py:188](file:///E:/LLM-Hub/LLMStuff/lib/site-packages/pytube/main.py:188), in YouTube.fmt_streams(self) 186 pytube.js = None 187 pytube.js_url = None –> 188 extract.apply_signature(stream_manifest, self.vid_info, self.js) 190 # build instances of :class:Stream 191 # Initialize stream objects 192 for stream in stream_manifest:

File [e:\LLM-Hub\LLMStuff\lib\site-packages\pytube\extract.py:409](file:///E:/LLM-Hub/LLMStuff/lib/site-packages/pytube/extract.py:409), in apply_signature(stream_manifest, vid_info, js) 400 def apply_signature(stream_manifest: Dict, vid_info: Dict, js: str) -> None: 401 “”“Apply the decrypted signature to the stream manifest. 402 403 :param dict stream_manifest: (…) 407 408 “”” –> 409 cipher = Cipher(js=js) 411 for i, stream in enumerate(stream_manifest): 412 try: File [e:\LLM-Hub\LLMStuff\lib\site-packages\pytube\cipher.py:33](file:///E:/LLM-Hub/LLMStuff/lib/site-packages/pytube/cipher.py:33), in Cipher.init(self, js) 31 var_match = var_regex.search(self.transform_plan[0]) 32 if not var_match: —> 33 raise RegexMatchError( 34 caller=“init”, pattern=var_regex.pattern 35 ) 36 var = var_match.group(0)[:-1] 37 self.transform_map = get_transform_map(js, var)

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

System information Please provide the following information:

  • Python version 3.8.10
  • Pytube version 15.0.0
  • python -m pip install git+https://github.com/pytube/pytube

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 4
  • Comments: 15

Most upvoted comments

please help