mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
fix: Add common headers to fetch requests in getStream function
This commit is contained in:
@@ -10,7 +10,7 @@ export const getStream = async function ({
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const { axios, cheerio, extractors } = providerContext;
|
||||
const { axios, cheerio, extractors, commonHeaders } = providerContext;
|
||||
const { superVideoExtractor } = extractors;
|
||||
async function ExtractGuardahd({
|
||||
imdb, // type, // season,
|
||||
@@ -39,10 +39,16 @@ export const getStream = async function ({
|
||||
const controller2 = new AbortController();
|
||||
const signal2 = controller2.signal;
|
||||
setTimeout(() => controller2.abort(), 4000);
|
||||
const res2 = await fetch("https:" + superVideoUrl, { signal: signal2 });
|
||||
const res2 = await fetch("https:" + superVideoUrl, {
|
||||
signal: signal2,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
},
|
||||
});
|
||||
const data = await res2.text();
|
||||
// console.log('mostraguarda data:', data);
|
||||
console.log("mostraguarda data:", data);
|
||||
const streamUrl = await superVideoExtractor(data);
|
||||
console.log("superStreamUrl:", streamUrl);
|
||||
return streamUrl;
|
||||
} catch (err) {
|
||||
console.error("Error in GetMostraguardaStram:", err);
|
||||
@@ -73,7 +79,7 @@ export const getStream = async function ({
|
||||
const html = res.data;
|
||||
const $ = cheerio.load(html);
|
||||
const superVideoUrl = $('li:contains("supervideo")').attr("data-link");
|
||||
console.log("superVideoUrl:", superVideoUrl);
|
||||
// console.log("superVideoUrl:", superVideoUrl);
|
||||
|
||||
if (!superVideoUrl) {
|
||||
return null;
|
||||
@@ -81,7 +87,12 @@ export const getStream = async function ({
|
||||
const controller2 = new AbortController();
|
||||
const signal2 = controller2.signal;
|
||||
setTimeout(() => controller2.abort(), 4000);
|
||||
const res2 = await fetch("https:" + superVideoUrl, { signal: signal2 });
|
||||
const res2 = await fetch("https:" + superVideoUrl, {
|
||||
signal: signal2,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
},
|
||||
});
|
||||
const data = await res2.text();
|
||||
// console.log('mostraguarda data:', data);
|
||||
const streamUrl = await superVideoExtractor(data);
|
||||
|
||||
Reference in New Issue
Block a user