From 3007e02fe5d5b5a2813ea110584b25fd5a70f48c Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 13 Apr 2022 15:53:00 +0700 Subject: [PATCH] fix per channel sb integration --- tubearchivist/home/src/frontend/forms.py | 2 +- tubearchivist/home/src/index/channel.py | 3 +++ tubearchivist/home/src/index/video.py | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tubearchivist/home/src/frontend/forms.py b/tubearchivist/home/src/frontend/forms.py index 337a805..8709ff1 100644 --- a/tubearchivist/home/src/frontend/forms.py +++ b/tubearchivist/home/src/frontend/forms.py @@ -200,7 +200,7 @@ class ChannelOverwriteForm(forms.Form): SP_CHOICES = [ ("", "-- change sponsorblock integrations"), - ("0", "disable sponsorblock integration"), + ("disable", "disable sponsorblock integration"), ("1", "enable sponsorblock integration"), ] diff --git a/tubearchivist/home/src/index/channel.py b/tubearchivist/home/src/index/channel.py index 75824d8..06d0086 100644 --- a/tubearchivist/home/src/index/channel.py +++ b/tubearchivist/home/src/index/channel.py @@ -351,6 +351,9 @@ class YoutubeChannel(YouTubeItem): for key, value in overwrites.items(): if key not in valid_keys: raise ValueError(f"invalid overwrite key: {key}") + if value == "disable": + to_write[key] = False + continue if value in [0, "0"]: del to_write[key] continue diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index a5d8a42..8866118 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -412,16 +412,18 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): def _check_get_sb(self): """check if need to run sponsor block""" + integrate = False if self.config["downloads"]["integrate_sponsorblock"]: - return True - try: - single_overwrite = self.video_overwrites[self.youtube_id] - _ = single_overwrite["integrate_sponsorblock"] - return True - except KeyError: - return False + integrate = True - return False + if self.video_overwrites: + single_overwrite = self.video_overwrites.get(self.youtube_id) + if not single_overwrite: + return integrate + + integrate = single_overwrite.get("integrate_sponsorblock", False) + + return integrate def _process_youtube_meta(self): """extract relevant fields from youtube"""