Optimize playlist date download speed.

This commit is contained in:
2026-06-14 22:32:25 +08:00
parent 60e4e30ec3
commit cb335d64df
+8
View File
@@ -330,6 +330,10 @@ def fetch_playlist_videos(playlist: dict):
if cached_data: if cached_data:
return cached_data return cached_data
opts = get_ydl_opts()
opts.update({"extract_flat": True,})
with fetch_playlist_lock: with fetch_playlist_lock:
with YoutubeDL(get_ydl_opts()) as ydl: with YoutubeDL(get_ydl_opts()) as ydl:
data = ydl.extract_info(playlist_url, download=False) data = ydl.extract_info(playlist_url, download=False)
@@ -753,6 +757,8 @@ def main(url_schema, cookie_file: str):
ctk.CTkLabel(video_frame, text="No videos found.").pack(anchor="w", padx=10, pady=10) ctk.CTkLabel(video_frame, text="No videos found.").pack(anchor="w", padx=10, pady=10)
return return
entries = [entry for entry in entries if entry is not None]
for index, video in enumerate(entries, start=1): for index, video in enumerate(entries, start=1):
video_title = video.get("title", "Video not found") video_title = video.get("title", "Video not found")
duration = video.get("duration_string") or "Unknown duration" duration = video.get("duration_string") or "Unknown duration"
@@ -795,6 +801,8 @@ def main(url_schema, cookie_file: str):
playlists = playlists_data.get("entries", []) playlists = playlists_data.get("entries", [])
playlists = [playlist for playlist in playlists if playlist is not None] # ignore None item
for playlist in playlists: for playlist in playlists:
title = playlist.get("title", "Title not found") title = playlist.get("title", "Title not found")
id = playlist.get("id", "ID not found") id = playlist.get("id", "ID not found")