From 1d9dc3ecda4d08e6f54979a9062a8c65da61875a Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Wed, 23 Nov 2022 21:14:09 -0500 Subject: [PATCH] Add sponsorblock categories and action types as json --- src/components/SearchScreen/SearchScreen.bs | 4 ++-- src/source/services/SponsorBlock.bs | 9 +++++++-- src/source/utils/WebUtils.bs | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/SearchScreen/SearchScreen.bs b/src/components/SearchScreen/SearchScreen.bs index 564cdf45..99147889 100644 --- a/src/components/SearchScreen/SearchScreen.bs +++ b/src/components/SearchScreen/SearchScreen.bs @@ -100,7 +100,7 @@ function ScrollUp() as void destination = m.scrollAnimationInterpolator.keyValue[0][1] current = m.container.translation[1] if current = destination - return + return end if m.scrollAnimationInterpolator.reverse = true m.scrollAnimation.control = "start" @@ -110,7 +110,7 @@ function ScrollDown() as void destination = m.scrollAnimationInterpolator.keyValue[2][1] current = m.container.translation[1] if current = destination - return + return end if m.scrollAnimationInterpolator.reverse = false m.scrollAnimation.control = "start" diff --git a/src/source/services/SponsorBlock.bs b/src/source/services/SponsorBlock.bs index 77eba120..99c52a21 100644 --- a/src/source/services/SponsorBlock.bs +++ b/src/source/services/SponsorBlock.bs @@ -1,12 +1,17 @@ import "pkg:/source/roku_modules/rokurequests/Requests.brs" +import "pkg:/source/utils/WebUtils.bs" namespace SponsorBlock const API_URL = "https://sponsor.ajay.app" const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments" - const CATEGORIES = "&category=sponsor&category=selfpromo&category=interaction&category=intro&category=outro&category=preview&category=music_offtopic" function GetSkipSegmentsForVideo(videoId as string) as object - url = `${SponsorBlock.API_URL}${SponsorBlock.SKIP_SEGMENT_ENDPOINT}?videoID=${videoId}${SponsorBlock.CATEGORIES}` + categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "chapter", "filler", "exclusive_access"] + actionTypes = ["skip", "mute", "chapter", "full", "poi"] + + categoriesJson = WebUtils.UrlEscape(FormatJson(categories)) + actionTypesJson = WebUtils.UrlEscape(FormatJson(actionTypes)) + url = `${SponsorBlock.API_URL}${SponsorBlock.SKIP_SEGMENT_ENDPOINT}?videoID=${videoId}&categories=${categoriesJson}&actionTypes=${actionTypesJson}` response = Requests().get(url) if response.statuscode = 200 diff --git a/src/source/utils/WebUtils.bs b/src/source/utils/WebUtils.bs index 63b1b1b7..e5adde10 100644 --- a/src/source/utils/WebUtils.bs +++ b/src/source/utils/WebUtils.bs @@ -1,3 +1,5 @@ +import "pkg:/source/utils/Types.bs" + namespace WebUtils function UrlEncode(url as string) as string ue = m.UrlEncoder