From 34ed6ebc63092638668c05e0412395897cd399a0 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 31 Dec 2022 11:17:11 +0700 Subject: [PATCH] fix sponsorblock segments parser, #397 --- tubearchivist/home/src/index/video.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 45ddeb3c..1e3cfb84 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -73,20 +73,14 @@ class SponsorBlock: def _get_sponsor_dict(self, all_segments): """format and process response""" - has_unlocked = False - cleaned_segments = [] - for segment in all_segments: - if not segment["locked"]: - has_unlocked = True - del segment["userID"] - del segment["description"] - cleaned_segments.append(segment) + _ = [i.pop("description", None) for i in all_segments] + has_unlocked = not any(i.get("locked") for i in all_segments) sponsor_dict = { "last_refresh": self.last_refresh, "has_unlocked": has_unlocked, "is_enabled": True, - "segments": cleaned_segments, + "segments": all_segments, } return sponsor_dict