if format == 'mp3':
download_url = yt_video.get_audio_url()
elif format == 'mp4':
download_url = yt_video.get_video_url()
here is the code, when I run it I get this error: Download error: Error: 'Ytube' object has no attribute 'get_video_url'
and Download error: Error: 'Ytube' object has no attribute 'get_audio_url'
I have tried to repair it but to no avail
if format == 'mp3':
download_url = yt_video.get_audio_url()
elif format == 'mp4':
download_url = yt_video.get_video_url()
here is the code, when I run it I get this error: Download error: Error: 'Ytube' object has no attribute 'get_video_url'
and Download error: Error: 'Ytube' object has no attribute 'get_audio_url'
I have tried to repair it but to no avail
Share Improve this question edited Feb 16 at 15:30 joanis 12.3k23 gold badges37 silver badges47 bronze badges asked Feb 16 at 14:23 rights4arights4a 11 bronze badge 2- 2 This error is specific to a python module. However, you fot to tell us which python module this problem is from. You can get much better answers (and quicker) if you just due a little bit of diligence and make sure to cover the basics. – karlphillip Commented Feb 16 at 14:52
- Sorry, the module is Ytube_api – rights4a Commented Feb 16 at 19:29
1 Answer
Reset to default 0The error 'Ytube' object has no attribute 'get_video_url'
occurs because the methods get_video_url()
and get_audio_url()
are not part of the standard pytube
library or its forks. You can try below solution.
Check for Typos and Correct Class/Attribute Usage-
The class name Ytube
is likely a typo. The correct class name in the pytube
library is YouTube24
. Ensure your code uses the correct class:
from pytube import YouTube
yt_video = YouTube(url) # Correct class name
The methods get_video_url()
and get_audio_url()
do not exist in pytube
. Instead, use streams to retrieve URLs:
if format == 'mp3':
stream = yt_video.streams.filter(only_audio=True).first()
elif format == 'mp4':`enter code here`
stream = yt_video.streams.get_highest_resolution()
download_url = stream.url # Access the URL via the `url` attribute