Update himovies/himovies.js

This commit is contained in:
aka paul 2025-11-09 18:24:55 +00:00
parent 9ae4ba9de1
commit b7d7ffd419

View file

@ -1,10 +1,11 @@
async function searchResults(keyword) {
const results = [];
const formattedKeyword = keyword.replace(/ /g, '-');
try {
const response = await fetchv2("https://himovies.sx/search/" + encodeURIComponent(keyword));
const response = await fetchv2("https://himovies.sx/search/" + encodeURIComponent(formattedKeyword));
const html = await response.text();
console.log("Search HTML: " + html);
const blocks = html.split('<div class="flw-item">').slice(1);
for (const block of blocks) {
@ -65,35 +66,35 @@ async function extractEpisodes(url) {
if (!showIdMatch) return JSON.stringify([]);
const showId = showIdMatch[1];
const seasonsRes = await fetchv2("https://himovies.sx/ajax/season/list/" + showId);
const seasonsHtml = await seasonsRes.text();
const seasonMatch = seasonsHtml.match(/data-id="(\d+)"/);
if (!seasonMatch) {
const seasonIdMatches = [...seasonsHtml.matchAll(/data-id="(\d+)"/g)];
if (!seasonIdMatches.length) {
return JSON.stringify([{
href: "https://himovies.sx/ajax/episode/list/" + showId,
number: 1
number: 1,
season: 1
}]);
}
const seasonId = seasonMatch[1];
const epsRes = await fetchv2("https://himovies.sx/ajax/season/episodes/" + seasonId);
const epsHtml = await epsRes.text();
const matches = epsHtml.match(/data-id="(\d+)"/g) || [];
matches.forEach((m, i) => {
const id = m.replace(/data-id="|"/g, "");
results.push({
href: "https://himovies.sx/ajax/episode/servers/" + id,
number: i + 1
const allEpisodes = await Promise.all(seasonIdMatches.map(async (match, seasonIdx) => {
const seasonId = match[1];
const epsRes = await fetchv2("https://himovies.sx/ajax/season/episodes/" + seasonId);
const epsHtml = await epsRes.text();
const episodeMatches = epsHtml.match(/data-id="(\d+)"/g) || [];
return episodeMatches.map((m, i) => {
const id = m.replace(/data-id="|"/g, "");
return {
href: "https://himovies.sx/ajax/episode/servers/" + id,
number: i + 1,
season: seasonIdx + 1
};
});
});
}));
const results = allEpisodes.flat();
return JSON.stringify(results);
} catch (err) {
return JSON.stringify([{
href: "Error",