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,4 +1,6 @@
|
||||
import { Stream, ProviderContext } from "../types";
|
||||
import { hubcloudExtractor } from "../extractors/hubcloud";
|
||||
import { gdflixExtractor } from "../extractors/gdflix";
|
||||
|
||||
export const getStream = async ({
|
||||
link,
|
||||
@@ -10,6 +12,7 @@ export const getStream = async ({
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> => {
|
||||
const { axios, cheerio, commonHeaders: headers } = providerContext;
|
||||
try {
|
||||
let newLink = link;
|
||||
console.log("getStream 1", link);
|
||||
@@ -39,7 +42,7 @@ export const getStream = async ({
|
||||
});
|
||||
const html = await res.text();
|
||||
const refreshMetaMatch = html.match(
|
||||
/<meta\s+http-equiv="refresh"\s+content="[^"]*url=([^"]+)"/i
|
||||
/<meta\s+http-equiv="refresh"\s+content="[^"]*url=([^"]+)"/i,
|
||||
);
|
||||
if (refreshMetaMatch && refreshMetaMatch[1]) {
|
||||
link = refreshMetaMatch[1];
|
||||
@@ -50,8 +53,8 @@ export const getStream = async ({
|
||||
console.log("getStream 2", link);
|
||||
|
||||
if (link.includes("luxedrive")) {
|
||||
const res = await providerContext.axios.get(link, { signal });
|
||||
const $ = providerContext.cheerio.load(res.data);
|
||||
const res = await axios.get(link, { signal });
|
||||
const $ = cheerio.load(res.data);
|
||||
const hubcloudLink = $("a.btn.hubcloud").attr("href");
|
||||
if (hubcloudLink) {
|
||||
newLink = hubcloudLink;
|
||||
@@ -63,18 +66,24 @@ export const getStream = async ({
|
||||
}
|
||||
}
|
||||
if (newLink.includes("flix")) {
|
||||
const sreams = await providerContext.extractors.gdFlixExtracter(
|
||||
const sreams = await gdflixExtractor(
|
||||
newLink,
|
||||
signal
|
||||
signal,
|
||||
axios,
|
||||
cheerio,
|
||||
headers,
|
||||
);
|
||||
return sreams;
|
||||
}
|
||||
const res2 = await providerContext.axios.get(newLink, { signal });
|
||||
const res2 = await axios.get(newLink, { signal });
|
||||
const data2 = res2.data;
|
||||
const hcLink = data2.match(/location\.replace\('([^']+)'/)?.[1] || newLink;
|
||||
const hubCloudLinks = await providerContext.extractors.hubcloudExtracter(
|
||||
const hubCloudLinks = await hubcloudExtractor(
|
||||
hcLink.includes("https://hubcloud") ? hcLink : newLink,
|
||||
signal
|
||||
signal,
|
||||
axios,
|
||||
cheerio,
|
||||
headers,
|
||||
);
|
||||
return hubCloudLinks;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user