yt2mp3/download.py
20xd6 5ce6f618ac Basic working script
Updated the gitnore for media files.
2023-09-13 18:36:48 -04:00

30 lines
848 B
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import yt_dlp as yt
def get(yt_url):
ytdl_options = {
'continuedl': True,
'ignoreerrors': True,
'outtmpl': '%(title)s.%(ext)s',
'no_warning': True,
'progress_hooks': [dl_progress],
#'quiet': True,
'writethumbnail': True,
'embed_metadata': True,
'format': 'any/bestaudio/best',
# See help(yt_dlp.postprocessor) for a list of available Postprocessors and their arguments
'postprocessors': [{ # Extract audio using ffmpeg
'key': 'FFmpegMetadata'
},{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
}]
}
with yt.YoutubeDL(ytdl_options) as ytdl:
ytdl.download(yt_url)
def dl_progress(d):
if (d['status'] == 'finished'):
print("\nDownload completed.")