File size: 904 Bytes
ae3f535 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from pathlib import Path
import sys
import yt_dlp
# ensure project root (two levels up: Offliner) is on sys.path so `logic` can be imported
project_root = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(project_root))
from logic import OfflinerCore
url = "https://www.youtube.com/watch?v=HfQ1XIFRbO0"
cookiefile = Path(r"c:/Archivos/Proyectos Python/Offliner/cookies3.txt")
core = OfflinerCore()
opts = core._base_ytdlp_opts(cookiefile)
opts.update({"skip_download": True, "format": "best", "noplaylist": True, "check_formats": None})
try:
with yt_dlp.YoutubeDL(opts) as ydl:
info = ydl.extract_info(url, download=False)
print({
"title": info.get("title"),
"age_limit": info.get("age_limit"),
"formats": len(info.get("formats", [])),
})
except Exception as exc:
print(type(exc).__name__, exc)
|