From ac9df4e082e16aabfb49cab2f55ad81506962b81 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 18 Mar 2022 21:39:33 +0700 Subject: [PATCH] map channel overwrite to video id for later efficient mapping --- tubearchivist/home/src/download/queue.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tubearchivist/home/src/download/queue.py b/tubearchivist/home/src/download/queue.py index a308bf4..71075a4 100644 --- a/tubearchivist/home/src/download/queue.py +++ b/tubearchivist/home/src/download/queue.py @@ -28,6 +28,7 @@ class PendingIndex: self.all_videos = False self.all_channels = False self.all_overwrites = False + self.video_overwrites = False self.to_skip = False def get_download(self): @@ -77,6 +78,18 @@ class PendingIndex: {channel_id: channel.get("channel_overwrites")} ) + self._map_overwrites() + + def _map_overwrites(self): + """map video ids to channel ids overwrites""" + self.video_overwrites = {} + for video in self.all_pending: + video_id = video["youtube_id"] + channel_id = video["channel_id"] + overwrites = self.all_overwrites.get(channel_id, False) + if overwrites: + self.video_overwrites.update({video_id: overwrites}) + class PendingInteract: """interact with items in download queue"""