mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-22 05:36:32 +01:00
Update himovies/himovies.js
This commit is contained in:
parent
9ae4ba9de1
commit
b7d7ffd419
1 changed files with 21 additions and 20 deletions
|
|
@ -1,10 +1,11 @@
|
||||||
async function searchResults(keyword) {
|
async function searchResults(keyword) {
|
||||||
const results = [];
|
const results = [];
|
||||||
|
|
||||||
|
const formattedKeyword = keyword.replace(/ /g, '-');
|
||||||
try {
|
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();
|
const html = await response.text();
|
||||||
|
console.log("Search HTML: " + html);
|
||||||
const blocks = html.split('<div class="flw-item">').slice(1);
|
const blocks = html.split('<div class="flw-item">').slice(1);
|
||||||
|
|
||||||
for (const block of blocks) {
|
for (const block of blocks) {
|
||||||
|
|
@ -65,35 +66,35 @@ async function extractEpisodes(url) {
|
||||||
if (!showIdMatch) return JSON.stringify([]);
|
if (!showIdMatch) return JSON.stringify([]);
|
||||||
|
|
||||||
const showId = showIdMatch[1];
|
const showId = showIdMatch[1];
|
||||||
|
|
||||||
const seasonsRes = await fetchv2("https://himovies.sx/ajax/season/list/" + showId);
|
const seasonsRes = await fetchv2("https://himovies.sx/ajax/season/list/" + showId);
|
||||||
const seasonsHtml = await seasonsRes.text();
|
const seasonsHtml = await seasonsRes.text();
|
||||||
|
|
||||||
const seasonMatch = seasonsHtml.match(/data-id="(\d+)"/);
|
const seasonIdMatches = [...seasonsHtml.matchAll(/data-id="(\d+)"/g)];
|
||||||
if (!seasonMatch) {
|
if (!seasonIdMatches.length) {
|
||||||
return JSON.stringify([{
|
return JSON.stringify([{
|
||||||
href: "https://himovies.sx/ajax/episode/list/" + showId,
|
href: "https://himovies.sx/ajax/episode/list/" + showId,
|
||||||
number: 1
|
number: 1,
|
||||||
|
season: 1
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const seasonId = seasonMatch[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 epsRes = await fetchv2("https://himovies.sx/ajax/season/episodes/" + seasonId);
|
||||||
const epsHtml = await epsRes.text();
|
const epsHtml = await epsRes.text();
|
||||||
|
const episodeMatches = epsHtml.match(/data-id="(\d+)"/g) || [];
|
||||||
const matches = epsHtml.match(/data-id="(\d+)"/g) || [];
|
return episodeMatches.map((m, i) => {
|
||||||
|
|
||||||
matches.forEach((m, i) => {
|
|
||||||
const id = m.replace(/data-id="|"/g, "");
|
const id = m.replace(/data-id="|"/g, "");
|
||||||
results.push({
|
return {
|
||||||
href: "https://himovies.sx/ajax/episode/servers/" + id,
|
href: "https://himovies.sx/ajax/episode/servers/" + id,
|
||||||
number: i + 1
|
number: i + 1,
|
||||||
});
|
season: seasonIdx + 1
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
const results = allEpisodes.flat();
|
||||||
return JSON.stringify(results);
|
return JSON.stringify(results);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return JSON.stringify([{
|
return JSON.stringify([{
|
||||||
href: "Error",
|
href: "Error",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue