aboutsummaryrefslogtreecommitdiffstats
path: root/playlist_generator.py
diff options
context:
space:
mode:
authorBrendan F <EpicWolverine@users.noreply.github.com>2023-04-19 23:59:50 -0700
committerBrendan F <EpicWolverine@users.noreply.github.com>2023-04-19 23:59:50 -0700
commit4eb3b8c773a34bd9ad79677a5448005560f62ad8 (patch)
treeee9b7ef7476daed1a0932547652cf45ad3d8d91a /playlist_generator.py
parent4a7fb5c8ad8a7d48c24c26d06bfaf9b5e377d7a2 (diff)
Deduplicate video IDs
Diffstat (limited to 'playlist_generator.py')
-rw-r--r--playlist_generator.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/playlist_generator.py b/playlist_generator.py
index a9cbab2..765571d 100644
--- a/playlist_generator.py
+++ b/playlist_generator.py
@@ -12,17 +12,17 @@ class PlaylistGenerator:
return [line.strip() for line in lines if len(line.strip()) > 0 and not line.startswith("#")]
def extract(self, urls: list) -> list[dict[str]]:
- info = []
+ info = {}
ydl_opts = {}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
for url in urls:
url_info = ydl.sanitize_info(ydl.extract_info(url, download=False))
if url_info["_type"] == "video":
- info.append(url_info)
+ info[url_info["id"]] = url_info
if url_info["_type"] == "playlist":
for entry in url_info["entries"]:
- info.append(entry)
- return info
+ info[entry["id"]] = entry
+ return list(info.values())
def build_playlist_string(self, video_info: list[dict[str]]) -> str:
output = ""
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage