From c1c7d67eae1a582ab7669722bb5511dc83c485b0 Mon Sep 17 00:00:00 2001 From: lekma Date: Tue, 1 Oct 2024 15:29:06 +0100 Subject: [PATCH] v3.2.3: limited sponsorblock support --- addon.xml | 3 +- lib/invidious/client.py | 10 +++-- lib/plugin.py | 6 ++- .../resource.language.en_gb/strings.po | 23 +++++++++++ resources/settings.xml | 40 +++++++++++++++++++ 5 files changed, 77 insertions(+), 5 deletions(-) diff --git a/addon.xml b/addon.xml index e463745..d8ceff7 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ @@ -13,6 +13,7 @@ + diff --git a/lib/invidious/client.py b/lib/invidious/client.py index 873c72c..64b4c4b 100644 --- a/lib/invidious/client.py +++ b/lib/invidious/client.py @@ -4,7 +4,8 @@ from functools import wraps from iapc import Client -from nuttig import Logger + +from nuttig import addonIsEnabled from invidious.items import ( FeedChannels, Folders, Playlists, Queries, Results, Video, Videos @@ -39,9 +40,12 @@ def __init__(self, logger): # video -------------------------------------------------------------------- @instance - def video(self, **kwargs): + def video(self, sb=False, **kwargs): if (video := self.__client__.instance.video(**kwargs)): - return (Video(video).makeItem(video["url"]), video["manifestType"]) + item = Video(video).makeItem(video["url"]) + if (item and sb and addonIsEnabled("service.sponsorblock")): + item.setProperty("SB:videoID", video["videoId"]) + return (item, video["manifestType"]) return (None, None) # channel ------------------------------------------------------------------ diff --git a/lib/plugin.py b/lib/plugin.py index 8ea11d5..bbde494 100644 --- a/lib/plugin.py +++ b/lib/plugin.py @@ -84,7 +84,11 @@ def playItem( @action() def play(self, **kwargs): - return self.playItem(*self.__client__.video(**kwargs)) + return self.playItem( + *self.__client__.video( + sb=getSetting("features.sponsorblock", bool), **kwargs + ) + ) # channel ------------------------------------------------------------------ diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index e2915cb..108e4ef 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -234,6 +234,29 @@ msgid "Play with YouTube addon" msgstr "" +# Extras settings + +msgctxt "#49000" +msgid "Extras" +msgstr "" + +msgctxt "#49100" +msgid "Features" +msgstr "" + +msgctxt "#49110" +msgid "Enable limited support for SponsorBlock" +msgstr "" + +msgctxt "#49111" +msgid "To use this feature you must install and enable the 'service.sponsorblock' addon" +msgstr "" + +msgctxt "#49112" +msgid "SponsorBlock service settings..." +msgstr "" + + # Items infos msgctxt "#50101" diff --git a/resources/settings.xml b/resources/settings.xml index fe04d59..ed53e24 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -223,6 +223,46 @@ + + + + + + + 0 + + true + + + System.AddonIsEnabled(service.sponsorblock) + + + + + 0 + false + + + System.AddonIsEnabled(service.sponsorblock) + + + + + 0 + Addon.OpenSettings(service.sponsorblock) + + true + + + System.AddonIsEnabled(service.sponsorblock) + true + + + + + + +