From cf30abbca7a6c3e24f4ad2cf25a4959fbd3f3f58 Mon Sep 17 00:00:00 2001
From: aka paul <50n50@noreply.localhost>
Date: Sun, 9 Nov 2025 11:11:03 +0000
Subject: [PATCH] Add himovies/himovies.js
---
himovies/himovies.js | 205 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 205 insertions(+)
create mode 100644 himovies/himovies.js
diff --git a/himovies/himovies.js b/himovies/himovies.js
new file mode 100644
index 0000000..9669a6c
--- /dev/null
+++ b/himovies/himovies.js
@@ -0,0 +1,205 @@
+async function searchResults(keyword) {
+ const results = [];
+
+ try {
+ const response = await fetchv2("https://himovies.sx/search/" + encodeURIComponent(keyword));
+ const html = await response.text();
+
+ const blocks = html.split('
').slice(1);
+
+ for (const block of blocks) {
+ const href = block.match(/
([\s\S]*?)<\/div>/);
+ const dateMatch = html.match(/Released:\s*<\/strong>\s*([^<\n]+)/);
+
+ const description = descMatch ? descMatch[1].trim() : "N/A";
+ const airdate = dateMatch ? dateMatch[1].trim() : "N/A";
+
+ return JSON.stringify([{
+ description: description,
+ aliases: "N/A",
+ airdate: airdate
+ }]);
+
+ } catch (err) {
+ return JSON.stringify([{
+ description: "Error",
+ aliases: "Error",
+ airdate: "Error"
+ }]);
+ }
+}
+
+async function extractEpisodes(url) {
+ const results = [];
+
+ try {
+ const showIdMatch = url.match(/-(\d+)(?:\/)?$/);
+ 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) {
+ return JSON.stringify([{
+ href: "https://himovies.sx/ajax/episode/list/" + showId,
+ number: 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
+ });
+ });
+
+ return JSON.stringify(results);
+
+ } catch (err) {
+ return JSON.stringify([{
+ href: "Error",
+ number: "Error"
+ }]);
+ }
+}
+
+async function extractStreamUrl(url) {
+ try {
+ const response = await fetchv2(url);
+ const html = await response.text();
+ const idMatch = html.match(/data-id="([\w\d]+)"[^>]*title="Server MegaCloud"/i);
+ if (!idMatch) return "https://error.org/";
+
+ const api = await fetchv2("https://himovies.sx/ajax/episode/sources/" + idMatch[1]);
+ const json = await api.json();
+
+ const linkMatch = json.link.match(/\/embed-1\/v3\/e-1\/([\w\d]+)/);
+ if (!linkMatch) return "https://error.org/";
+ const playerId = linkMatch[1];
+ const responseTwo = await fetchv2(json.link, {
+ "referrer": "https://himovies.sx/",
+ });
+ const txtTwo = await responseTwo.text();
+ let key = null;
+ console.log("Response Text: " + txtTwo);
+ const xyMatch = txtTwo.match(/window\._xy_ws\s*=\s*"([^"]+)"/);
+ if (xyMatch) key = xyMatch[1];
+
+
+ if (!key) {
+ const lkMatch = txtTwo.match(/window\._lk_db\s*=\s*\{[^}]*x:\s*"([^"]+)"[^}]*y:\s*"([^"]+)"[^}]*z:\s*"([^"]+)"/);
+ if (lkMatch) key = lkMatch[1] + lkMatch[2] + lkMatch[3];
+ }
+
+ if (!key) {
+ const metaMatch = txtTwo.match(/]+nonce="([^"]+)"/i);
+ if (nonceMatch) key = nonceMatch[1];
+ }
+
+ if (!key) {
+ const commentMatch = txtTwo.match(//);
+ if (commentMatch) key = commentMatch[1];
+ }
+
+ if (!key) return "https://error.org/";
+
+ const sourcesUrl = `https://videostr.net/embed-1/v3/e-1/getSources?id=${playerId}&_k=${key}`;
+ const headers = {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
+ "Referer": "https://videostr.net/",
+ "x-Requested-With": "XMLHttpRequest",
+ "accept": "application/json, text/javascript, */*; q=0.01"
+ };
+ const responseThree = await fetchv2(sourcesUrl, headers);
+ const jsonThree = await responseThree.json();
+ console.log("Extracted sources URL: " + JSON.stringify(jsonThree));
+
+ let streamUrl = null;
+ if (Array.isArray(jsonThree.sources)) {
+ const hlsSource = jsonThree.sources.find(s => s.type === "hls" && s.file);
+ if (hlsSource) streamUrl = hlsSource.file;
+ }
+
+ let subtitle = null;
+ if (Array.isArray(jsonThree.tracks)) {
+ const engSub = jsonThree.tracks.find(t => t.label && t.label.toLowerCase() === "english" && t.file);
+ if (engSub) subtitle = engSub.file;
+ }
+
+ const streamHeaders = {
+ "Host": "f9.megacdn.co:2228",
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0",
+ "Accept": "*/*",
+ "Accept-Language": "en-US,en;q=0.5",
+ "Accept-Encoding": "gzip, deflate, br, zstd",
+ "Referer": "https://videostr.net/",
+ "Origin": "https://videostr.net",
+ "Connection": "keep-alive",
+ "Sec-Fetch-Dest": "empty",
+ "Sec-Fetch-Mode": "cors",
+ "Sec-Fetch-Site": "cross-site"
+ };
+
+ return JSON.stringify({
+ streams: [
+ {
+ title: "Server 1",
+ streamUrl: streamUrl || "",
+ headers: streamHeaders
+ }
+ ],
+ subtitle: subtitle || ""
+ });
+ } catch (err) {
+ return "https://error.org/";
+ }
+}
\ No newline at end of file