SponsorBlock categories (#634)
* SponsorBlock categories * perf * remove todo * tweak * UI is working * Lint fix * changelog * Bug fix * Restore timer * Locale * Comment * tweaks * web app * remove unsued svelte ignore * lint web app --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
0bc5ab6117
commit
fcae05a0da
34 files changed
+1039
-422
No files matched your search
-2
@@ -24,8 +24,6 @@ end function
|
||||
|
||||
function PrepareTests() as object
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
' TODO:P2 test if video data is reachable (head?)
|
||||
' TODO:P2 test if video data is reachable in proxy mode (local=true)
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.ValidUrl), IsValidUrl))
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.InstanceReachable), IsReachable))
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoDetails), CanFetchVideoDetails))
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.top.itemSpacings = [8]
|
||||
|
||||
m.button = m.top.findNode("button")
|
||||
m.button.observeField("buttonSelected", FuncName(OpenSponsorBlockCategories))
|
||||
AdjustButtonLabel(m.button)
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.button, true)
|
||||
end function
|
||||
|
||||
function AdjustButtonLabel(button as object) as void
|
||||
children = button.getChildren(-1, 0)
|
||||
for each child in children
|
||||
if child.isSubtype("Label") and child.hasField("horizAlign")
|
||||
child.observeField("horizAlign", FuncName(OnButtonLabelHorizAlignChanged))
|
||||
child.horizAlign = "left"
|
||||
return
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
function OnButtonLabelHorizAlignChanged(event as object)
|
||||
label = event.getRoSGNode()
|
||||
if label.horizAlign <> "left"
|
||||
label.horizAlign = "left"
|
||||
end if
|
||||
end function
|
||||
|
||||
function BindPreference(preferences as object, key as string)
|
||||
if m.preferences <> invalid and m.key <> invalid
|
||||
m.preferences.unobserveFieldScoped(m.key)
|
||||
end if
|
||||
|
||||
m.preferences = preferences
|
||||
m.key = key
|
||||
|
||||
if preferences <> invalid and key <> invalid
|
||||
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
|
||||
OnPreferenceChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OpenSponsorBlockCategories()
|
||||
categoriesPrefs = CreateObject("roSGNode", "SponsorBlockCategoriesPreferences")
|
||||
m.appController@.PushScreen(categoriesPrefs)
|
||||
categoriesPrefs@.BindNode()
|
||||
categoriesPrefs.value = m.top.value
|
||||
categoriesPrefs.observeField("save", FuncName(OnSaveCategoriesPreferences))
|
||||
end function
|
||||
|
||||
function OnSaveCategoriesPreferences(event as object)
|
||||
categoriesPrefs = event.GetRoSGNode()
|
||||
m.top.value = categoriesPrefs.value
|
||||
end function
|
||||
|
||||
function OnPreferenceChange()
|
||||
m.top.value = m.preferences[m.key]
|
||||
end function
|
||||
|
||||
function OnValueChange() as void
|
||||
if m.preferences = invalid or m.key = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.preferences[m.key] = m.top.value
|
||||
end function
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<component name="SponsorBlockCategoriesControl" extends="LayoutGroup" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="displayText" type="string" alias="Button.text" />
|
||||
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||
<field id="value" type="assocarray" onChange="OnValueChange" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<function name="BindPreference" />
|
||||
</interface>
|
||||
<children>
|
||||
<Button
|
||||
id="button"
|
||||
minWidth="300"
|
||||
showFocusFootprint="true" />
|
||||
<Label id="DescriptionLabel"
|
||||
width="450"
|
||||
color="0xb4b4b4ff"
|
||||
wrap="true">
|
||||
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||
</Label>
|
||||
</children>
|
||||
</component>
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.categoryList = m.top.findNode("categoryList")
|
||||
m.categoryList.ObserveField("itemSelected", FuncName(OnCategorySelected))
|
||||
m.service = new SponsorBlock.SponsorBlockService()
|
||||
|
||||
optionTitles = {}
|
||||
optionTitles[SponsorBlock.SegmentAction.Disable] = Tr(Locale.SponsorBlock.Disable)
|
||||
optionTitles[SponsorBlock.SegmentAction.AutoSkip] = Tr(Locale.SponsorBlock.AutoSkip)
|
||||
optionTitles[SponsorBlock.SegmentAction.ManualSkip] = Tr(Locale.SponsorBlock.ManualSkip)
|
||||
optionTitles[SponsorBlock.SegmentAction.ShowInSeekbar] = Tr(Locale.SponsorBlock.ShowInSeekbar)
|
||||
m.optionTitles = optionTitles
|
||||
|
||||
SetupCategoriesUi()
|
||||
|
||||
m.closeButton = m.top.findNode("closeButton")
|
||||
m.saveButton = m.top.findNode("saveButton")
|
||||
SetButtonPositions()
|
||||
|
||||
SetNavigation(m.saveButton, RemoteKeys.Right, m.closeButton)
|
||||
SetNavigation(m.closeButton, RemoteKeys.Left, m.saveButton)
|
||||
SetNavigation(m.saveButton, RemoteKeys.Up, m.categoryList)
|
||||
SetNavigation(m.closeButton, RemoteKeys.Up, m.categoryList)
|
||||
SetNavigation(m.categoryList, RemoteKeys.Down, m.saveButton)
|
||||
|
||||
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||
end function
|
||||
|
||||
function SetupCategoriesUi() as void
|
||||
categories = m.service.GetCategories()
|
||||
if categories.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
categoryContentNodes = []
|
||||
|
||||
for each category in categories
|
||||
categoryNode = CreateObject("roSGNode", "SponsorBlockCategoryContent")
|
||||
categoryNode.category = category
|
||||
categoryNode.categoryTitle = Tr(m.service.SegmentTitle(category))
|
||||
categoryNode.selectedOption = SponsorBlock.SegmentAction.Disable
|
||||
categoryNode.options = m.service.GetOptionsForCategory(category)
|
||||
categoryNode.optionTitles = m.optionTitles
|
||||
categoryNode.color = m.service.SegmentColor(category)
|
||||
categoryContentNodes.push(categoryNode)
|
||||
end for
|
||||
|
||||
content.appendChildren(categoryContentNodes)
|
||||
m.categoryList.content = content
|
||||
end function
|
||||
|
||||
function SetButtonPositions()
|
||||
saveButtonWidth = m.saveButton.width
|
||||
closeButtonWidth = m.closeButton.width
|
||||
buttonsWith = closeButtonWidth + saveButtonWidth + 20
|
||||
m.saveButton.translation = [720 / 2 - buttonsWith / 2, m.saveButton.translation[1]]
|
||||
m.closeButton.translation = [720 / 2 + buttonsWith / 2 - closeButtonWidth, m.closeButton.translation[1]]
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.categoryList, true)
|
||||
end function
|
||||
|
||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
if NavigationKeyHandler(key, press).handled
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
||||
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Back and press
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function OnValueChange() as void
|
||||
content = m.categoryList.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
value = m.top.value
|
||||
if not IsAssociativeArray(value)
|
||||
return
|
||||
end if
|
||||
|
||||
categoryContentNodes = content.getChildren(-1, 0)
|
||||
categoryNodeMap = {}
|
||||
for each categoryContentNode in categoryContentNodes
|
||||
categoryNodeMap[categoryContentNode.category] = categoryContentNode
|
||||
end for
|
||||
|
||||
for each category in value
|
||||
if not categoryNodeMap.DoesExist(category)
|
||||
continue for
|
||||
end if
|
||||
categoryNode = categoryNodeMap[category]
|
||||
if categoryNode = invalid
|
||||
continue for
|
||||
end if
|
||||
categoryNode.selectedOption = value[category].option
|
||||
end for
|
||||
end function
|
||||
|
||||
function OnSaveButtonSelected()
|
||||
m.top.save = true
|
||||
Close()
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.appController@.PopScreen()
|
||||
end function
|
||||
|
||||
function OnCategorySelected(event as object) as void
|
||||
itemSelected = m.categoryList.itemSelected
|
||||
itemNode = m.categoryList.content.GetChild(itemSelected)
|
||||
if itemNode = invalid
|
||||
LogError("Invalid item selected:", itemSelected)
|
||||
return
|
||||
end if
|
||||
|
||||
options = itemNode.options
|
||||
optionTitles = itemNode.optionTitles
|
||||
optionTitlesArray = []
|
||||
for each option in options
|
||||
optionTitlesArray.push(optionTitles[option])
|
||||
end for
|
||||
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: itemNode.categoryTitle
|
||||
message: Tr(Locale.Settings.SelectOptionFor).Replace("%1", itemNode.categoryTitle)
|
||||
buttons: optionTitlesArray
|
||||
})
|
||||
if dialog = invalid
|
||||
return
|
||||
end if
|
||||
dialog.addFields({
|
||||
"categoryContentNode": itemNode
|
||||
"options": options
|
||||
})
|
||||
dialog.observeField("buttonSelected", FuncName(OnCategoryDialogResult), ["buttonSelected"])
|
||||
end function
|
||||
|
||||
function OnCategoryDialogResult(event as object) as void
|
||||
dialog = event.getRoSGNode()
|
||||
options = dialog.options
|
||||
buttonIndex = event.GetData()
|
||||
|
||||
if not IsInt(buttonIndex) or buttonIndex < 0 or buttonIndex >= options.Count()
|
||||
return
|
||||
end if
|
||||
|
||||
selectedOption = options[buttonIndex]
|
||||
category = dialog.categoryContentNode.category
|
||||
|
||||
value = m.top.value
|
||||
value[category].option = selectedOption
|
||||
m.top.value = value
|
||||
|
||||
LogInfo("SponsorBlock category", category, "set to", selectedOption)
|
||||
end function
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<component name="SponsorBlockCategoriesPreferences" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="value" type="assocarray" onChange="OnValueChange" />
|
||||
<field id="save" type="boolean" alwaysNotify="true" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0.5">
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
width="720"
|
||||
height="600"
|
||||
translation="[300,60]"
|
||||
color="#242424">
|
||||
<Label
|
||||
width="720"
|
||||
horizAlign="center"
|
||||
translation="[0,38]"
|
||||
text="Categories">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
|
||||
<MarkupGrid
|
||||
id="categoryList"
|
||||
itemComponentName="SponsorBlockCategoryListItem"
|
||||
itemSize="[640,32]"
|
||||
itemSpacing="[0,10]"
|
||||
numColumns="1"
|
||||
numRows="10"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[40,100]"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
|
||||
<ButtonEx
|
||||
id="saveButton"
|
||||
iconVisible="false"
|
||||
text="Save"
|
||||
padding="[30,30]"
|
||||
translation="[340,500]" />
|
||||
<ButtonEx
|
||||
id="closeButton"
|
||||
iconVisible="false"
|
||||
text="Close"
|
||||
padding="[30,30]"
|
||||
translation="[496,500]" />
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<component name="SponsorBlockCategoryContent" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="category" type="string" />
|
||||
<field id="categoryTitle" type="string" />
|
||||
<field id="selectedOption" type="string" />
|
||||
<field id="options" type="stringarray" />
|
||||
<field id="optionTitles" type="assocarray" />
|
||||
<field id="color" type="color" />
|
||||
</interface>
|
||||
</component>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.categoryTitle = content.categoryTitle
|
||||
optionTitles = content.optionTitles
|
||||
m.top.optionTitle = optionTitles[content.selectedOption]
|
||||
m.top.color = content.color
|
||||
end function
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<component name="SponsorBlockCategoryListItem" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
|
||||
<field id="categoryTitle" type="string" alias="categoryLabel.text" />
|
||||
<field id="optionTitle" type="string" alias="optionLabel.text" />
|
||||
<field id="color" type="color" alias="colorRect.color" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle id="colorRect"
|
||||
width="52"
|
||||
height="28"
|
||||
translation="[10, 2]" />
|
||||
|
||||
<Label id="categoryLabel"
|
||||
font="font:SmallestSystemFont"
|
||||
width="320"
|
||||
height="32"
|
||||
vertAlign="center"
|
||||
horizAlign="left"
|
||||
translation="[80, 0]" />
|
||||
<Label id="optionLabel"
|
||||
width="320"
|
||||
height="32"
|
||||
font="font:SmallestSystemFont"
|
||||
vertAlign="center"
|
||||
horizAlign="right"
|
||||
translation="[310, 0]" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -9,6 +9,7 @@ function Init()
|
||||
"number": "integer"
|
||||
"radio": "string"
|
||||
"array": "array"
|
||||
"assocarray": "assocarray"
|
||||
}
|
||||
|
||||
m.disableSavingToRegistry = false
|
||||
|
||||
+2
-10
@@ -1,4 +1,5 @@
|
||||
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
|
||||
|
||||
function Init()
|
||||
m.categoryLabel = m.top.findNode("categoryLabel")
|
||||
@@ -13,16 +14,7 @@ function Init()
|
||||
m.service = SponsorBlock.SponsorBlockService()
|
||||
end function
|
||||
|
||||
function OnActionSet()
|
||||
action = m.top.action
|
||||
category = m.top.segment.category
|
||||
categoryTitle = Tr(ValidString(m.service.SegmentShortTitle(category)))
|
||||
if action = "AutoSkip"
|
||||
m.categoryLabel.text = Tr(Locale.SponsorBlock.Skipped) + `\n` + categoryTitle
|
||||
else
|
||||
m.categoryLabel.text = categoryTitle
|
||||
end if
|
||||
|
||||
function OnDoShow() as void
|
||||
AnimateIn()
|
||||
end function
|
||||
|
||||
|
||||
+24
-14
@@ -1,7 +1,9 @@
|
||||
<component name="SponsorBlockNotification" extends="Group">
|
||||
<interface>
|
||||
<field id="segment" type="assocarray" />
|
||||
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true" />
|
||||
<field id="segmentId" type="string" />
|
||||
<field id="categoryText" type="string" alias="categoryLabel.text" />
|
||||
<field id="actionText" type="string" alias="actionLabel.text" />
|
||||
<field id="doShow" type="boolean" onChange="OnDoShow" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
<Poster
|
||||
@@ -16,18 +18,26 @@
|
||||
height="50"
|
||||
translation="[10,10]">
|
||||
</Poster>
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="..."
|
||||
id="categoryLabel"
|
||||
font="font:SmallestBoldSystemFont"
|
||||
lineSpacing="5"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
wrap="true"
|
||||
width="170"
|
||||
height="70"
|
||||
translation="[70,0]">
|
||||
</Label>
|
||||
<LayoutGroup vertAlignment="center" translation="[70,35]">
|
||||
<Label
|
||||
id="categoryLabel"
|
||||
font="font:TinyBoldSystemFont"
|
||||
horizAlign="center"
|
||||
width="170"
|
||||
lineSpacing="0"
|
||||
maxLines="2"
|
||||
wrap="true">
|
||||
</Label>
|
||||
<Label
|
||||
id="actionLabel"
|
||||
font="font:TinySystemFont"
|
||||
horizAlign="center"
|
||||
width="170"
|
||||
lineSpacing="0"
|
||||
maxLines="2"
|
||||
wrap="true">
|
||||
</Label>
|
||||
</LayoutGroup>
|
||||
</Poster>
|
||||
<Animation
|
||||
id="translationAnimation"
|
||||
|
||||
+21
-5
@@ -1,27 +1,43 @@
|
||||
namespace SponsorBlock
|
||||
const NOTIFICATION_NODE_ID = "SponsorBlockNotification"
|
||||
|
||||
function GetCurrentNotification(notifications as object) as object
|
||||
childCount = notifications.getChildCount()
|
||||
|
||||
for i = 0 to childCount - 1
|
||||
child = notifications.getChild(i)
|
||||
if child.id = NOTIFICATION_NODE_ID
|
||||
return child
|
||||
end if
|
||||
end for
|
||||
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ShowNotifcation(notifications as object, segment as object, action as dynamic) as void
|
||||
' TODO:P2 avoid finding the node over and over
|
||||
' The video player can probably own a single notification, and destroy it when the video is closed
|
||||
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||
notification = GetCurrentNotification(notifications)
|
||||
if notification = invalid
|
||||
notification = notifications.createChild("SponsorBlockNotification")
|
||||
notification.id = NOTIFICATION_NODE_ID
|
||||
end if
|
||||
notification.segment = segment
|
||||
notification.action = action
|
||||
|
||||
notification.segmentId = segment.UUID
|
||||
notification.categoryText = segment.shortTitle
|
||||
notification.actionText = segment.actionText
|
||||
notification.doShow = true
|
||||
end function
|
||||
|
||||
function RemoveNotifcation(notifications as object) as void
|
||||
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||
notification = GetCurrentNotification(notifications)
|
||||
if notification <> invalid
|
||||
notifications.RemoveChild(notification)
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetVisible(notifications as object, visible as boolean)
|
||||
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||
notification = GetCurrentNotification(notifications)
|
||||
if notification <> invalid
|
||||
notification.visible = visible
|
||||
end if
|
||||
|
||||
@@ -5,5 +5,5 @@ function SponsorBlockSegmentViewedTask(input as object)
|
||||
segmentId = input.segmentId
|
||||
service = new SponsorBlock.SponsorBlockService()
|
||||
|
||||
service.PostSegmentViewed(segmentId)
|
||||
service.PostSegmentViewed(segmentId, m.top.cancellation)
|
||||
end function
|
||||
@@ -12,6 +12,26 @@ namespace SponsorBlock
|
||||
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
|
||||
end function
|
||||
|
||||
function GetCategories() as object
|
||||
if m.sponsorBlockConfig = invalid
|
||||
return []
|
||||
end if
|
||||
|
||||
return ValidArray(m.sponsorBlockConfig.categoryList)
|
||||
end function
|
||||
|
||||
function GetOptionsForCategory(category as string) as object
|
||||
if m.sponsorBlockConfig = invalid
|
||||
return []
|
||||
end if
|
||||
|
||||
if not m.sponsorBlockConfig.categories.doesexist(category)
|
||||
return []
|
||||
end if
|
||||
|
||||
return ValidArray(m.sponsorBlockConfig.categories[category].options)
|
||||
end function
|
||||
|
||||
function SegmentColor(category as string) as integer
|
||||
if m.sponsorBlockConfig = invalid
|
||||
return 0
|
||||
@@ -54,8 +74,10 @@ namespace SponsorBlock
|
||||
return invalid
|
||||
end if
|
||||
|
||||
categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler", "exclusive_access"]
|
||||
actionTypes = ["skip", "mute", "chapter", "full", "poi"]
|
||||
' categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler", "exclusive_access"]
|
||||
categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler"]
|
||||
' actionTypes = ["skip", "mute", "chapter", "full", "poi"]
|
||||
actionTypes = ["skip", "mute", "poi"]
|
||||
|
||||
categoriesJson = FormatJson(categories).EncodeUriComponent()
|
||||
actionTypesJson = FormatJson(actionTypes).EncodeUriComponent()
|
||||
@@ -64,6 +86,11 @@ namespace SponsorBlock
|
||||
hashPrefix = CryptoUtils.GetSha256(videoId).Left(4)
|
||||
url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.SKIP_SEGMENT_ENDPOINT}/${hashPrefix}?categories=${categoriesJson}&actionTypes=${actionTypesJson}`
|
||||
response = HttpClient.Get(url).Await()
|
||||
if not response.IsSuccess()
|
||||
LogError("SponsorBlockService: GetSkipSegmentsForVideo failed", response.ErrorMessage())
|
||||
return invalid
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
if json = invalid
|
||||
return invalid
|
||||
@@ -78,13 +105,13 @@ namespace SponsorBlock
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function PostSegmentViewed(segmentId as string) as void
|
||||
function PostSegmentViewed(segmentId as string, cancellation = invalid as object) as void
|
||||
if m.sponsorBlockConfig = invalid or StringUtils.IsNullOrEmpty(m.sponsorBlockConfig.serverAddress)
|
||||
return
|
||||
end if
|
||||
|
||||
url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.VIEWED_SEGMENT_ENDPOINT}?UUID=${segmentId}`
|
||||
HttpClient.Post(url, "").Await()
|
||||
HttpClient.Post(url, "").Cancellation(cancellation).Await()
|
||||
end function
|
||||
|
||||
function GenerateProgressBarBackground(segments as object, lengthSeconds as integer, path as string)
|
||||
@@ -103,8 +130,8 @@ namespace SponsorBlock
|
||||
continue for
|
||||
end if
|
||||
|
||||
pixelStart = (segment.segment[0] / videoDuration) * width
|
||||
pixelEnd = (segment.segment[1] / videoDuration) * width
|
||||
pixelStart = (segment.start / videoDuration) * width
|
||||
pixelEnd = (segment.end / videoDuration) * width
|
||||
color = m.SegmentColor(segment.category)
|
||||
' highlight's duration is zero, so it is not visble on the bar.
|
||||
' Add a few pixels to see it
|
||||
|
||||
@@ -1,22 +1,135 @@
|
||||
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
@asynctask
|
||||
function SponsorBlockTask(input as object) as object
|
||||
videoId = input.metadata.videoId
|
||||
lengthSeconds = input.metadata.lengthSeconds
|
||||
showNotifications = input.showNotifications
|
||||
categories = input.categories
|
||||
|
||||
service = new SponsorBlock.SponsorBlockService()
|
||||
skipSegments = service.GetSkipSegmentsForVideo(videoId)
|
||||
barPath = invalid
|
||||
|
||||
skipSegments = ProcessSkipSegments(skipSegments, showNotifications, categories, service)
|
||||
|
||||
barPath = invalid
|
||||
if skipSegments <> invalid
|
||||
barPath = `tmp:/sponsorblock_bar.png`
|
||||
service.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath)
|
||||
end if
|
||||
|
||||
' Usually segment.start and segment.end are equal for poi_highlight
|
||||
' We pad the duration for poi_highlight segments so that the chapter label
|
||||
' can be visible when seeking in trickplay.
|
||||
' Padding poi_highlight is done after generating the progress bar, so that the
|
||||
' highlight is not too long in the bar.
|
||||
skipSegments = PadHightlightSegment(skipSegments, lengthSeconds)
|
||||
|
||||
' Sort the segments by start time, so we can binary search them later.
|
||||
if skipSegments <> invalid
|
||||
skipSegments.SortBy("start")
|
||||
end if
|
||||
|
||||
return {
|
||||
videoId: videoId
|
||||
skipSegments: skipSegments
|
||||
barPath: barPath
|
||||
}
|
||||
end function
|
||||
|
||||
function ProcessSkipSegments(skipSegments as object, showNotifications as boolean, categories as object, service as SponsorBlock.SponsorBlockService) as object
|
||||
if skipSegments = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
processedSegments = []
|
||||
for each segment in skipSegments
|
||||
' When a submission reaches the score of -2 or lower, it gets removed and will not appear anymore for users
|
||||
' https://wiki.sponsor.ajay.app/w/FAQ#How_does_voting_work_and_what_do_certain_amounts_of_votes_mean?
|
||||
if ValidInt(segment.votes) < -1
|
||||
continue for
|
||||
end if
|
||||
|
||||
option = GetOptionForSegment(segment, categories)
|
||||
if option = SponsorBlock.SegmentAction.Disable
|
||||
continue for
|
||||
end if
|
||||
|
||||
segment.option = option
|
||||
|
||||
segment.showNotification = showNotifications and ShouldShowNotification(segment, categories)
|
||||
if segment.showNotification
|
||||
if option = SponsorBlock.SegmentAction.AutoSkip
|
||||
segment.actionText = Tr(Locale.SponsorBlock.Skipped)
|
||||
else if option = SponsorBlock.SegmentAction.ManualSkip
|
||||
segment.actionText = Tr(Locale.SponsorBlock.PressOkToSkip)
|
||||
else
|
||||
segment.actionText = ""
|
||||
end if
|
||||
end if
|
||||
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
segment.Delete("segment")
|
||||
segment.start = segmentStart
|
||||
segment.end = segmentEnd
|
||||
|
||||
segment.title = Tr(ValidString(service.SegmentTitle(segment.category)))
|
||||
segment.shortTitle = Tr(ValidString(service.SegmentShortTitle(segment.category)))
|
||||
|
||||
processedSegments.push(segment)
|
||||
end for
|
||||
|
||||
return processedSegments
|
||||
end function
|
||||
|
||||
function GetOptionForSegment(segment as object, categories as object) as string
|
||||
category = categories[segment.category]
|
||||
if not IsAssociativeArray(category)
|
||||
return false
|
||||
end if
|
||||
|
||||
option = category.option
|
||||
if StringUtils.IsNullOrEmpty(option)
|
||||
option = SponsorBlock.SegmentAction.Disable
|
||||
end if
|
||||
|
||||
return option
|
||||
end function
|
||||
|
||||
function ShouldShowNotification(segment as object, categories as object) as boolean
|
||||
option = GetOptionForSegment(segment, categories)
|
||||
return option = SponsorBlock.SegmentAction.AutoSkip or option = SponsorBlock.SegmentAction.ManualSkip
|
||||
end function
|
||||
|
||||
function PadHightlightSegment(segments as object, lengthSeconds as integer) as object
|
||||
for each segment in segments
|
||||
if not segment.category = "poi_highlight"
|
||||
continue for
|
||||
end if
|
||||
|
||||
segmentPaddedDuration = 5
|
||||
|
||||
if lengthSeconds > 0
|
||||
if lengthSeconds < 120
|
||||
segmentPaddedDuration = 1
|
||||
else if lengthSeconds < 300
|
||||
segmentPaddedDuration = 2
|
||||
else if lengthSeconds < 900
|
||||
segmentPaddedDuration = 5
|
||||
else
|
||||
segmentPaddedDuration = 10
|
||||
end if
|
||||
end if
|
||||
|
||||
segmentDuration = Abs(segment.end - segment.start)
|
||||
padding = Abs(segmentPaddedDuration - segmentDuration) / 2
|
||||
segment.start = segment.start - padding
|
||||
segment.end = segment.end + padding
|
||||
end for
|
||||
|
||||
return segments
|
||||
end function
|
||||
@@ -2,6 +2,7 @@ import "pkg:/components/Services/SponsorBlock/Notifications/SponsorBlockNotifica
|
||||
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "SponsorBlockSegmentAction.bs"
|
||||
import "VideoPlayer.bs"
|
||||
|
||||
namespace SponsorBlock
|
||||
@@ -12,18 +13,62 @@ namespace SponsorBlock
|
||||
end if
|
||||
|
||||
m.sponsorBlockService = new SponsorBlock.SponsorBlockService()
|
||||
|
||||
PositionChapterLabel()
|
||||
m.top.trickPlayBar.observeField("visible", FuncName(OnTrickPlayBarVisible))
|
||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||
m.chapterLabelTimer.observeField("fire", FuncName(OnChapterLabelTimer))
|
||||
m._sponsorBlockLastTime = 0.0#
|
||||
|
||||
' TODO:P1 more precision on when notifications should be visible
|
||||
' Should notifcations be visible when the video is not fullscreen?
|
||||
SponsorBlock.SetVisible(m.notifications, m.container.fullscreen)
|
||||
end function
|
||||
|
||||
function FetchSponsorBlock(metadata as object) as void
|
||||
if not m.preferences["sponsorblock.enabled"]
|
||||
return
|
||||
end if
|
||||
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.cancel = true
|
||||
end if
|
||||
|
||||
m.sponsorBlockTask = AsyncTask.Start(Tasks.SponsorBlockTask, {
|
||||
metadata: metadata
|
||||
showNotifications: m.preferences["sponsorblock.show_notifications"]
|
||||
categories: m.preferences["sponsorblock.categories"]
|
||||
}, OnSponsorBlockTaskResults)
|
||||
end function
|
||||
|
||||
function OnSponsorBlockTaskResults(output as object) as void
|
||||
m.sponsorBlockTask = invalid
|
||||
if output.cancelled or m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
|
||||
if not output.success
|
||||
error = ErrorUtils.Format(output.error)
|
||||
LogError(error)
|
||||
return
|
||||
end if
|
||||
|
||||
skipSegments = output.result.skipSegments
|
||||
if skipSegments = invalid or skipSegments.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
m.skipSegments = skipSegments
|
||||
m.top.seekMode = "accurate"
|
||||
|
||||
barPath = output.result.barPath
|
||||
if barPath <> invalid
|
||||
m.top.trickPlayBar.trackImageUri = barPath
|
||||
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
|
||||
end if
|
||||
|
||||
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
|
||||
|
||||
if m.top.hasField("trickPlayPosition")
|
||||
PositionChapterLabel()
|
||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||
m.chapterLabelTimer.observeField("fire", FuncName(OnChapterLabelTimer))
|
||||
m._sponsorBlockLastTimeChapterUpdated = 0.0#
|
||||
m.top.trickPlayBar.observeField("visible", FuncName(OnTrickPlayBarVisible))
|
||||
end if
|
||||
end function
|
||||
|
||||
function PositionChapterLabel()
|
||||
m.chapterLabel = m.top.findNode("chapterLabel")
|
||||
' We move the chapter label under m.top.trickPlayBar
|
||||
@@ -43,162 +88,137 @@ namespace SponsorBlock
|
||||
end function
|
||||
|
||||
function OnChapterLabelTimer() as void
|
||||
if m.skipSegments = invalid
|
||||
trickPlayPosition = m.top.trickPlayPosition
|
||||
if m._sponsorBlockLastTimeChapterUpdated = trickPlayPosition
|
||||
return
|
||||
end if
|
||||
|
||||
' trickPlayPosition is not documented on Roku website, this is why we're checking
|
||||
if not IsDouble(m.top.trickPlayPosition)
|
||||
return
|
||||
end if
|
||||
|
||||
if m._sponsorBlockLastTime = m.top.trickPlayPosition
|
||||
return
|
||||
end if
|
||||
|
||||
m._sponsorBlockLastTime = m.top.trickPlayPosition
|
||||
|
||||
UpdateSponsorBlockChapter(m._sponsorBlockLastTime)
|
||||
m._sponsorBlockLastTimeChapterUpdated = trickPlayPosition
|
||||
UpdateSponsorBlockChapter(trickPlayPosition)
|
||||
end function
|
||||
|
||||
function UpdateSponsorBlockChapter(time as double) as void
|
||||
segments = m.skipSegments
|
||||
for each segment in segments
|
||||
category = segment["category"]
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
|
||||
' Usually segmentStart and segmentEnd are equal for poi_highlight
|
||||
' We pad the duration for poi_highlight segments so that the chapter label
|
||||
' can be visible when seeking in trickplay
|
||||
if category = "poi_highlight"
|
||||
segmentPaddedDuration = 5
|
||||
|
||||
duration = m.top.duration
|
||||
if duration > 0
|
||||
if duration < 120
|
||||
segmentPaddedDuration = 1
|
||||
else if duration < 300
|
||||
segmentPaddedDuration = 2
|
||||
else if duration < 900
|
||||
segmentPaddedDuration = 5
|
||||
else
|
||||
segmentPaddedDuration = 10
|
||||
end if
|
||||
end if
|
||||
|
||||
segmentDuration = Abs(segmentEnd - segmentStart)
|
||||
padding = Abs(segmentPaddedDuration - segmentDuration) / 2
|
||||
segmentStart = segmentStart - padding
|
||||
segmentEnd = segmentEnd + padding
|
||||
end if
|
||||
|
||||
if (segmentStart <= time) and (segmentEnd >= time)
|
||||
m.top.chapter = Tr(ValidString(m.sponsorBlockService.SegmentTitle(category)))
|
||||
return
|
||||
end if
|
||||
end for
|
||||
m.top.chapter = ""
|
||||
segment = FindSegmentByTime(segments, time, 0)
|
||||
if segment = invalid
|
||||
m.top.chapter = ""
|
||||
return
|
||||
end if
|
||||
m.top.chapter = segment.title
|
||||
end function
|
||||
|
||||
function FetchSponsorBlock(metadata as object) as void
|
||||
if not m.preferences["sponsorblock.enabled"]
|
||||
return
|
||||
end if
|
||||
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.cancel = true
|
||||
end if
|
||||
|
||||
m.sponsorBlockTask = AsyncTask.Start(Tasks.SponsorBlockTask, { metadata: metadata }, OnSponsorBlockTaskResults)
|
||||
end function
|
||||
|
||||
function OnSponsorBlockTaskResults(output as object) as void
|
||||
m.sponsorBlockTask = invalid
|
||||
if output.cancelled or m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
|
||||
if not output.success
|
||||
error = ErrorUtils.Format(output.error)
|
||||
LogError(error)
|
||||
return
|
||||
end if
|
||||
|
||||
skipSegments = output.result.skipSegments
|
||||
if skipSegments = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.skipSegments = skipSegments
|
||||
m.top.seekMode = "accurate"
|
||||
|
||||
barPath = output.result.barPath
|
||||
if barPath <> invalid
|
||||
m.top.trickPlayBar.trackImageUri = barPath
|
||||
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
|
||||
end if
|
||||
|
||||
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
|
||||
function FindSegmentByTime(segments as object, time as dynamic, endOffset as integer) as dynamic
|
||||
' Binary search for the segment that contains the time.
|
||||
' This search sometimes fails if the segments overlap.
|
||||
' For most cases, this is acceptable, since it is not common for segments to overlap.
|
||||
low = 0
|
||||
high = segments.Count() - 1
|
||||
while low <= high
|
||||
middle = (low + high) \ 2
|
||||
segment = segments[middle]
|
||||
if time < segment.start
|
||||
high = middle - 1
|
||||
else if time > (segment.end + endOffset)
|
||||
low = middle + 1
|
||||
else
|
||||
return segment
|
||||
end if
|
||||
end while
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function OnPositionChangeSkipSponsorBlockSections() as void
|
||||
segments = m.skipSegments
|
||||
if segments = invalid
|
||||
position = m.top.position
|
||||
|
||||
' We add a small offset to the end position of the segment.
|
||||
' This is so that when we skip a segment, we don't get
|
||||
' another notification to skip it.
|
||||
' Seeking accuracy is not perfect, so we need to account for that.
|
||||
segment = FindSegmentByTime(segments, position, -1)
|
||||
if segment = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
for each segment in segments
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||
action = GetActionForSegment(segment)
|
||||
if m.preferences["sponsorblock.show_notifications"] = true
|
||||
SponsorBlock.ShowNotifcation(m.notifications, segment, action)
|
||||
end if
|
||||
action = segment.option
|
||||
|
||||
if action = "AutoSkip"
|
||||
duration = m.top.duration
|
||||
' Sometimes segmentEnd is greater than duration
|
||||
if duration > 0 and segmentEnd > duration
|
||||
segmentEnd = duration
|
||||
end if
|
||||
' If the segment is at the end of the video, skip the video instead of seeking
|
||||
if duration > 0 and Abs(segmentEnd - duration) < 2
|
||||
LogInfo("Skipping section:", segment["category"], "at end of video")
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
OnVideoFinished()
|
||||
return
|
||||
else
|
||||
LogInfo("Skipping section:", segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
m.top.seek = segmentEnd
|
||||
return
|
||||
end if
|
||||
end if
|
||||
if segment.showNotification
|
||||
SponsorBlock.ShowNotifcation(m.notifications, segment, action)
|
||||
|
||||
if action = SegmentAction.ManualSkip
|
||||
' We'll save the segment here, and handle it in case the user
|
||||
' presses the OK button on the notification.
|
||||
m.manualSkipSegment = segment
|
||||
return
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
if action = SegmentAction.AutoSkip
|
||||
SkipSegment(segment, position)
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetActionForSegment(segment as object) as dynamic
|
||||
category = segment["category"]
|
||||
if category = "sponsor"
|
||||
return "AutoSkip"
|
||||
else if category = "poi_highlight"
|
||||
return "ManualSkip"
|
||||
else if category = "exclusive_access"
|
||||
return "ShowOverlay"
|
||||
else if category = "chapter"
|
||||
return "ShowOverlay"
|
||||
function SkipSegment(segment as object, position as dynamic) as void
|
||||
segmentEnd = segment.end
|
||||
|
||||
duration = m.top.duration
|
||||
' Sometimes segmentEnd is greater than duration
|
||||
if duration > 0 and segmentEnd > duration
|
||||
segmentEnd = duration
|
||||
end if
|
||||
return ""
|
||||
|
||||
' If we're skipping a very short distance, it's not worth it
|
||||
' since we can cause rebuffering
|
||||
if Abs(segmentEnd - position) < 2
|
||||
LogInfo("Skip position is within 2 seconds of segment end, not skipping")
|
||||
return
|
||||
end if
|
||||
|
||||
' If the segment is at the end of the video, skip the video instead of seeking
|
||||
if duration > 0 and Abs(segmentEnd - duration) < 2
|
||||
LogInfo("Skipping section:", segment.category, "at end of video")
|
||||
OnVideoFinished()
|
||||
else
|
||||
LogInfo("Skipping section:", segment.category)
|
||||
m.top.seek = segmentEnd
|
||||
end if
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
end function
|
||||
|
||||
function ManualSkipSegment() as boolean
|
||||
segment = m.manualSkipSegment
|
||||
if segment = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
m.manualSkipSegment = invalid
|
||||
|
||||
notification = SponsorBlock.GetCurrentNotification(m.notifications)
|
||||
if notification = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
notificationSegmentId = notification.segmentId
|
||||
if notificationSegmentId <> segment.UUID
|
||||
return false
|
||||
end if
|
||||
|
||||
position = m.top.position
|
||||
if (position < segment.start) or (segment.end < position)
|
||||
return false
|
||||
end if
|
||||
|
||||
SkipSegment(segment, position)
|
||||
SponsorBlock.RemoveNotifcation(m.notifications)
|
||||
return true
|
||||
end function
|
||||
|
||||
function SendSkippedSectionEvent(segmentId as string)
|
||||
AsyncTask.Start(Tasks.SponsorBlockSegmentViewedTask, { segmentId: segmentId })
|
||||
if m.sponsorSkipEventTask <> invalid
|
||||
m.sponsorSkipEventTask.cancel = true
|
||||
end if
|
||||
|
||||
m.sponsorSkipEventTask = AsyncTask.Start(Tasks.SponsorBlockSegmentViewedTask, { segmentId: segmentId })
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace SponsorBlock
|
||||
|
||||
enum SegmentAction
|
||||
' Disable: we do not care about this segment.
|
||||
Disable = "disable"
|
||||
' AutoSkip: we want to skip this segment automatically.
|
||||
AutoSkip = "auto_skip"
|
||||
' ManualSkip: we want to skip this segment manually, by showing a notification.
|
||||
' The user would have to press the skip button on the notification.
|
||||
ManualSkip = "manual_skip"
|
||||
' ShowInSeekbar: we want to show this segment in the seekbar, but not skip it.
|
||||
' No notification will be shown
|
||||
ShowInSeekbar = "show_in_seekbar"
|
||||
end enum
|
||||
|
||||
end namespace
|
||||
@@ -518,6 +518,10 @@ function HideUIAndStopTimer()
|
||||
end function
|
||||
|
||||
function HandleOKPress() as boolean
|
||||
if SponsorBlock.ManualSkipSegment()
|
||||
return false
|
||||
end if
|
||||
|
||||
if not m.showUIEnabled
|
||||
return false
|
||||
end if
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</interface>
|
||||
<children>
|
||||
<Label id="chapterLabel" width="350" height="25" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
|
||||
<Timer id="chapterLabelTimer" repeat="true" duration="0.25" />
|
||||
<Timer id="chapterLabelTimer" repeat="true" duration="0.5" />
|
||||
<Animation id="minimizeAnimation" duration="0.3" optional="true">
|
||||
<FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" />
|
||||
<FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" />
|
||||
|
||||
@@ -128,6 +128,52 @@
|
||||
type: "boolean",
|
||||
defaultValue: true,
|
||||
},
|
||||
{
|
||||
displayText: "Categories",
|
||||
key: "sponsorblock.categories",
|
||||
description: "Configure which segments to skip",
|
||||
type: "assocarray",
|
||||
visibility: "tv",
|
||||
rokuComponent: "SponsorBlockCategoriesControl",
|
||||
defaultValue: {
|
||||
// TODO:P1 support for exclusive_access and chapter
|
||||
// TODO:P1 support for manual skip for poi_highlight
|
||||
sponsor: {
|
||||
option: "auto_skip",
|
||||
},
|
||||
selfpromo: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
interaction: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
poi_highlight: {
|
||||
option: "show_in_seekbar",
|
||||
},
|
||||
intro: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
outro: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
preview: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
filler: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
music_offtopic: {
|
||||
option: "manual_skip",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayText: "Categories",
|
||||
key: "sponsorblock.categories",
|
||||
description: "Configure which segments to skip",
|
||||
visibility: "web",
|
||||
svelteComponent: "SponsorBlockCategoriesControl",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,116 +1,70 @@
|
||||
{
|
||||
serverAddress: 'https://sponsor.ajay.app',
|
||||
serverAddress: "https://sponsor.ajay.app",
|
||||
categoryList: [
|
||||
'sponsor',
|
||||
'selfpromo',
|
||||
'exclusive_access',
|
||||
'interaction',
|
||||
'poi_highlight',
|
||||
'intro',
|
||||
'outro',
|
||||
'preview',
|
||||
'filler',
|
||||
'chapter',
|
||||
'music_offtopic',
|
||||
"sponsor",
|
||||
"selfpromo",
|
||||
"interaction",
|
||||
"poi_highlight",
|
||||
"intro",
|
||||
"outro",
|
||||
"preview",
|
||||
"filler",
|
||||
"music_offtopic",
|
||||
],
|
||||
categories: {
|
||||
sponsor: {
|
||||
title: 'Sponsor',
|
||||
short_title: 'Sponsor',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
'full',
|
||||
],
|
||||
color: '#00D400B3',
|
||||
title: "Sponsor",
|
||||
short_title: "Sponsor",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#00D400B3",
|
||||
},
|
||||
selfpromo: {
|
||||
title: 'Unpaid/Self Promotion',
|
||||
short_title: 'Unpaid/Self Promotion',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
'full',
|
||||
],
|
||||
color: '#FFFF00B3',
|
||||
},
|
||||
exclusive_access: {
|
||||
title: 'Exclusive Access',
|
||||
short_title: 'Exclusive Access',
|
||||
categorySupport: [
|
||||
'full',
|
||||
],
|
||||
color: '#008A5CB3',
|
||||
title: "Unpaid/Self Promotion",
|
||||
short_title: "Unpaid/Self Promotion",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#FFFF00B3",
|
||||
},
|
||||
interaction: {
|
||||
title: 'Interaction Reminder (Subscribe)',
|
||||
short_title: 'Interaction Reminder',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
],
|
||||
color: '#CC00FFB3',
|
||||
title: "Interaction Reminder (Subscribe)",
|
||||
short_title: "Interaction Reminder",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#CC00FFB3",
|
||||
},
|
||||
poi_highlight: {
|
||||
title: 'Highlight',
|
||||
short_title: 'Highlight',
|
||||
categorySupport: [
|
||||
'poi',
|
||||
],
|
||||
color: '#FF1684B3',
|
||||
title: "Highlight",
|
||||
short_title: "Highlight",
|
||||
options: ["show_in_seekbar", "disable"],
|
||||
color: "#FF1684B3",
|
||||
},
|
||||
intro: {
|
||||
title: 'Intermission/Intro Animation',
|
||||
short_title: 'Intermission',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
],
|
||||
color: '#00FFFFB3',
|
||||
title: "Intermission/Intro Animation",
|
||||
short_title: "Intermission",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#00FFFFB3",
|
||||
},
|
||||
outro: {
|
||||
title: 'Endcards/Credits',
|
||||
short_title: 'Endcards/Credits',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
],
|
||||
color: '#0202EDB3',
|
||||
title: "Endcards/Credits",
|
||||
short_title: "Endcards/Credits",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#0202EDB3",
|
||||
},
|
||||
preview: {
|
||||
title: 'Preview/Recap/Hook',
|
||||
// Note: short title renamed from "Preview/Recap/Hook" to "Preview/Recap" to fit in the UI
|
||||
short_title: 'Preview/Recap',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
],
|
||||
color: '#008FD6B3',
|
||||
title: "Preview/Recap/Hook",
|
||||
short_title: "Preview/Recap",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#008FD6B3",
|
||||
},
|
||||
filler: {
|
||||
title: 'Filler Tangent/Jokes',
|
||||
short_title: 'Filler',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
'mute',
|
||||
],
|
||||
color: '#7300FFE6',
|
||||
},
|
||||
chapter: {
|
||||
title: 'Chapter',
|
||||
short_title: 'Chapter',
|
||||
categorySupport: [
|
||||
'chapter',
|
||||
],
|
||||
color: '#FFFFFFC8',
|
||||
title: "Filler Tangent/Jokes",
|
||||
short_title: "Filler",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#7300FFE6",
|
||||
},
|
||||
music_offtopic: {
|
||||
title: 'Music: Non-Music Section',
|
||||
short_title: 'Non-Music',
|
||||
categorySupport: [
|
||||
'skip',
|
||||
],
|
||||
color: '#FF9900B3',
|
||||
title: "Music: Non-Music Section",
|
||||
short_title: "Non-Music",
|
||||
options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
|
||||
color: "#FF9900B3",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -884,6 +884,18 @@
|
||||
<source>Show notifications when a segment is skipped</source>
|
||||
<translation>Show notifications when a segment is skipped</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Categories</source>
|
||||
<translation>Categories</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Configure which segments to skip</source>
|
||||
<translation>Configure which segments to skip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select option for %1</source>
|
||||
<translation>Select option for %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Search History</source>
|
||||
<translation>Search History</translation>
|
||||
@@ -1004,6 +1016,26 @@
|
||||
<source>Skipped</source>
|
||||
<translation>Skipped</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Press OK to skip</source>
|
||||
<translation>Press OK to skip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disable</source>
|
||||
<translation>Disable</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Auto Skip</source>
|
||||
<translation>Auto Skip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Manual Skip</source>
|
||||
<translation>Manual Skip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show in Seekbar</source>
|
||||
<translation>Show in Seekbar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Sponsor</source>
|
||||
<translation>Sponsor</translation>
|
||||
|
||||
@@ -285,6 +285,9 @@ namespace Locale
|
||||
EnabledDescription = "Enable SponsorBlock"
|
||||
ShowNotifications = "Show notifications"
|
||||
ShowNotificationsDescription = "Show notifications when a segment is skipped"
|
||||
Categories = "Categories"
|
||||
CategoriesDescription = "Configure which segments to skip"
|
||||
SelectOptionFor = "Select option for %1"
|
||||
|
||||
SearchHistory = "Search History"
|
||||
SearchHistoryPreferences = "Search history preferences"
|
||||
@@ -333,6 +336,12 @@ namespace Locale
|
||||
@locale
|
||||
enum SponsorBlock
|
||||
Skipped = "Skipped"
|
||||
PressOkToSkip = "Press OK to skip"
|
||||
|
||||
Disable = "Disable"
|
||||
AutoSkip = "Auto Skip"
|
||||
ManualSkip = "Manual Skip"
|
||||
ShowInSeekbar = "Show in Seekbar"
|
||||
|
||||
SponsorTitle = "Sponsor"
|
||||
SelfPromoTitle = "Unpaid/Self Promotion"
|
||||
|
||||
Reference in new issue
Block a user