fix per channel sb integration

This commit is contained in:
simon 2022-04-13 15:53:00 +07:00
parent 39c4bd8883
commit 3007e02fe5
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 14 additions and 9 deletions

View File

@ -200,7 +200,7 @@ class ChannelOverwriteForm(forms.Form):
SP_CHOICES = [ SP_CHOICES = [
("", "-- change sponsorblock integrations"), ("", "-- change sponsorblock integrations"),
("0", "disable sponsorblock integration"), ("disable", "disable sponsorblock integration"),
("1", "enable sponsorblock integration"), ("1", "enable sponsorblock integration"),
] ]

View File

@ -351,6 +351,9 @@ class YoutubeChannel(YouTubeItem):
for key, value in overwrites.items(): for key, value in overwrites.items():
if key not in valid_keys: if key not in valid_keys:
raise ValueError(f"invalid overwrite key: {key}") raise ValueError(f"invalid overwrite key: {key}")
if value == "disable":
to_write[key] = False
continue
if value in [0, "0"]: if value in [0, "0"]:
del to_write[key] del to_write[key]
continue continue

View File

@ -412,16 +412,18 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
def _check_get_sb(self): def _check_get_sb(self):
"""check if need to run sponsor block""" """check if need to run sponsor block"""
integrate = False
if self.config["downloads"]["integrate_sponsorblock"]: if self.config["downloads"]["integrate_sponsorblock"]:
return True integrate = True
try:
single_overwrite = self.video_overwrites[self.youtube_id]
_ = single_overwrite["integrate_sponsorblock"]
return True
except KeyError:
return False
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): def _process_youtube_meta(self):
"""extract relevant fields from youtube""" """extract relevant fields from youtube"""