fix: Add common headers to fetch requests in getStream function

This commit is contained in:
Himanshu
2025-11-02 16:55:52 +05:30
parent 6fe8ee24ab
commit ac79ec2629
2 changed files with 17 additions and 6 deletions

View File

@@ -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);