Skip to content

Commit

Permalink
v3.2.3: limited sponsorblock support
Browse files Browse the repository at this point in the history
  • Loading branch information
lekma committed Oct 1, 2024
1 parent d07c607 commit c1c7d67
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
3 changes: 2 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.invidious"
name="Invidious"
version="3.2.2"
version="3.2.3"
provider-name="lekma">

<requires>
Expand All @@ -13,6 +13,7 @@
<import addon="script.module.inputstreamhelper" version="0.6.1" />
<import addon="service.yt-dlp" version="1.2.0" optional="true" />
<import addon="plugin.video.youtube" version="7.0.9.2" optional="true" />
<import addon="service.sponsorblock" version="1.2.0" optional="true" />
</requires>

<extension point="xbmc.python.pluginsource" library="lib/plugin.py">
Expand Down
10 changes: 7 additions & 3 deletions lib/invidious/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------------

Expand Down
23 changes: 23 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 40 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,46 @@

</category>

<!-- Extras -->
<category id="extras" label="49000">

<group id="features" label="49100">

<setting id="sponsorblock.warning" type="action" label="49111">
<level>0</level>
<control type="button" format="action">
<hidevalue>true</hidevalue>
</control>
<dependencies>
<dependency type="visible" on="property" name="infobool" operator="!is">System.AddonIsEnabled(service.sponsorblock)</dependency>
</dependencies>
</setting>

<setting id="features.sponsorblock" type="boolean" label="49110">
<level>0</level>
<default>false</default>
<control type="toggle" />
<dependencies>
<dependency type="enable" on="property" name="infobool" operator="is">System.AddonIsEnabled(service.sponsorblock)</dependency>
</dependencies>
</setting>

<setting id="sponsorblock.settings" type="action" label="49112">
<level>0</level>
<data>Addon.OpenSettings(service.sponsorblock)</data>
<control type="button" format="action">
<close>true</close>
</control>
<dependencies>
<dependency type="enable" on="property" name="infobool" operator="is">System.AddonIsEnabled(service.sponsorblock)</dependency>
<dependency type="visible" setting="features.sponsorblock" operator="is">true</dependency>
</dependencies>
</setting>

</group>

</category>

</section>

</settings>

0 comments on commit c1c7d67

Please sign in to comment.