mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
feat: add extractors bundled in file refactor stream handling in multiple providers
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Stream, ProviderContext } from "../types";
|
||||
import { hubcloudExtractor } from "../extractors/hubcloud";
|
||||
import { gdflixExtractor } from "../extractors/gdflix";
|
||||
|
||||
async function extractKmhdLink(
|
||||
katlink: string,
|
||||
providerContext: ProviderContext
|
||||
providerContext: ProviderContext,
|
||||
) {
|
||||
const { axios } = providerContext;
|
||||
const res = await axios.get(katlink, {
|
||||
@@ -13,7 +15,7 @@ async function extractKmhdLink(
|
||||
const data = res.data;
|
||||
const hubDriveRes = data.match(/hubdrive_res:\s*"([^"]+)"/)[1];
|
||||
const hubDriveLink = data.match(
|
||||
/hubdrive_res\s*:\s*{[^}]*?link\s*:\s*"([^"]+)"/
|
||||
/hubdrive_res\s*:\s*{[^}]*?link\s*:\s*"([^"]+)"/,
|
||||
)[1];
|
||||
return hubDriveLink + hubDriveRes;
|
||||
}
|
||||
@@ -27,17 +29,22 @@ export const getStream = async function ({
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
const { axios, cheerio, extractors } = providerContext;
|
||||
const { hubcloudExtracter, gdFlixExtracter } = extractors;
|
||||
const { axios, cheerio, commonHeaders } = providerContext;
|
||||
const streamLinks: Stream[] = [];
|
||||
console.log("katGetStream", link);
|
||||
try {
|
||||
if (link.includes("gdflix")) {
|
||||
return await gdFlixExtracter(link, signal);
|
||||
return await gdflixExtractor(link, signal, axios, cheerio, commonHeaders);
|
||||
}
|
||||
if (link.includes("kmhd")) {
|
||||
const hubcloudLink = await extractKmhdLink(link, providerContext);
|
||||
return await hubcloudExtracter(hubcloudLink, signal);
|
||||
return await hubcloudExtractor(
|
||||
hubcloudLink,
|
||||
signal,
|
||||
axios,
|
||||
cheerio,
|
||||
commonHeaders,
|
||||
);
|
||||
}
|
||||
if (link.includes("gdflix")) {
|
||||
// resume link
|
||||
@@ -94,7 +101,13 @@ export const getStream = async function ({
|
||||
}
|
||||
return streamLinks;
|
||||
}
|
||||
const stereams = await hubcloudExtracter(link, signal);
|
||||
const stereams = await hubcloudExtractor(
|
||||
link,
|
||||
signal,
|
||||
axios,
|
||||
cheerio,
|
||||
commonHeaders,
|
||||
);
|
||||
return stereams;
|
||||
} catch (error: any) {
|
||||
console.log("katgetStream error: ", error);
|
||||
|
||||
Reference in New Issue
Block a user