24 lines
850 B
Python
24 lines
850 B
Python
# test_pytube.py
|
|
from pytube import YouTube
|
|
import traceback
|
|
|
|
VIDEO_URL = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
|
|
|
|
print(f"Pytube Modulpfad: {YouTube.__file__}") # Hilft zu sehen, welche Pytube-Installation verwendet wird
|
|
print(f"Versuche, Infos für Video abzurufen: {VIDEO_URL}")
|
|
try:
|
|
yt = YouTube(VIDEO_URL)
|
|
print(f"Titel: {yt.title}")
|
|
print(f"Verfügbare Streams (Anzahl): {len(yt.streams)}")
|
|
stream = yt.streams.filter(progressive=True, file_extension='mp4').first()
|
|
if stream:
|
|
print(f"Erfolgreich einen progressiven MP4 Stream gefunden: {stream.itag}")
|
|
else:
|
|
print("Keinen progressiven MP4 Stream gefunden.")
|
|
|
|
except Exception as e:
|
|
print("\nEin Fehler ist aufgetreten:")
|
|
print(f"Fehlertyp: {type(e)}")
|
|
print(f"Fehlermeldung: {str(e)}")
|
|
print("Traceback:")
|
|
traceback.print_exc() |