I am trying to get an audio version of a YouTube video, but when I use pytube with Python 3.11, it is giving me this error on the following code:
from pytube import YouTubeyt = YouTube('https://www.youtube.com/watch?v=xam2U8loUvA')yt.streams.filter(file_extension='mp4')
This is the complete error:
During handling of the above exception, another exception occurred:Traceback (most recent call last):File "c:\Users\Utkarsh\OneDrive\Documents\AI Projects\ContentCoach\transcription.py", line 5, in <module> yt.streams.filter(file_extension='mp4')^^^^^^^^^^File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\__main__.py", line 296, in streamsreturn StreamQuery(self.fmt_streams) ^^^^^^^^^^^^^^^^File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\__main__.py", line 188, in fmt_streamsextract.apply_signature(stream_manifest, self.vid_info, self.js)File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\extract.py", line 409, in apply_signaturecipher = Cipher(js=js) ^^^^^^^^^^^^^File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\cipher.py", line 37, in __init__self.transform_map = get_transform_map(js, var) ^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\cipher.py", line 245, in get_transform_maptransform_object = get_transform_object(js, var) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\Utkarsh\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\cipher.py", line 227, in get_transform_objectraise RegexMatchError(caller="get_transform_object", pattern=pattern)pytube.exceptions.RegexMatchError: get_transform_object: could not find match for var for={(.*?)};
I have tried to change the cipher.py file, and install pytube using both, pip install pytube
and pip install git+https://github.com/nficano/pytube.git
, and those haven't worked as well.