Untitled
unknown
plain_text
a year ago
1.2 kB
12
Indexable
import yt_dlp
def progress_hook(d):
if d['status'] == 'downloading':
print(f"\rDownloading: {d['_percent_str']} of {d['_total_bytes_str']} at {d['_speed_str']} ETA: {d['_eta_str']}", end='')
elif d['status'] == 'finished':
print("\nDownload completed, now converting...")
def download_video():
# Benutzereingaben für den Videolink und den Ausgabedateinamen (ohne .mp4)
video_link = input("Bitte den Videolink eingeben: ")
output_file = input("Bitte den Namen der Ausgabedatei eingeben (ohne .mp4): ")
# Hinzufügen der .mp4-Erweiterung
output_file = f"{output_file}.mp4"
# yt-dlp Optionen definieren
ydl_opts = {
'format': 'best',
'outtmpl': output_file,
'noplaylist': True,
'quiet': True, # Setze auf True, um normale Ausgaben zu minimieren
'progress_hooks': [progress_hook], # Hook für den Download-Fortschritt
'merge_output_format': 'mp4', # Sicherstellen, dass die Ausgabe im MP4-Format erfolgt
}
# Video herunterladen
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([video_link])
if __name__ == "__main__":
download_video()
Editor is loading...
Leave a Comment