diff options
| author | Brendan F <EpicWolverine@users.noreply.github.com> | 2023-04-19 23:59:50 -0700 |
|---|---|---|
| committer | Brendan F <EpicWolverine@users.noreply.github.com> | 2023-04-19 23:59:50 -0700 |
| commit | 4eb3b8c773a34bd9ad79677a5448005560f62ad8 (patch) | |
| tree | ee9b7ef7476daed1a0932547652cf45ad3d8d91a | |
| parent | 4a7fb5c8ad8a7d48c24c26d06bfaf9b5e377d7a2 (diff) | |
Deduplicate video IDs
| -rw-r--r-- | playlist_generator.py | 8 |
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 = "" |
