SponsorBlock Notification (#47)
* SponsorBlock Notification * Lint fix * Reuse animation for multiple skips * Small change * Rename color utils * Lint fix --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
9697ac58d0
commit
e0020ffa66
17 files changed
+460
-62
No files matched your search
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- SponsorBlock notification
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Crash in case GetLocalIpAddress() returns invalid
|
- Crash in case GetLocalIpAddress() returns invalid
|
||||||
|
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.6.0",
|
"version": "0.7.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.6.0",
|
"version": "0.7.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bslib": "npm:@rokucommunity/bslib@^0.1.1",
|
"bslib": "npm:@rokucommunity/bslib@^0.1.1",
|
||||||
|
|||||||
+2
-1
@@ -55,6 +55,7 @@
|
|||||||
"sign-package": "node tools/sign-package.js",
|
"sign-package": "node tools/sign-package.js",
|
||||||
"screenshot": "node tools/screenshot.js",
|
"screenshot": "node tools/screenshot.js",
|
||||||
"profile-sync": "node tools/profile-sync.js",
|
"profile-sync": "node tools/profile-sync.js",
|
||||||
|
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
||||||
"postinstall": "npx ropm copy && cd playlet-web && npm install"
|
"postinstall": "npx ropm copy && cd playlet-web && npm install"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import "pkg:/source/services/SponsorBlock.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.categoryLabel = m.top.findNode("categoryLabel")
|
||||||
|
m.translationAnimation = m.top.findNode("translationAnimation")
|
||||||
|
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
|
||||||
|
m.animationTimer = m.top.findNode("animationTimer")
|
||||||
|
|
||||||
|
m.top.translation = [1280, 20]
|
||||||
|
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||||
|
m.animationTimer.observeField("fire", "OnAnimationTimer")
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSegmentSet()
|
||||||
|
category = m.top.segment.category
|
||||||
|
categoryTitle = SponsorBlock.SegmentShortTitle(category)
|
||||||
|
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
|
||||||
|
AnimateIn()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAnimationTimer()
|
||||||
|
AnimateOut()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AnimateIn()
|
||||||
|
m.translationAnimation.unobserveField("state")
|
||||||
|
m.animationTimer.control = "stop"
|
||||||
|
m.animationTimer.control = "start"
|
||||||
|
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||||
|
|
||||||
|
Animate(false)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AnimateOut()
|
||||||
|
Animate(true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Animate(reverse as boolean) as void
|
||||||
|
' We are already animating in the requested direction
|
||||||
|
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.state = "running"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Check if we are already at the destination
|
||||||
|
if m.translationAnimation.state = "stopped"
|
||||||
|
if reverse
|
||||||
|
destination = m.translationAnimationInterpolator.keyValue[0][0]
|
||||||
|
else
|
||||||
|
destination = m.translationAnimationInterpolator.keyValue[1][0]
|
||||||
|
end if
|
||||||
|
current = m.top.translation[0]
|
||||||
|
if current = destination
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.translationAnimationInterpolator.reverse = reverse
|
||||||
|
m.translationAnimation.control = "start"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAnimationState()
|
||||||
|
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true
|
||||||
|
m.top.getParent().removeChild(m.top)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<component name="SponsorBlockNotification" extends="Group">
|
||||||
|
<interface>
|
||||||
|
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Rectangle
|
||||||
|
width="250"
|
||||||
|
height="70"
|
||||||
|
color="#414141"
|
||||||
|
opacity="0.8">
|
||||||
|
<Poster
|
||||||
|
uri="libpkg:/images/LogoSponsorBlockSimple256px.png"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
translation="[10,10]">
|
||||||
|
</Poster>
|
||||||
|
<Label
|
||||||
|
id="categoryLabel"
|
||||||
|
text="..."
|
||||||
|
font="font:SmallestBoldSystemFont"
|
||||||
|
lineSpacing="5"
|
||||||
|
horizAlign="center"
|
||||||
|
vertAlign="center"
|
||||||
|
wrap="true"
|
||||||
|
width="170"
|
||||||
|
height="70"
|
||||||
|
translation="[70,0]">
|
||||||
|
</Label>
|
||||||
|
</Rectangle>
|
||||||
|
<Animation
|
||||||
|
id="translationAnimation"
|
||||||
|
duration="0.3"
|
||||||
|
optional="true">
|
||||||
|
<Vector2DFieldInterpolator
|
||||||
|
id="translationAnimationInterpolator"
|
||||||
|
key="[0.0, 0.5, 1.0]"
|
||||||
|
keyValue="[ [1280.0, 20.0], [1140.0, 20.0], [1000.0, 20.0] ]"
|
||||||
|
fieldToInterp="SponsorBlockNotification.translation" />
|
||||||
|
</Animation>
|
||||||
|
<Timer
|
||||||
|
id="animationTimer"
|
||||||
|
duration="3"
|
||||||
|
/>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
import "pkg:/components/VideoPlayer/Video.bs"
|
||||||
|
|
||||||
|
function ShowSponsorBlockNotifcation(segment as object)
|
||||||
|
videoContainer = GetVideoContainer()
|
||||||
|
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||||
|
if notification = invalid
|
||||||
|
notification = videoContainer.createChild("SponsorBlockNotification")
|
||||||
|
notification.id = "sponsorBlockNotification"
|
||||||
|
end if
|
||||||
|
notification.segment = segment
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RemoveSponsorBlockNotifcation()
|
||||||
|
videoContainer = GetVideoContainer()
|
||||||
|
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||||
|
if notification <> invalid
|
||||||
|
videoContainer.RemoveChild(notification)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SponsorBlockNotifcationSetVisible(visible as boolean)
|
||||||
|
videoContainer = GetVideoContainer()
|
||||||
|
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||||
|
if notification <> invalid
|
||||||
|
notification.visible = visible
|
||||||
|
end if
|
||||||
|
end function
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/source/services/Invidious.bs"
|
import "pkg:/source/services/Invidious.bs"
|
||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
|
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
||||||
|
|
||||||
function PlayVideo(videoId as string, args = invalid as object)
|
function PlayVideo(videoId as string, args = invalid as object)
|
||||||
sender = args?.sender
|
sender = args?.sender
|
||||||
@@ -23,6 +24,7 @@ function PlayVideo(videoId as string, args = invalid as object)
|
|||||||
videoContainer.sender = sender
|
videoContainer.sender = sender
|
||||||
end if
|
end if
|
||||||
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
||||||
|
videoContainer.insertChild(videoContainer.videoPlayer, 0)
|
||||||
videoContainer.videoPlayer.id = "VideoPlayer"
|
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||||
videoContainer.videoPlayer.metadata = metadata
|
videoContainer.videoPlayer.metadata = metadata
|
||||||
videoContainer.videoPlayer.videoId = videoId
|
videoContainer.videoPlayer.videoId = videoId
|
||||||
@@ -49,6 +51,7 @@ function CloseVideo(setFocus = true as boolean)
|
|||||||
videoContainer.sender.SetFocus(true)
|
videoContainer.sender.SetFocus(true)
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
SponsorBlockNotifcationSetVisible(false)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ToggleVideoPictureInPicture(sender = invalid as object) as boolean
|
function ToggleVideoPictureInPicture(sender = invalid as object) as boolean
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import "pkg:/components/VideoPlayer/Video.bs"
|
|||||||
import "pkg:/components/VideoPlayer/VideoDetailsTask.bs"
|
import "pkg:/components/VideoPlayer/VideoDetailsTask.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
|
m.videoContainer = GetVideoContainer()
|
||||||
|
|
||||||
SetupSponsorBlock()
|
SetupSponsorBlock()
|
||||||
SetupAnimation()
|
SetupAnimation()
|
||||||
SetupBusySpinner()
|
SetupBusySpinner()
|
||||||
@@ -12,7 +14,6 @@ function Init()
|
|||||||
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
|
|
||||||
m.videoContainer = GetVideoContainer()
|
|
||||||
m.top.enableUI = m.videoContainer.fullscreen
|
m.top.enableUI = m.videoContainer.fullscreen
|
||||||
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
||||||
|
|
||||||
@@ -335,4 +336,5 @@ function OnFullScreenChange()
|
|||||||
m.translationAnimation.control = "start"
|
m.translationAnimation.control = "start"
|
||||||
|
|
||||||
m.top.enableUI = m.videoContainer.fullscreen
|
m.top.enableUI = m.videoContainer.fullscreen
|
||||||
|
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||||
end function
|
end function
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||||
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
||||||
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
||||||
|
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
||||||
|
|
||||||
function SetupSponsorBlock()
|
function SetupSponsorBlock()
|
||||||
PositionChapterLabel()
|
PositionChapterLabel()
|
||||||
|
|
||||||
|
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||||
|
|
||||||
m.timeLabel = FindTimeLabel()
|
m.timeLabel = FindTimeLabel()
|
||||||
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
||||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||||
@@ -123,6 +127,7 @@ function OnPositionChangeSkipSponsorBlockSections() as void
|
|||||||
' TODO: if segmentEnd is at the end of the video, close video
|
' TODO: if segmentEnd is at the end of the video, close video
|
||||||
m.top.seek = segmentEnd
|
m.top.seek = segmentEnd
|
||||||
print("Skipping section:" + segment["category"])
|
print("Skipping section:" + segment["category"])
|
||||||
|
ShowSponsorBlockNotifcation(segment)
|
||||||
SendSkippedSectionEvent(segment.UUID)
|
SendSkippedSectionEvent(segment.UUID)
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ function WebServerLoop()
|
|||||||
return true
|
return true
|
||||||
end function)
|
end function)
|
||||||
|
|
||||||
if IsDebugMode()
|
#if DEBUG
|
||||||
allowedOrigin = "*"
|
allowedOrigin = "*"
|
||||||
else
|
#else
|
||||||
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
|
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
|
||||||
end if
|
#end if
|
||||||
|
|
||||||
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
|
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
|
||||||
#if WEB_SOCKETS
|
#if WEB_SOCKETS
|
||||||
m.server.UseRouter(new Http.WebSocketMiddleware())
|
m.server.UseRouter(new Http.WebSocketMiddleware())
|
||||||
@@ -58,13 +59,13 @@ function WebServerLoop()
|
|||||||
m.server.UseRouter(new Http.StateApiRouter())
|
m.server.UseRouter(new Http.StateApiRouter())
|
||||||
m.server.UseRouter(new Http.InvidiousRouter())
|
m.server.UseRouter(new Http.InvidiousRouter())
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
|
||||||
if IsDebugMode()
|
#if DEBUG
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", true, true, false))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", true, true, false))
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", true, true))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", true, true))
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", true, true))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", true, true))
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", true, true))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", true, true))
|
||||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", true, true))
|
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", true, true))
|
||||||
end if
|
#end if
|
||||||
#if WEB_SERVER_BASIC_AUTH
|
#if WEB_SERVER_BASIC_AUTH
|
||||||
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
||||||
#end if
|
#end if
|
||||||
|
|||||||
@@ -5,5 +5,4 @@
|
|||||||
<field id="login" type="boolean" alwaysNotify="true" />
|
<field id="login" type="boolean" alwaysNotify="true" />
|
||||||
<field id="command" type="string" alwaysNotify="true" />
|
<field id="command" type="string" alwaysNotify="true" />
|
||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="pkg:/source/utils/Debug.bs" />
|
|
||||||
</component>
|
</component>
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"serverAddress": "https://sponsor.ajay.app",
|
||||||
|
"categoryList": [
|
||||||
|
"sponsor",
|
||||||
|
"selfpromo",
|
||||||
|
"exclusive_access",
|
||||||
|
"interaction",
|
||||||
|
"poi_highlight",
|
||||||
|
"intro",
|
||||||
|
"outro",
|
||||||
|
"preview",
|
||||||
|
"filler",
|
||||||
|
"chapter",
|
||||||
|
"music_offtopic"
|
||||||
|
],
|
||||||
|
"categories": {
|
||||||
|
"sponsor": {
|
||||||
|
"title": "Sponsor",
|
||||||
|
"short_title": "Sponsor",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip",
|
||||||
|
"mute",
|
||||||
|
"full"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"interaction": {
|
||||||
|
"title": "Interaction Reminder (Subscribe)",
|
||||||
|
"short_title": "Interaction Reminder",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip",
|
||||||
|
"mute"
|
||||||
|
],
|
||||||
|
"color": "#cc00ffB3"
|
||||||
|
},
|
||||||
|
"poi_highlight": {
|
||||||
|
"title": "Highlight",
|
||||||
|
"short_title": "Highlight",
|
||||||
|
"categorySupport": [
|
||||||
|
"poi"
|
||||||
|
],
|
||||||
|
"color": "#ff1684B3"
|
||||||
|
},
|
||||||
|
"intro": {
|
||||||
|
"title": "Intermission/Intro Animation",
|
||||||
|
"short_title": "Intermission",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip",
|
||||||
|
"mute"
|
||||||
|
],
|
||||||
|
"color": "#00ffffB3"
|
||||||
|
},
|
||||||
|
"outro": {
|
||||||
|
"title": "Endcards/Credits",
|
||||||
|
"short_title": "Endcards/Credits",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip",
|
||||||
|
"mute"
|
||||||
|
],
|
||||||
|
"color": "#0202edB3"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"title": "Preview/Recap",
|
||||||
|
"short_title": "Preview/Recap",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip",
|
||||||
|
"mute"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"music_offtopic": {
|
||||||
|
"title": "Music: Non-Music Section",
|
||||||
|
"short_title": "Non-Music",
|
||||||
|
"categorySupport": [
|
||||||
|
"skip"
|
||||||
|
],
|
||||||
|
"color": "#ff9900B3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
@@ -1,54 +1,53 @@
|
|||||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||||
import "pkg:/source/utils/WebUtils.bs"
|
import "pkg:/source/utils/WebUtils.bs"
|
||||||
import "pkg:/source/utils/Crypto.bs"
|
import "pkg:/source/utils/Crypto.bs"
|
||||||
|
import "pkg:/source/utils/ColorUtils.bs"
|
||||||
|
|
||||||
namespace SponsorBlock
|
namespace SponsorBlock
|
||||||
const API_URL = "https://sponsor.ajay.app"
|
const API_URL = "https://sponsor.ajay.app"
|
||||||
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
||||||
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
|
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
|
||||||
|
|
||||||
function SegmentColor(category as string) as integer
|
function GetSponsorBlockConfig() as object
|
||||||
map = m.SponsorBlockColors
|
if m.sponsorBlockConfig = invalid
|
||||||
if map = invalid
|
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json"))
|
||||||
map = {
|
|
||||||
sponsor: &h00D400FF,
|
|
||||||
selfpromo: &hFFFF00FF,
|
|
||||||
exclusive_access: &h008A5CFF,
|
|
||||||
interaction: &hCC00FFFF,
|
|
||||||
poi_highlight: &hFF1684FF,
|
|
||||||
intro: &h00FFFFFF,
|
|
||||||
outro: &h0202EDFF,
|
|
||||||
preview: &h008FD6FF,
|
|
||||||
filler: &h7300FFFF,
|
|
||||||
music_offtopic: &hFF9900FF
|
|
||||||
}
|
|
||||||
m.SponsorBlockColors = map
|
|
||||||
end if
|
end if
|
||||||
if map.doesexist(category)
|
return m.sponsorBlockConfig
|
||||||
return map[category]
|
end function
|
||||||
|
|
||||||
|
function SegmentColor(category as string) as integer
|
||||||
|
config = SponsorBlock.GetSponsorBlockConfig()
|
||||||
|
if config = invalid
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
|
||||||
|
if config.categories.doesexist(category)
|
||||||
|
color = config.categories[category].color
|
||||||
|
return ColorUtils.HexToInt(color)
|
||||||
end if
|
end if
|
||||||
return 0
|
return 0
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SegmentTitle(category as string) as string
|
function SegmentTitle(category as string) as string
|
||||||
map = m.SponsorBlockTitles
|
config = SponsorBlock.GetSponsorBlockConfig()
|
||||||
if map = invalid
|
if config = invalid
|
||||||
map = {
|
return ""
|
||||||
sponsor: "Sponsor",
|
|
||||||
selfpromo: "Unpaid/Self Promotion",
|
|
||||||
exclusive_access: "Exclusive Access",
|
|
||||||
interaction: "Interaction Reminder (Subscribe)",
|
|
||||||
poi_highlight: "Highlight",
|
|
||||||
intro: "Intermission/Intro Animation",
|
|
||||||
outro: "Endcards/Credits",
|
|
||||||
preview: "Preview/Recap",
|
|
||||||
filler: "Filler Tangent/Jokes",
|
|
||||||
music_offtopic: "Non-Music Section"
|
|
||||||
}
|
|
||||||
m.SponsorBlockTitles = map
|
|
||||||
end if
|
end if
|
||||||
if map.doesexist(category)
|
|
||||||
return map[category]
|
if config.categories.doesexist(category)
|
||||||
|
return config.categories[category].title
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SegmentShortTitle(category as string) as string
|
||||||
|
config = SponsorBlock.GetSponsorBlockConfig()
|
||||||
|
if config = invalid
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
|
||||||
|
if config.categories.doesexist(category)
|
||||||
|
return config.categories[category].short_title
|
||||||
end if
|
end if
|
||||||
return ""
|
return ""
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace ColorUtils
|
||||||
|
function HexToInt(color as dynamic) as integer
|
||||||
|
if color = invalid
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
if color.left(1) = "#"
|
||||||
|
color = color.mid(1)
|
||||||
|
end if
|
||||||
|
|
||||||
|
value = Val(color.mid(0, 2), 16) * 16777216 + Val(color.mid(2, 2), 16) * 65536 + Val(color.mid(4, 2), 16) * 256
|
||||||
|
if color.Len() = 6
|
||||||
|
value += 255
|
||||||
|
else if color.Len() = 8
|
||||||
|
value += Val(color.mid(6, 2), 16)
|
||||||
|
end if
|
||||||
|
|
||||||
|
return value
|
||||||
|
end function
|
||||||
|
end namespace
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
function IsDebugMode() as boolean
|
|
||||||
appInfo = CreateObject("roAppInfo")
|
|
||||||
bsConst = appInfo.GetValue("bs_const")
|
|
||||||
symbols = bsConst.Tokenize(";")
|
|
||||||
|
|
||||||
for each symbol in symbols
|
|
||||||
keyValuePair = symbol.Tokenize("=")
|
|
||||||
if keyValuePair.Count() <> 2
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
if UCase(keyValuePair[0]) = "DEBUG"
|
|
||||||
return UCase(keyValuePair[1]) = "TRUE"
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
|
|
||||||
return false
|
|
||||||
end function
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
if (process.argv.length !== 3) {
|
||||||
|
console.error("Invalid usage! usage: npm run generate-sponsorblock-config -- sponsorblock_root");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLAYLEY_CONFIG_PATH = "./playlet-lib/src/config/sponsorblock_config.json"
|
||||||
|
|
||||||
|
const sponsorblockRoot = process.argv[2];
|
||||||
|
|
||||||
|
const configExamplePath = path.join(sponsorblockRoot, "config.json.example")
|
||||||
|
const englishLocalePath = path.join(sponsorblockRoot, "public/_locales/en/messages.json")
|
||||||
|
|
||||||
|
let configExample = JSON.parse(fs.readFileSync(configExamplePath, { encoding: 'utf8', flag: 'r' }))
|
||||||
|
let englishLocale = JSON.parse(fs.readFileSync(englishLocalePath, { encoding: 'utf8', flag: 'r' }))
|
||||||
|
|
||||||
|
// https://github.com/ajayyy/SponsorBlock/blob/f4d80d88438ff31bc067ff480fd94112d972718d/src/config.ts#L251
|
||||||
|
const barTypes = {
|
||||||
|
"preview-chooseACategory": {
|
||||||
|
color: "#ffffff",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"sponsor": {
|
||||||
|
color: "#00d400",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-sponsor": {
|
||||||
|
color: "#007800",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"selfpromo": {
|
||||||
|
color: "#ffff00",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-selfpromo": {
|
||||||
|
color: "#bfbf35",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"exclusive_access": {
|
||||||
|
color: "#008a5c",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"interaction": {
|
||||||
|
color: "#cc00ff",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-interaction": {
|
||||||
|
color: "#6c0087",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"intro": {
|
||||||
|
color: "#00ffff",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-intro": {
|
||||||
|
color: "#008080",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"outro": {
|
||||||
|
color: "#0202ed",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-outro": {
|
||||||
|
color: "#000070",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
color: "#008fd6",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-preview": {
|
||||||
|
color: "#005799",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"music_offtopic": {
|
||||||
|
color: "#ff9900",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-music_offtopic": {
|
||||||
|
color: "#a6634a",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"poi_highlight": {
|
||||||
|
color: "#ff1684",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"preview-poi_highlight": {
|
||||||
|
color: "#9b044c",
|
||||||
|
opacity: "0.7"
|
||||||
|
},
|
||||||
|
"filler": {
|
||||||
|
color: "#7300FF",
|
||||||
|
opacity: "0.9"
|
||||||
|
},
|
||||||
|
"preview-filler": {
|
||||||
|
color: "#2E0066",
|
||||||
|
opacity: "0.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColor(obj) {
|
||||||
|
if (!obj) {
|
||||||
|
return "#FFFFFFC8"
|
||||||
|
}
|
||||||
|
|
||||||
|
const opacity = (Math.round(parseFloat(obj.opacity) * 255)).toString(16).toUpperCase().padStart(2, "0")
|
||||||
|
return obj.color + opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
let playletConfig = {
|
||||||
|
serverAddress: configExample.serverAddress,
|
||||||
|
categoryList: configExample.categoryList,
|
||||||
|
categories: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
playletConfig.categoryList.forEach(categoryId => {
|
||||||
|
const category = {}
|
||||||
|
|
||||||
|
category.title = englishLocale[`category_${categoryId}`].message
|
||||||
|
category.short_title = englishLocale[`category_${categoryId}_short`]?.message ?? category.title;
|
||||||
|
category.categorySupport = configExample.categorySupport[categoryId];
|
||||||
|
category.color = getColor(barTypes[categoryId]);
|
||||||
|
|
||||||
|
playletConfig.categories[categoryId] = category;
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.writeFileSync(PLAYLEY_CONFIG_PATH, JSON.stringify(playletConfig, null, 4));
|
||||||
Reference in new issue
Block a user