From 7b5c53e6bd051e09aad9d1666fb631d9527eb45a Mon Sep 17 00:00:00 2001 From: Jorrin Date: Thu, 4 Jan 2024 22:35:02 +0100 Subject: [PATCH] browser compatible decodeSrc function --- src/providers/sources/vidsrc/scrape.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/providers/sources/vidsrc/scrape.ts b/src/providers/sources/vidsrc/scrape.ts index 65a709c..81dceff 100644 --- a/src/providers/sources/vidsrc/scrape.ts +++ b/src/providers/sources/vidsrc/scrape.ts @@ -7,11 +7,13 @@ import { vidsrcBase, vidsrcRCPBase } from '@/providers/sources/vidsrc/common'; import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; function decodeSrc(encoded: string, seed: string) { - const encodedBuffer = Buffer.from(encoded, 'hex'); let decoded = ''; + const seedLength = seed.length; - for (let i = 0; i < encodedBuffer.length; i++) { - decoded += String.fromCharCode(encodedBuffer[i] ^ seed.charCodeAt(i % seed.length)); + for (let i = 0; i < encoded.length; i += 2) { + const byte = parseInt(encoded.substr(i, 2), 16); + const seedChar = seed.charCodeAt((i / 2) % seedLength); + decoded += String.fromCharCode(byte ^ seedChar); } return decoded;