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
@@ -1,54 +1,53 @@
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
import "pkg:/source/utils/WebUtils.bs"
|
||||
import "pkg:/source/utils/Crypto.bs"
|
||||
import "pkg:/source/utils/ColorUtils.bs"
|
||||
|
||||
namespace SponsorBlock
|
||||
const API_URL = "https://sponsor.ajay.app"
|
||||
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
||||
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
|
||||
|
||||
function SegmentColor(category as string) as integer
|
||||
map = m.SponsorBlockColors
|
||||
if map = invalid
|
||||
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
|
||||
function GetSponsorBlockConfig() as object
|
||||
if m.sponsorBlockConfig = invalid
|
||||
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json"))
|
||||
end if
|
||||
if map.doesexist(category)
|
||||
return map[category]
|
||||
return m.sponsorBlockConfig
|
||||
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
|
||||
return 0
|
||||
end function
|
||||
|
||||
function SegmentTitle(category as string) as string
|
||||
map = m.SponsorBlockTitles
|
||||
if map = invalid
|
||||
map = {
|
||||
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
|
||||
config = SponsorBlock.GetSponsorBlockConfig()
|
||||
if config = invalid
|
||||
return ""
|
||||
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
|
||||
return ""
|
||||
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
|
||||
Reference in new issue
Block a user