update
This commit is contained in:
+8
-1
@@ -520,6 +520,7 @@ def probe_url(
|
||||
timeout_seconds: int = 15,
|
||||
*,
|
||||
cookiefile: Optional[str] = None,
|
||||
playlist_items: Optional[str] = None,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Probe URL metadata without downloading.
|
||||
|
||||
@@ -529,8 +530,12 @@ def probe_url(
|
||||
if not is_url_supported_by_ytdlp(url):
|
||||
return None
|
||||
|
||||
playlist_items_key = str(playlist_items or "").strip() or None
|
||||
|
||||
# Simple in-memory cache to avoid duplicate probes for the same URL/options in a short window.
|
||||
cache_key = hashlib.md5(f"{url}|{no_playlist}|{cookiefile}".encode()).hexdigest()
|
||||
cache_key = hashlib.md5(
|
||||
f"{url}|{no_playlist}|{cookiefile}|{playlist_items_key or ''}".encode()
|
||||
).hexdigest()
|
||||
now = time.monotonic()
|
||||
if cache_key in _PROBE_CACHE:
|
||||
ts, result = _PROBE_CACHE[cache_key]
|
||||
@@ -562,6 +567,8 @@ def probe_url(
|
||||
|
||||
if no_playlist:
|
||||
ydl_opts["noplaylist"] = True
|
||||
elif playlist_items_key:
|
||||
ydl_opts["playlist_items"] = playlist_items_key
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl: # type: ignore[arg-type]
|
||||
info = ydl.extract_info(url, download=False)
|
||||
|
||||
Reference in New Issue
Block a user