vidsrcto converted to vidsrc.cc

This commit is contained in:
Inside4ndroid
2024-08-01 09:20:16 +01:00
parent 75ac2a12e7
commit d0cc0f8563
6 changed files with 176 additions and 298 deletions
-137
View File
@@ -1,137 +0,0 @@
import { getKeys } from './getKeys.js';
import { unpack } from 'unpacker';
const keys = await getKeys();
function rc4(key, inp) {
let e = [];
e[4] = [];
e[3] = 0;
let i = 0;
e[8] = '';
for (i = 0; i < 256; i++) {
e[4][i] = i;
}
for (i = 0; i < 256; i++) {
e[3] = (e[3] + e[4][i] + key.charCodeAt(i % key.length)) % 256;
e[2] = e[4][i];
e[4][i] = e[4][e[3]];
e[4][e[3]] = e[2];
}
i = 0;
e[3] = 0;
let j = 0;
for (j = 0; j < inp.length; j++) {
i = (i + 1) % 256;
e[3] = (e[3] + e[4][i]) % 256;
e[2] = e[4][i];
e[4][i] = e[4][e[3]];
e[4][e[3]] = e[2];
e[8] += String.fromCharCode(inp.charCodeAt(j) ^ e[4][(e[4][i] + e[4][e[3]]) % 256]);
}
return e[8];
}
function enc(inp) {
inp = encodeURIComponent(inp);
const e = rc4(keys[0], inp);
const out = btoa(e).replace(/\//g, '_').replace(/\+/g, '-');
return out;
}
function dec(inp) {
const i = atob(inp.replace(/_/g, '/').replace(/-/g, '+'));
let e = rc4(keys[3], i);
e = decodeURIComponent(e);
return e;
}
async function episode(data_id) {
let url = `https://vidsrc.to/ajax/embed/episode/${data_id}/sources?token=${encodeURIComponent(enc(data_id))}`;
let resp = await fetch(url);
resp = await resp.json();
let filemoon_id = resp.result[1].id;
url = `https://vidsrc.to/ajax/embed/source/${filemoon_id}?token=${encodeURIComponent(enc(filemoon_id))}`;
resp = await fetch(url);
resp = await resp.json();
let filemoon_url = resp.result.url;
let filemoon_url_dec = dec(filemoon_url);
const parsedUrl = new URL(filemoon_url_dec);
const SRC_URL = parsedUrl.origin + parsedUrl.pathname;
const queryParams = parsedUrl.search.substring(1);
const params = new URLSearchParams(queryParams);
const subtitleLink = params.get('sub.info');
console.log(SRC_URL);
console.log(subtitleLink);
const data = await fetch(SRC_URL);
const dataText = await data.text();
const match = /eval\(function\(p,a,c,k,e,d\).+\)\)\)/g.exec(dataText);
if (match) {
const packed = match[0];
const unpacked = unpack(packed);
const hlsMatch = /sources:\[\s*{\s*file:"([^"]*)"/g.exec(unpacked);
const subs = await getSubtitles(subtitleLink);
const sources = hlsMatch[1];
if (!sources) {
const data = {
source: null,
subtitles: null
};
return { filemoon: data };
} else {
const data = {
source: sources,
subtitles: subs
};
return { filemoon: data };
}
} else {
console.error('Packed data not found');
}
}
async function getSubtitles(subtitleLink) {
if (subtitleLink) {
const subtitlesFetch = await fetch(subtitleLink);
const subtitles = await subtitlesFetch.json();
return subtitles.map(subtitle => ({
file: subtitle.file,
lang: subtitle.label,
}));
} else {
console.error('Subtitle link not found in params');
return null;
}
}
export async function getfmovie(id) {
let resp = await fetch(`https://vidsrc.to/embed/movie/${id}`);
let respText = await resp.text();
const match = /data-id="(.*?)"/g.exec(respText);
if (match) {
let data_id = match[1];
return episode(data_id);
} else {
console.error('Data ID not found');
}
}
export async function getfserie(id, s, e) {
let resp = await (await fetch(`https://vidsrc.to/embed/tv/${id}/${s}/${e}`)).text();
let match = (/data-id="(.*?)"/g).exec(resp)[1];
if (match) {
let data_id = match[1];
return episode(data_id);
} else {
console.error('Data ID not found');
}
}
-24
View File
@@ -1,24 +0,0 @@
export const getKeys = async () => {
const url = "https://raw.githubusercontent.com/Ciarands/vidsrc-keys/main/keys.json";
try {
const response = await fetch(url);
if (response.status !== 200) {
console.error("Failed to fetch decryption keys:", response.statusText);
return null;
}
const keys = await response.json();
if (keys && keys.encrypt && keys.decrypt) {
const allKeys = [...keys.encrypt, ...keys.decrypt];
return allKeys;
} else {
console.error("Keys object is empty or malformed");
return null;
}
} catch (error) {
console.error("Error:", error.message);
return null;
}
};
+77 -129
View File
@@ -1,142 +1,90 @@
import { getKeys } from './getKeys.js';
const HOST = 'vidsrc.cc';
const keys = await getKeys();
async function episode(data_id_1, data_id_2, type, s, e) {
if (type == 'movie') {
const url = `https://${HOST}/api/episodes/${data_id_2}/servers?id=${data_id_1}&type=${type}`;
let resp = await (await fetch(url)).json();
let id1 = resp['data'][0]['hash'];
let id2 = resp['data'][1]['hash'];
const url1 = `https://${HOST}/api/source/${id1}`;
console.log(url1);
const resp1 = await (await fetch(url1)).json();
const url2 = `https://${HOST}/api/source/${id2}`;
console.log(url2);
const resp2 = await (await fetch(url2)).json();
const result_1 = {
source1: resp1
};
const result_2 = {
source2: resp2
};
const combinedResponse = { ...result_1, ...result_2 };
console.log(`combinedResponse : ${JSON.stringify(combinedResponse, null, 2)}`);
return combinedResponse;
};
function rc4(key, inp) {
let e = [];
e[4] = [];
e[3] = 0;
let i = 0;
e[8] = "";
for (i = 0; i < 256; i++) {
e[4][i] = i;
if (type == 'tv') {
const url = `https://${HOST}/api/episodes/${data_id_2}/servers?id=${data_id_1}&type=tv&season=${s}&episode=${e}`;
console.log(url);
let resp = await (await fetch(url)).json();
let id1 = resp['data'][0]['hash'];
let id2 = resp['data'][1]['hash'];
const url1 = `https://${HOST}/api/source/${id1}`;
console.log(url1);
const resp1 = await (await fetch(url1)).json();
const url2 = `https://${HOST}/api/source/${id2}`;
console.log(url2);
const resp2 = await (await fetch(url2)).json();
const result_1 = {
source1: resp1
};
const result_2 = {
source2: resp2
};
const combinedResponse = { ...result_1, ...result_2 };
console.log(`combinedResponse : ${JSON.stringify(combinedResponse, null, 2)}`);
return combinedResponse;
}
for (i = 0; i < 256; i++) {
e[3] = (e[3] + e[4][i] + key.charCodeAt(i % key.length)) % 256;
e[2] = e[4][i];
e[4][i] = e[4][e[3]];
e[4][e[3]] = e[2];
}
i = 0;
e[3] = 0;
let j = 0;
for (j = 0; j < inp.length; j++) {
i = (i + 1) % 256;
e[3] = (e[3] + e[4][i]) % 256;
e[2] = e[4][i];
e[4][i] = e[4][e[3]];
e[4][e[3]] = e[2];
e[8] += String.fromCharCode(inp.charCodeAt(j) ^ e[4][(e[4][i] + e[4][e[3]]) % 256]);
}
return e[8];
}
function enc(inp) {
inp = encodeURIComponent(inp);
const e = rc4(keys[0], inp);
const out = btoa(e).replace(/\//g, "_").replace(/\+/g, '-');
return out;
}
function embed_enc(inp) {
inp = encodeURIComponent(inp);
const e = rc4(keys[1], inp);
const out = btoa(e).replace(/\//g, "_").replace(/\+/g, '-');
return out;
}
function h_enc(inp) {
inp = encodeURIComponent(inp);
const e = rc4(keys[2], inp);
const out = btoa(e).replace(/\//g, "_").replace(/\+/g, '-');
return out;
}
function dec(inp) {
const i = atob((inp).replace(/_/g, "/").replace(/-/g, "+"));
let e = rc4(keys[3], i);
e = decodeURIComponent(e);
return e;
}
function embed_dec(inp) {
const i = atob((inp).replace(/_/g, "/").replace(/-/g, "+"));
let e = rc4(keys[4], i);
e = decodeURIComponent(e);
return e;
}
async function episode(data_id) {
let url = `https://vidsrc.to/ajax/embed/episode/${data_id}/sources?token=${encodeURIComponent(enc(data_id))}`;
let resp = await (await fetch(url)).json();
console.log(resp);
let f2cloud_id = resp['result'][0]['id'];
console.log(f2cloud_id);
url = `https://vidsrc.to/ajax/embed/source/${f2cloud_id}?token=${encodeURIComponent(enc(f2cloud_id))}`;
resp = await (await fetch(url)).json();
let f2cloud_url = resp['result']['url'];
let f2cloud_url_dec = dec(f2cloud_url);
const subs = await getSubtitles(f2cloud_url_dec);
url = new URL(f2cloud_url_dec);
let embed_id = url.pathname.split("/")[2];
let h = h_enc(embed_id);
let mediainfo_url = `https://vid2v11.site/mediainfo/${embed_enc(embed_id)}${url.search}&ads=0&h=${encodeURIComponent(h)}`;
resp = await (await fetch(mediainfo_url)).json();
let playlist = embed_dec(resp['result']);
if (typeof playlist === 'string') {
playlist = JSON.parse(playlist);
}
const sources = playlist.sources?.[0]?.file;
if (!sources) {
const data = {
source: null,
subtitles: null
};
return { vidsrc: data };
} else {
const data = {
source: sources,
subtitles: subs
};
return { vidsrc: data };
}
}
export async function getvmovie(id) {
let resp = await (await fetch(`https://vidsrc.to/embed/movie/${id}`)).text();
const match = (/data-id="(.*?)"/g).exec(resp);
let data_id = match[1];
return episode(data_id);
console.log(`https://${HOST}/v2/embed/movie/${id}`);
let resp = await (await fetch(`https://${HOST}/v2/embed/movie/${id}`)).text();
let regex = /data-id="(.*?)"/g;
let matches = [];
let match;
while ((match = regex.exec(resp)) !== null) {
matches.push(match[1]);
}
if (matches.length >= 2) {
let data_id_1 = matches[0];
let data_id_2 = matches[1];
return await episode(data_id_1, data_id_2, 'movie');
} else {
throw new Error("Failed to find two data-id values in response.");
}
}
export async function getvserie(id, s, e) {
let resp = await (await fetch(`https://vidsrc.to/embed/tv/${id}/${s}/${e}`)).text();
let data_id = (/data-id="(.*?)"/g).exec(resp)[1];
return episode(data_id);
}
console.log(`https://${HOST}/v2/embed/tv/${id}/${s}/${e}`);
let resp = await (await fetch(`https://${HOST}/v2/embed/tv/${id}/${s}/${e}`)).text();
let regex = /data-id="(.*?)"/g;
let matches = [];
let match;
async function getSubtitles(vidplayLink) {
if (vidplayLink.includes('sub.info=')) {
const subtitleLink = vidplayLink.split('?sub.info=')[1].split('&')[0];
const subtitlesFetch = await (await fetch(decodeURIComponent(subtitleLink))).json();
while ((match = regex.exec(resp)) !== null) {
matches.push(match[1]);
}
const subtitles = subtitlesFetch.map(subtitle => ({
file: subtitle.file,
lang: subtitle.label
}));
return subtitles;
}
if (matches.length >= 2) {
let data_id_1 = matches[0];
let data_id_2 = matches[1];
return await episode(data_id_1, data_id_2, 'tv', s, e);
} else {
throw new Error("Failed to find two data-id values in response.");
}
}