* Add basic router * Add a preferences file * small changes * Basic settings navigation menu * Lint fix * Add bunch of controls * Lint fix * StringControl * Lint fix * Add description to keyboard * Settings saving and loading * Lint fix * Settings migration stuff * GET web api * Lint fix * PUT and DELETE (I really fucking hate BrightScript) * plug in sponsorblock settings * autoplay, quality, and video proxying * Remove unused stuff * Lint fix * Invidious instance stuff * cache public instances on start * Start loading home screen after fetching instances * Move web app out of settings to its own screen * picture in picture when in settings * Web app (#80) * Update instance stuff * Update dependencies * Add basic layout * Info and settings page, missing styling * Navbar fixes * Settings page formatting * Theme stuff * Feedback link * Fix username badge * Fix svelte warnings * A wip search page * Add a couple of api functions * Wip home screen * user country code * Expose token and proxy auth calls * Use auth requests server side * Some cleanup * Add svelte vs code extension * remove old web app * More layout stuff * Tweak for string control * Filter out old search suggestions * Search history stuff * img size for lazy loading * Basic modal to play video * Lint fix * Dependencies bump * Add video duration and LIVE indicator to cell * Delete legacy stuff * Add dev menu * Lint fix * Video cell layout * Cell stuff * prefs visibility * Modal layout * Drag and drop functionality * Clear search history * Move web calls to main app * changelog * changelog * Mostly comments * Lint fix --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
173 lines
5.5 KiB
Plaintext
173 lines
5.5 KiB
Plaintext
import "pkg:/source/asyncTask/asyncTask.bs"
|
|
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
|
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
|
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
|
import "pkg:/components/SettingsScreen/Settings.bs"
|
|
|
|
function SetupSponsorBlock() as void
|
|
LoadSponsorBlockSettings()
|
|
if not m.sponsorBlockEnabled = true
|
|
return
|
|
end if
|
|
|
|
PositionChapterLabel()
|
|
|
|
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
|
|
|
m.timeLabel = FindTimeLabel()
|
|
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
|
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
|
m.chapterLabelTimer.observeField("fire", "OnChapterLabelTimer")
|
|
m.top.observeField("videoId", "StartSponsorBlockTask")
|
|
end function
|
|
|
|
function LoadSponsorBlockSettings() as void
|
|
settings = FindAndGetPreferenceValues(["sponsorblock.enabled", "sponsorblock.show_notifications"])
|
|
if settings = invalid
|
|
m.sponsorBlockEnabled = false
|
|
m.sponsorBlockShowNotifications = false
|
|
return
|
|
end if
|
|
|
|
m.sponsorBlockEnabled = settings["sponsorblock.enabled"]
|
|
m.sponsorBlockShowNotifications = settings["sponsorblock.show_notifications"]
|
|
end function
|
|
|
|
function PositionChapterLabel()
|
|
m.chapterLabel = m.top.findNode("chapterLabel")
|
|
m.chapterLabel.reparent(m.top.trickPlayBar, false)
|
|
trickPlayBarWidth = m.top.trickPlayBar.boundingRect().width
|
|
#if DASH_THUMBNAILS
|
|
yPos = 25
|
|
#else
|
|
yPos = 55
|
|
#end if
|
|
m.chapterLabel.translation = [trickPlayBarWidth / 2 - m.chapterLabel.width / 2, yPos]
|
|
end function
|
|
|
|
' This is a hack to access the position of the trickplay
|
|
function FindTimeLabel() as object
|
|
children = m.top.trickPlayBar.getChildren(m.top.trickPlayBar.getChildCount(), 0)
|
|
label = invalid
|
|
for each child in children
|
|
' It's very unfortunate to have to find a label with 0:00 text,
|
|
' and that's on the left side of the screen. This might need completely custom trickPlayBar
|
|
if child.isSubtype("Label") and child.text = "0:00"
|
|
if label = invalid
|
|
label = child
|
|
else
|
|
if child.translation[0] < label.translation[0]
|
|
label = child
|
|
end if
|
|
end if
|
|
end if
|
|
end for
|
|
return label
|
|
end function
|
|
|
|
function OnTrickPlayBarVisible()
|
|
if m.top.trickPlayBar.visible
|
|
m.top.chapter = ""
|
|
m.chapterLabelTimer.control = "start"
|
|
else
|
|
m.chapterLabelTimer.control = "stop"
|
|
end if
|
|
end function
|
|
|
|
function OnChapterLabelTimer() as void
|
|
if m.timeLabel = invalid or m.skipSegments = invalid
|
|
return
|
|
end if
|
|
|
|
if m.sponsorBlockLastTime = m.timeLabel.text
|
|
return
|
|
end if
|
|
m.sponsorBlockLastTime = m.timeLabel.text
|
|
|
|
time = TimeUtils.ParseTime(m.timeLabel.text)
|
|
UpdateSponsorBlockChapter(time)
|
|
end function
|
|
|
|
function UpdateSponsorBlockChapter(time as integer) as void
|
|
segments = m.skipSegments
|
|
for each segment in segments
|
|
segmentRange = segment["segment"]
|
|
segmentStart = segmentRange[0]
|
|
segmentEnd = segmentRange[1]
|
|
|
|
if (segmentStart <= time) and (segmentEnd >= time)
|
|
m.top.chapter = SponsorBlock.SegmentTitle(segment["category"])
|
|
return
|
|
end if
|
|
end for
|
|
m.top.chapter = ""
|
|
end function
|
|
|
|
function StartSponsorBlockTask()
|
|
if m.sponsorBlockTask <> invalid
|
|
m.sponsorBlockTask.control = "stop"
|
|
end if
|
|
|
|
m.sponsorBlockTask = StartAsyncTask(SponsorBlockTask, { videoId: m.top.videoId }, OnSponsorBlockTaskResults)
|
|
end function
|
|
|
|
function OnSponsorBlockTaskResults(output as object)
|
|
skipSegments = output.result.skipSegments
|
|
barPath = output.result.barPath
|
|
if skipSegments <> invalid
|
|
m.skipSegments = skipSegments
|
|
m.top.seekMode = "accurate"
|
|
if barPath <> invalid
|
|
m.top.trickPlayBar.trackImageUri = barPath
|
|
m.top.trickPlayBar.filledBarBlendColor = "0xFF000080"
|
|
end if
|
|
|
|
m.top.ObserveField("position", "OnPositionChangeSkipSponsorBlockSections")
|
|
end if
|
|
end function
|
|
|
|
function OnPositionChangeSkipSponsorBlockSections() as void
|
|
segments = m.skipSegments
|
|
if segments = 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.sponsorBlockShowNotifications = true
|
|
ShowSponsorBlockNotifcation(segment, action)
|
|
end if
|
|
|
|
if action = "AutoSkip"
|
|
m.top.seek = segmentEnd
|
|
print("Skipping section:" + segment["category"])
|
|
SendSkippedSectionEvent(segment.UUID)
|
|
return
|
|
end if
|
|
end if
|
|
end for
|
|
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"
|
|
end if
|
|
return ""
|
|
end function
|
|
|
|
function SendSkippedSectionEvent(segmentId as string)
|
|
StartAsyncTask(SponsorBlockTrackingTask, { segmentId: segmentId })
|
|
end function
|