mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
renaming
This commit is contained in:
47
providers/drive/stream.ts
Normal file
47
providers/drive/stream.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Stream, ProviderContext } from "../types";
|
||||
|
||||
export const getStream = async function ({
|
||||
link: url,
|
||||
type,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
const headers = providerContext.commonHeaders;
|
||||
try {
|
||||
if (type === "movie") {
|
||||
const res = await providerContext.axios.get(url, { headers });
|
||||
const html = res.data;
|
||||
const $ = providerContext.cheerio.load(html);
|
||||
const link = $('a:contains("HubCloud")').attr("href");
|
||||
url = link || url;
|
||||
}
|
||||
const res = await providerContext.axios.get(url, { headers });
|
||||
let redirectUrl = res.data.match(
|
||||
/<meta\s+http-equiv="refresh"\s+content="[^"]*?;\s*url=([^"]+)"\s*\/?>/i
|
||||
)?.[1];
|
||||
if (url.includes("/archives/")) {
|
||||
redirectUrl = res.data.match(
|
||||
/<a\s+[^>]*href="(https:\/\/hubcloud\.[^\/]+\/[^"]+)"/i
|
||||
)?.[1];
|
||||
}
|
||||
if (!redirectUrl) {
|
||||
return await providerContext.extractors.hubcloudExtracter(url, signal);
|
||||
}
|
||||
const res2 = await providerContext.axios.get(redirectUrl, { headers });
|
||||
const data = res2.data;
|
||||
const $ = providerContext.cheerio.load(data);
|
||||
const hubcloudLink = $(".fa-file-download").parent().attr("href");
|
||||
return await providerContext.extractors.hubcloudExtracter(
|
||||
hubcloudLink?.includes("https://hubcloud") ? hubcloudLink : redirectUrl,
|
||||
signal
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("Movies Drive err", err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user