uni_scrapper
Version:
A Collection of Movies, Series, Animes Scrapper.
141 lines • 5.9 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
const index_1 = require("../index");
class VidSrcSource extends index_1.BaseSource {
constructor() {
super();
this.baseUrl = "https://himer365ery.com/play";
this.jarviBaseUrl = "https://jarvi366dow.com";
this.headers = {
Referer: "https://himer365ery.com/",
Origin: "https://himer365ery.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
};
}
extractFileUrl(htmlContent) {
const fileUrlRegex = /"file":"([^"]+)"/;
const match = htmlContent.match(fileUrlRegex);
return match ? match[1].replace(/\\\//g, "/") : null;
}
extractKey(htmlContent) {
const keyRegex = /"key":"([^"]+)"/;
const match = htmlContent.match(keyRegex);
return match ? match[1] : null;
}
buildFinalUrl(decodedFileUrl) {
return decodedFileUrl.includes("https")
? decodedFileUrl
: `${this.jarviBaseUrl}${decodedFileUrl}`;
}
buildPlaylistUrl(file) {
const strippedUri = decodeURIComponent(file.replaceAll("~", ""));
return strippedUri.includes("playlist")
? `${this.jarviBaseUrl}/${strippedUri}`
: `${this.jarviBaseUrl}/playlist/${strippedUri}.txt`;
}
async fetchStreamData(url, quality, key) {
try {
const response = await axios_1.default.get(url, {
headers: {
...this.headers,
"X-CSRF-TOKEN": key,
},
});
return {
url: response.data,
quality,
subtitles: [],
headers: this.headers,
};
}
catch (error) {
console.error(`Error fetching stream from ${url}:`, error);
return null;
}
}
async processTvShowStreams(playerData, season, episode, key) {
const seasonBlock = playerData.find((s) => s.id == season);
if (!seasonBlock || !Array.isArray(seasonBlock.folder)) {
throw new Error(`Invalid season block for season ${season}`);
}
const episodeBlock = seasonBlock.folder.find((e) => e.episode == episode);
if (!episodeBlock || !Array.isArray(episodeBlock.folder)) {
throw new Error(`Invalid episode block for episode ${episode}`);
}
const promises = episodeBlock.folder
.filter((source) => source.file && source.title)
.map((source) => {
const playlistUrl = this.buildPlaylistUrl(source.file);
return this.fetchStreamData(playlistUrl, source.title, key);
});
const results = await Promise.all(promises);
return results.filter((stream) => stream !== null);
}
async processMovieStreams(playerData, key) {
const promises = playerData
.filter((source) => source.file && source.title)
.map((source) => {
const playlistUrl = `${this.jarviBaseUrl}/playlist/${source.file.replaceAll("~", "")}.txt`;
return this.fetchStreamData(playlistUrl, source.title, key);
});
const results = await Promise.all(promises);
return results.filter((stream) => stream !== null);
}
async getStreams(slug) {
try {
const slugData = JSON.parse(slug);
const { imdbId, season, episode } = slugData;
const isMovie = !season && !episode;
const url = `${this.baseUrl}/${imdbId}`;
const commonHeaders = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"accept-language": "en-GB,en;q=0.5",
pragma: "no-cache",
"cache-control": "no-cache",
};
const response = await axios_1.default.get(url, {
headers: {
...commonHeaders,
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
referer: "https://www.jalshamoviez.io.in/",
"upgrade-insecure-requests": "1",
},
});
const htmlContent = response.data;
const fileUrl = this.extractFileUrl(htmlContent);
const key = this.extractKey(htmlContent);
if (!fileUrl || !key) {
console.warn("Failed to extract file URL or key from HTML content");
return [];
}
const decodedFileUrl = decodeURIComponent(fileUrl);
const finalUrl = this.buildFinalUrl(decodedFileUrl);
const playerResponse = await axios_1.default.get(finalUrl, {
headers: {
...this.headers,
"X-CSRF-TOKEN": key,
},
});
console.log(playerResponse.data);
if (isMovie) {
return await this.processMovieStreams(playerResponse.data, key);
}
else {
if (!season || !episode) {
throw new Error("Season and episode are required for TV shows");
}
return await this.processTvShowStreams(playerResponse.data, season, episode, key);
}
}
catch (error) {
console.error("Error in getStreams:", error);
return [];
}
}
}
exports.default = VidSrcSource;
//# sourceMappingURL=vidsrc.scrapper.js.map