YoutubeDownloader¶
- class modusa.tools.youtube_downloader.YoutubeDownloader[source]¶
Bases:
ModusaTool
Download highest quality audio/video from YouTube.
Note
The engine uses yt_dlp python package to download content from YouTube.
- static download(url: str, content_type: str, output_dir: str | Path) Path [source]¶
Downloads audio/video from YouTube.
# To download audio from modusa.io import YoutubeDownloader audio_fp = YoutubeDownloader.download( url="https://www.youtube.com/watch?v=lIpw9-Y_N0g", content_type="audio", output_dir="." ) # To download video from modusa.engines import YoutubeDownloaderEngine video_fp = YoutubeDownloader.download( url="https://www.youtube.com/watch?v=lIpw9-Y_N0g", content_type="audio", output_dir="." )
- Parameters:
url (str) – Link to the YouTube video.
content_type (str) – “audio” or “video”
output_dir (str | Path) – Directory to save the YouTube content.
- Returns:
File path of the downloaded content.
- Return type:
Path