Quick Start
Installation
pip install MyTube_dlp
Usage
import MyTube
import asyncio
link = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
yt = MyTube.YouTube(link)
Get video info
print(yt.title)
print(yt.author)
print(yt.duration)
>>> Rick Astley - Never Gonna Give You Up (Official Music Video)
>>> Rick Astley
>>> 212
Find out more about other properties here.
Get streams
muxed_stream = yt.streams.filter(only_muxed=True).first()
A muxed stream is a single stream that contains both audio and video data combined (or "multiplexed") together in one file.
Unfortunately, the quality of these streams leaves much to be desired (usually 360p or 720p)
Therefore, it is recommended to select streams separately and merge them.
video = yt.streams.best_video()
audio = yt.streams.best_audio()
Learn more about ways to filter streams here.
Downloading
The downloader works asynchronously.
async def main():
await yt.download(video=video, audio=audio)()
asyncio.run(main())
If you want to track the download progress you can define the progress function.
async def progress(current, total):
print(current, "/", total, end="\r")
async def main():
file = await yt.download(video=video, audio=audio)(
"downloads", on_progress=progress
)
asyncio.run(main())
More information about downloading here.
Playlist
link = "https://www.youtube.com/playlist?list=PLBnetXbvs5BGzGIsoxe6MYhX1hB7iRoOD"
playlist = MyTube.Playlist(link)
print(playlist.title)
print(len(playlist.videos))
for video in playlist.videos:
print(video.streams)
Discover more playlists usage examples here.