mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
feat: Add base page worker and update instant link handling in getStream function
This commit is contained in:
2
dist/mod/stream.js
vendored
2
dist/mod/stream.js
vendored
File diff suppressed because one or more lines are too long
2
dist/uhd/stream.js
vendored
2
dist/uhd/stream.js
vendored
File diff suppressed because one or more lines are too long
@@ -141,6 +141,22 @@ export const getStream = async function ({
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("ResumeBot link not found", err);
|
console.log("ResumeBot link not found", err);
|
||||||
}
|
}
|
||||||
|
// Base page worker
|
||||||
|
try {
|
||||||
|
const baseWorkerStream = $drive(".btn-success");
|
||||||
|
baseWorkerStream.each((i, el) => {
|
||||||
|
const link = (el as any).attribs?.href;
|
||||||
|
if (link) {
|
||||||
|
servers.push({
|
||||||
|
server: "Resume Worker " + (i + 1),
|
||||||
|
link: link,
|
||||||
|
type: "mkv",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Base page worker link not found", err);
|
||||||
|
}
|
||||||
// CF workers type 1
|
// CF workers type 1
|
||||||
try {
|
try {
|
||||||
const cfWorkersLink = driveLink.replace("/file", "/wfile") + "?type=1";
|
const cfWorkersLink = driveLink.replace("/file", "/wfile") + "?type=1";
|
||||||
@@ -185,37 +201,69 @@ export const getStream = async function ({
|
|||||||
|
|
||||||
// gdrive
|
// gdrive
|
||||||
|
|
||||||
//instant link
|
//*******
|
||||||
|
//instant link 1
|
||||||
|
//*******
|
||||||
|
// try {
|
||||||
|
// const seed = $drive(".btn-danger").attr("href") || "";
|
||||||
|
// const instantToken = seed.split("=")[1];
|
||||||
|
// console.log("InstantToken", instantToken);
|
||||||
|
// const InstantFromData = new FormData();
|
||||||
|
// InstantFromData.append("keys", instantToken);
|
||||||
|
// const videoSeedUrl = seed.split("/").slice(0, 3).join("/") + "/api";
|
||||||
|
// console.log("videoSeedUrl", videoSeedUrl);
|
||||||
|
// const instantLinkRes = await fetch(videoSeedUrl, {
|
||||||
|
// method: "POST",
|
||||||
|
// body: InstantFromData,
|
||||||
|
// headers: {
|
||||||
|
// "x-token": videoSeedUrl,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// const instantLinkData = await instantLinkRes.json();
|
||||||
|
// // console.log('instantLinkData', instantLinkData);
|
||||||
|
// if (instantLinkData.error === false) {
|
||||||
|
// const instantLink = instantLinkData.url;
|
||||||
|
// servers.push({
|
||||||
|
// server: "Gdrive-Instant",
|
||||||
|
// link: instantLink,
|
||||||
|
// type: "mkv",
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// console.log("Instant link not found", instantLinkData);
|
||||||
|
// }
|
||||||
|
// } catch (err) {
|
||||||
|
// console.log("Instant link not found", err);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//*******
|
||||||
|
//instant link 2
|
||||||
|
//*******
|
||||||
try {
|
try {
|
||||||
const seed = $drive(".btn-danger").attr("href") || "";
|
const seed = $drive(".btn-danger").attr("href") || "";
|
||||||
const instantToken = seed.split("=")[1];
|
const newLinkRes = await fetch(seed, {
|
||||||
// console.log('InstantToken', instantToken);
|
method: "HEAD",
|
||||||
const InstantFromData = new FormData();
|
headers,
|
||||||
InstantFromData.append("keys", instantToken);
|
redirect: "manual",
|
||||||
const videoSeedUrl = seed.split("/").slice(0, 3).join("/") + "/api";
|
|
||||||
// console.log('videoSeedUrl', videoSeedUrl);
|
|
||||||
const instantLinkRes = await fetch(videoSeedUrl, {
|
|
||||||
method: "POST",
|
|
||||||
body: InstantFromData,
|
|
||||||
headers: {
|
|
||||||
"x-token": videoSeedUrl,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const instantLinkData = await instantLinkRes.json();
|
let newLink = seed;
|
||||||
// console.log('instantLinkData', instantLinkData);
|
if (newLinkRes.status >= 300 && newLinkRes.status < 400) {
|
||||||
if (instantLinkData.error === false) {
|
newLink = newLinkRes.headers.get("location") || seed;
|
||||||
const instantLink = instantLinkData.url;
|
} else if (newLinkRes.url && newLinkRes.url !== seed) {
|
||||||
|
// Fallback: check if URL changed (redirect was followed)
|
||||||
|
newLink = newLinkRes.url || newLinkRes.url;
|
||||||
|
} else {
|
||||||
|
newLink = newLinkRes.headers.get("location") || seed;
|
||||||
|
}
|
||||||
|
console.log("Gdrive-Instant-2 link", newLink?.split("?url=")[1]);
|
||||||
servers.push({
|
servers.push({
|
||||||
server: "Gdrive-Instant",
|
server: "Gdrive-Instant-2",
|
||||||
link: instantLink,
|
link: newLink?.split("?url=")[1] || newLink,
|
||||||
type: "mkv",
|
type: "mkv",
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.log("Instant link not found", instantLinkData);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Instant link not found", err);
|
console.log("Instant link not found", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return servers;
|
return servers;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("getStream error", err);
|
console.log("getStream error", err);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const getStream = async ({
|
|||||||
const driveRes = await axios.get(driveLink, { headers });
|
const driveRes = await axios.get(driveLink, { headers });
|
||||||
const driveHtml = driveRes.data;
|
const driveHtml = driveRes.data;
|
||||||
const $drive = cheerio.load(driveHtml);
|
const $drive = cheerio.load(driveHtml);
|
||||||
|
|
||||||
//instant link
|
//instant link
|
||||||
try {
|
try {
|
||||||
const seed = $drive(".btn-danger").attr("href") || "";
|
const seed = $drive(".btn-danger").attr("href") || "";
|
||||||
@@ -74,6 +75,35 @@ export const getStream = async ({
|
|||||||
console.log("Instant link not found", err);
|
console.log("Instant link not found", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*******
|
||||||
|
//instant link 2
|
||||||
|
//*******
|
||||||
|
try {
|
||||||
|
const seed = $drive(".btn-danger").attr("href") || "";
|
||||||
|
const newLinkRes = await fetch(seed, {
|
||||||
|
method: "HEAD",
|
||||||
|
headers,
|
||||||
|
redirect: "manual",
|
||||||
|
});
|
||||||
|
let newLink = seed;
|
||||||
|
if (newLinkRes.status >= 300 && newLinkRes.status < 400) {
|
||||||
|
newLink = newLinkRes.headers.get("location") || seed;
|
||||||
|
} else if (newLinkRes.url && newLinkRes.url !== seed) {
|
||||||
|
// Fallback: check if URL changed (redirect was followed)
|
||||||
|
newLink = newLinkRes.url || newLinkRes.url;
|
||||||
|
} else {
|
||||||
|
newLink = newLinkRes.headers.get("location") || seed;
|
||||||
|
}
|
||||||
|
console.log("Gdrive-Instant-2 link", newLink?.split("?url=")[1]);
|
||||||
|
ServerLinks.push({
|
||||||
|
server: "Gdrive-Instant-2",
|
||||||
|
link: newLink?.split("?url=")[1] || newLink,
|
||||||
|
type: "mkv",
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Instant link not found", err);
|
||||||
|
}
|
||||||
|
|
||||||
// resume link
|
// resume link
|
||||||
try {
|
try {
|
||||||
const resumeDrive = driveLink.replace("/file", "/zfile");
|
const resumeDrive = driveLink.replace("/file", "/zfile");
|
||||||
@@ -94,6 +124,23 @@ export const getStream = async ({
|
|||||||
console.log("Resume link not found");
|
console.log("Resume link not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Base page worker
|
||||||
|
try {
|
||||||
|
const baseWorkerStream = $drive(".btn-success");
|
||||||
|
baseWorkerStream.each((i, el) => {
|
||||||
|
const link = (el as any).attribs?.href;
|
||||||
|
if (link) {
|
||||||
|
ServerLinks.push({
|
||||||
|
server: "Resume Worker " + (i + 1),
|
||||||
|
link: link,
|
||||||
|
type: "mkv",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Base page worker link not found", err);
|
||||||
|
}
|
||||||
|
|
||||||
// CF workers type 1
|
// CF workers type 1
|
||||||
try {
|
try {
|
||||||
const cfWorkersLink = driveLink.replace("/file", "/wfile") + "?type=1";
|
const cfWorkersLink = driveLink.replace("/file", "/wfile") + "?type=1";
|
||||||
|
|||||||
Reference in New Issue
Block a user