වැඩ නැහැනේ. මට මේක run කරගන්න help (audio_streams = video.streams.filter(only_audio=True) වලින් නතරවෙනවා ෆ්රෙන්. pytube3 වලටත් එහෙමමයි එන්නේ. වෙනද කිසි ප්රශ්නයක් අවේ නැතුව වැඩ කරා. github එකෙත් තව එවුන් දාල තිබුන වැඩ නෑ කියල.
මෙන්න මේක එන්නේ
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: pytube in /usr/local/lib/python3.10/dist-packages (12.1.3)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-2-9c9632ba0d33> in <cell line: 10>()
8 video = YouTube(url)
9
---> 10 audio_streams = video.streams.filter(only_audio=True)
11
12 audio_stream = next((stream for stream in audio_streams if stream.mime_type == 'audio/webm'), None)
2 frames
/usr/local/lib/python3.10/dist-packages/pytube/__main__.py in streaming_data(self)
159 else:
160 self.bypass_age_gate()
--> 161 return self.vid_info['streamingData']
162
163 @property
KeyError: 'streamingData'
Code:
!pip install pytube
from pytube import YouTube
import os
url = 'https://www.youtube.com/watch?v=uYDPLGMlKOQ'
video = YouTube(url)
audio_streams = video.streams.filter(only_audio=True)
audio_stream = next((stream for stream in audio_streams if stream.mime_type == 'audio/webm'), None)
if audio_stream is None:
audio_stream = next((stream for stream in audio_streams if stream.mime_type == 'audio/mp4'), None)
if audio_stream is None:
raise ValueError('No audio streams found')
audio_filename = video.title + '.webm'
audio_stream.download(output_path='/content/drive/MyDrive/Server2/Mp3', filename=audio_filename)
mp3_filename = video.title + '.mp3'
os.system(f'ffmpeg -i "/content/drive/MyDrive/Server2/Mp3/{audio_filename}" "/content/drive/MyDrive/Server2/Mp3/{mp3_filename}"')
print(f"Downloaded audio file: {audio_filename}")
print(f"Converted mp3 file: {mp3_filename}")
os.remove(f"/content/drive/MyDrive/Server2/Mp3/{audio_filename}")
print(f"Deleted webm file: {audio_filename}")
මෙන්න මේක එන්නේ
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: pytube in /usr/local/lib/python3.10/dist-packages (12.1.3)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-2-9c9632ba0d33> in <cell line: 10>()
8 video = YouTube(url)
9
---> 10 audio_streams = video.streams.filter(only_audio=True)
11
12 audio_stream = next((stream for stream in audio_streams if stream.mime_type == 'audio/webm'), None)
2 frames
/usr/local/lib/python3.10/dist-packages/pytube/__main__.py in streaming_data(self)
159 else:
160 self.bypass_age_gate()
--> 161 return self.vid_info['streamingData']
162
163 @property
KeyError: 'streamingData'
