From eb14d8d069ccaddfa66e3a0e7db6a64d9f336a93 Mon Sep 17 00:00:00 2001 From: elpaxel <45597512+elpaxel@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:01:25 +0200 Subject: [PATCH 1/3] Superstream captions fix --- src/providers/sources/superstream/common.ts | 4 ++++ src/providers/sources/superstream/subtitles.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/providers/sources/superstream/common.ts b/src/providers/sources/superstream/common.ts index b5d5de1..99299a2 100644 --- a/src/providers/sources/superstream/common.ts +++ b/src/providers/sources/superstream/common.ts @@ -11,3 +11,7 @@ export const apiUrls = [ ]; export const appKey = atob('bW92aWVib3g='); export const appId = atob('Y29tLnRkby5zaG93Ym94'); +export const captionsDomains = [ + atob('bWJwaW1hZ2VzLmNodWF4aW4uY29t'), + atob('aW1hZ2VzLnNoZWd1Lm5ldA=='), +]; \ No newline at end of file diff --git a/src/providers/sources/superstream/subtitles.ts b/src/providers/sources/superstream/subtitles.ts index 08fba3f..05346cd 100644 --- a/src/providers/sources/superstream/subtitles.ts +++ b/src/providers/sources/superstream/subtitles.ts @@ -2,6 +2,8 @@ import { Caption, getCaptionTypeFromUrl, isValidLanguageCode } from '@/providers import { sendRequest } from '@/providers/sources/superstream/sendRequest'; import { ScrapeContext } from '@/utils/context'; +import { captionsDomains } from './common'; + interface CaptionApiResponse { data: { list: { @@ -40,7 +42,10 @@ export async function getSubtitles( subtitleList.forEach((sub) => { const subtitle = sub.subtitles.sort((a, b) => b.order - a.order)[0]; if (!subtitle) return; - const subtitleType = getCaptionTypeFromUrl(subtitle.file_path); + const subtitleFilePath = subtitle.file_path.replace(captionsDomains[0], captionsDomains[1]).replace(/\s/g, "+").replace(/[()]/g, (c) => { + return "%" + c.charCodeAt(0).toString(16); + }); + const subtitleType = getCaptionTypeFromUrl(subtitleFilePath); if (!subtitleType) return; const validCode = isValidLanguageCode(subtitle.lang); @@ -50,7 +55,7 @@ export async function getSubtitles( language: subtitle.lang, hasCorsRestrictions: true, type: subtitleType, - url: subtitle.file_path, + url: subtitleFilePath, }); }); From 44f33182027939d6bb798c9884492172e6385b3d Mon Sep 17 00:00:00 2001 From: elpaxel <45597512+elpaxel@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:20:15 +0200 Subject: [PATCH 2/3] Quotes fix --- src/providers/sources/superstream/subtitles.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/sources/superstream/subtitles.ts b/src/providers/sources/superstream/subtitles.ts index 05346cd..9eef467 100644 --- a/src/providers/sources/superstream/subtitles.ts +++ b/src/providers/sources/superstream/subtitles.ts @@ -42,8 +42,8 @@ export async function getSubtitles( subtitleList.forEach((sub) => { const subtitle = sub.subtitles.sort((a, b) => b.order - a.order)[0]; if (!subtitle) return; - const subtitleFilePath = subtitle.file_path.replace(captionsDomains[0], captionsDomains[1]).replace(/\s/g, "+").replace(/[()]/g, (c) => { - return "%" + c.charCodeAt(0).toString(16); + const subtitleFilePath = subtitle.file_path.replace(captionsDomains[0], captionsDomains[1]).replace(/\s/g, '+').replace(/[()]/g, (c) => { + return '%' + c.charCodeAt(0).toString(16); }); const subtitleType = getCaptionTypeFromUrl(subtitleFilePath); if (!subtitleType) return; From 4dc71793287c82d7fc2a1215e5f126ab40f42a87 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 7 Dec 2023 14:22:26 +0100 Subject: [PATCH 3/3] Fix linting --- src/providers/sources/superstream/common.ts | 5 +---- src/providers/sources/superstream/subtitles.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/providers/sources/superstream/common.ts b/src/providers/sources/superstream/common.ts index 99299a2..6ad1448 100644 --- a/src/providers/sources/superstream/common.ts +++ b/src/providers/sources/superstream/common.ts @@ -11,7 +11,4 @@ export const apiUrls = [ ]; export const appKey = atob('bW92aWVib3g='); export const appId = atob('Y29tLnRkby5zaG93Ym94'); -export const captionsDomains = [ - atob('bWJwaW1hZ2VzLmNodWF4aW4uY29t'), - atob('aW1hZ2VzLnNoZWd1Lm5ldA=='), -]; \ No newline at end of file +export const captionsDomains = [atob('bWJwaW1hZ2VzLmNodWF4aW4uY29t'), atob('aW1hZ2VzLnNoZWd1Lm5ldA==')]; diff --git a/src/providers/sources/superstream/subtitles.ts b/src/providers/sources/superstream/subtitles.ts index 9eef467..36be8de 100644 --- a/src/providers/sources/superstream/subtitles.ts +++ b/src/providers/sources/superstream/subtitles.ts @@ -42,9 +42,12 @@ export async function getSubtitles( subtitleList.forEach((sub) => { const subtitle = sub.subtitles.sort((a, b) => b.order - a.order)[0]; if (!subtitle) return; - const subtitleFilePath = subtitle.file_path.replace(captionsDomains[0], captionsDomains[1]).replace(/\s/g, '+').replace(/[()]/g, (c) => { - return '%' + c.charCodeAt(0).toString(16); - }); + const subtitleFilePath = subtitle.file_path + .replace(captionsDomains[0], captionsDomains[1]) + .replace(/\s/g, '+') + .replace(/[()]/g, (c) => { + return `%${c.charCodeAt(0).toString(16)}`; + }); const subtitleType = getCaptionTypeFromUrl(subtitleFilePath); if (!subtitleType) return;