mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 14:53:24 +00:00
browser compatible decodeSrc function
This commit is contained in:
@@ -7,11 +7,13 @@ import { vidsrcBase, vidsrcRCPBase } from '@/providers/sources/vidsrc/common';
|
|||||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
function decodeSrc(encoded: string, seed: string) {
|
function decodeSrc(encoded: string, seed: string) {
|
||||||
const encodedBuffer = Buffer.from(encoded, 'hex');
|
|
||||||
let decoded = '';
|
let decoded = '';
|
||||||
|
const seedLength = seed.length;
|
||||||
|
|
||||||
for (let i = 0; i < encodedBuffer.length; i++) {
|
for (let i = 0; i < encoded.length; i += 2) {
|
||||||
decoded += String.fromCharCode(encodedBuffer[i] ^ seed.charCodeAt(i % seed.length));
|
const byte = parseInt(encoded.substr(i, 2), 16);
|
||||||
|
const seedChar = seed.charCodeAt((i / 2) % seedLength);
|
||||||
|
decoded += String.fromCharCode(byte ^ seedChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
return decoded;
|
return decoded;
|
||||||
|
Reference in New Issue
Block a user