Skip to content

Commit db25912

Browse files
committed
update: fixed broken streaming source
1 parent 35db1be commit db25912

14 files changed

Lines changed: 123 additions & 140 deletions

src/configs/player_v1.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const PLAYER_SCRIPT_URL =
2-
"https://megacloud.tv/js/player/a/e1-player.min.js";
2+
"https://megacloud.club/js/player/a/e1-player.min.js";

src/controllers/animeInfo.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import { getCachedData, setCachedData } from "../helper/cache.helper.js";
44

55
export const getAnimeInfo = async (req, res) => {
66
const { id } = req.query;
7-
const cacheKey = `animeInfo_${id}`;
7+
// const cacheKey = `animeInfo_${id}`;
88

99
try {
10-
const cachedResponse = await getCachedData(cacheKey);
11-
if (cachedResponse && Object.keys(cachedResponse).length > 0) {
12-
return cachedResponse;
13-
}
10+
// const cachedResponse = await getCachedData(cacheKey);
11+
// if (cachedResponse && Object.keys(cachedResponse).length > 0) {
12+
// return cachedResponse;
13+
// }
1414
const [seasons, data] = await Promise.all([
1515
extractSeasons(id),
1616
extractAnimeInfo(id),
1717
]);
1818
const responseData = { data: data, seasons: seasons };
19-
setCachedData(cacheKey, responseData).catch((err) => {
20-
console.error("Failed to set cache:", err);
21-
});
19+
// setCachedData(cacheKey, responseData).catch((err) => {
20+
// console.error("Failed to set cache:", err);
21+
// });
2222
return responseData;
2323
} catch (e) {
2424
console.error(e);

src/controllers/category.controller.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ export const getCategory = async (req, res, routeType) => {
66
routeType = "genre/marial-arts";
77
}
88
const requestedPage = parseInt(req.query.page) || 1;
9-
const cacheKey = `${routeType.replace(/\//g, "_")}_page_${requestedPage}`;
9+
// const cacheKey = `${routeType.replace(/\//g, "_")}_page_${requestedPage}`;
1010
try {
11-
const cachedResponse = await getCachedData(cacheKey);
12-
if (cachedResponse && Object.keys(cachedResponse).length > 0)
13-
return cachedResponse;
11+
// const cachedResponse = await getCachedData(cacheKey);
12+
// if (cachedResponse && Object.keys(cachedResponse).length > 0)
13+
// return cachedResponse;
1414
const { data, totalPages } = await extractor(routeType, requestedPage);
1515
if (requestedPage > totalPages) {
1616
const error = new Error("Requested page exceeds total available pages.");
1717
error.status = 404;
1818
throw error;
1919
}
2020
const responseData = { totalPages: totalPages, data: data };
21-
setCachedData(cacheKey, responseData).catch((err) => {
22-
console.error("Failed to set cache:", err);
23-
});
21+
// setCachedData(cacheKey, responseData).catch((err) => {
22+
// console.error("Failed to set cache:", err);
23+
// });
2424
return responseData;
2525
} catch (e) {
2626
console.error(e);

src/controllers/episodeList.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { getCachedData, setCachedData } from "../helper/cache.helper.js";
33

44
export const getEpisodes = async (req,res) => {
55
const { id } = req.params;
6-
const cacheKey = `episodes_${id}`;
6+
// const cacheKey = `episodes_${id}`;
77
try {
8-
const cachedResponse = await getCachedData(cacheKey);
9-
if (cachedResponse && Object.keys(cachedResponse).length > 0) {
10-
return cachedResponse;
11-
}
8+
// const cachedResponse = await getCachedData(cacheKey);
9+
// if (cachedResponse && Object.keys(cachedResponse).length > 0) {
10+
// return cachedResponse;
11+
// }
1212
const data = await extractEpisodesList(encodeURIComponent(id));
13-
setCachedData(cacheKey, data).catch((err) => {
14-
console.error("Failed to set cache:", err);
15-
});
13+
// setCachedData(cacheKey, data).catch((err) => {
14+
// console.error("Failed to set cache:", err);
15+
// });
1616
return data;
1717
} catch (e) {
1818
console.error("Error fetching episodes:", e);

src/controllers/homeInfo.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const genres = routeTypes
1111
.map((genre) => genre.replace("genre/", ""));
1212

1313
export const getHomeInfo = async (req,res) => {
14-
const cacheKey = "homeInfo";
14+
// const cacheKey = "homeInfo";
1515
try {
16-
const cachedResponse = await getCachedData(cacheKey);
17-
if (cachedResponse && Object.keys(cachedResponse).length > 0) {
18-
return cachedResponse;
19-
}
16+
// const cachedResponse = await getCachedData(cacheKey);
17+
// if (cachedResponse && Object.keys(cachedResponse).length > 0) {
18+
// return cachedResponse;
19+
// }
2020
const [
2121
spotlights,
2222
trending,
@@ -57,9 +57,9 @@ export const getHomeInfo = async (req,res) => {
5757
genres,
5858
};
5959

60-
setCachedData(cacheKey, responseData).catch((err) => {
61-
console.error("Failed to set cache:", err);
62-
});
60+
// setCachedData(cacheKey, responseData).catch((err) => {
61+
// console.error("Failed to set cache:", err);
62+
// });
6363
return responseData;
6464
} catch (fetchError) {
6565
console.error("Error fetching fresh data:", fetchError);

src/controllers/producer.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ export const getProducer = async (req) => {
55
const { id } = req.params;
66
const routeType = `producer/${id}`;
77
const requestedPage = parseInt(req.query.page) || 1;
8-
const cacheKey = `${routeType.replace(/\//g, "_")}_page_${requestedPage}`;
8+
// const cacheKey = `${routeType.replace(/\//g, "_")}_page_${requestedPage}`;
99
try {
10-
const cachedResponse = await getCachedData(cacheKey);
11-
if (cachedResponse && Object.keys(cachedResponse).length > 0) {
12-
return cachedResponse;
13-
}
10+
// const cachedResponse = await getCachedData(cacheKey);
11+
// if (cachedResponse && Object.keys(cachedResponse).length > 0) {
12+
// return cachedResponse;
13+
// }
1414
const [data, totalPages] = await extractPage(requestedPage, routeType);
1515
if (requestedPage > totalPages) {
1616
const error = new Error("Requested page exceeds total available pages.");
1717
error.status = 404;
1818
throw error;
1919
}
2020
const responseData = { totalPages: totalPages, data: data };
21-
setCachedData(cacheKey, responseData).catch((err) => {
22-
console.error("Failed to set cache:", err);
23-
});
21+
// setCachedData(cacheKey, responseData).catch((err) => {
22+
// console.error("Failed to set cache:", err);
23+
// });
2424
return { data, totalPages };
2525
} catch (e) {
2626
console.error(e);

src/controllers/streamInfo.controller.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@ export const getStreamInfo = async (req) => {
55
const input = req.query.id;
66
const server = req.query.server;
77
const type = req.query.type;
8-
const anilistId = req.query.anilistId || null;
9-
const epnum = req.query.epnum || null;
108
const match = input.match(/ep=(\d+)/);
119
if (!match) throw new Error("Invalid URL format");
1210
const finalId = match[1];
13-
const streamingInfo = await extractStreamingInfo(
14-
finalId,
15-
server,
16-
type,
17-
anilistId,
18-
epnum
19-
);
11+
const streamingInfo = await extractStreamingInfo(finalId, server, type);
2012
return streamingInfo;
2113
} catch (e) {
2214
console.error(e);

src/controllers/topten.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import extractTopTen from "../extractors/topten.extractor.js";
22
import { getCachedData, setCachedData } from "../helper/cache.helper.js";
33

44
export const getTopTen = async (req,res) => {
5-
const cacheKey = "topTen";
5+
// const cacheKey = "topTen";
66
try {
7-
const cachedResponse = await getCachedData(cacheKey);
8-
if (cachedResponse && Object.keys(cachedResponse).length > 0) {
9-
return cachedResponse;
10-
}
7+
// const cachedResponse = await getCachedData(cacheKey);
8+
// if (cachedResponse && Object.keys(cachedResponse).length > 0) {
9+
// return cachedResponse;
10+
// }
1111
const topTen = await extractTopTen();
12-
await setCachedData(cacheKey, topTen).catch((err) => {
13-
console.error("Failed to set cache:", err);
14-
});
12+
// await setCachedData(cacheKey, topTen).catch((err) => {
13+
// console.error("Failed to set cache:", err);
14+
// });
1515
return topTen;
1616
} catch (e) {
1717
console.error(e);

src/extractors/streamInfo.extractor.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import axios from "axios";
22
import * as cheerio from "cheerio";
33
import { v1_base_url } from "../utils/base_v1.js";
4-
import decryptMegacloud from "../parsers/decryptors/megacloud.decryptor.js";
5-
import AniplayExtractor from "../parsers/aniplay.parser.js";
4+
// import decryptMegacloud from "../parsers/decryptors/megacloud.decryptor.js";
5+
// import AniplayExtractor from "../parsers/aniplay.parser.js";
6+
import { decryptSources_v1 } from "../parsers/decryptors/decrypt_v1.decryptor.js";
67

78
export async function extractServers(id) {
89
try {
@@ -15,6 +16,7 @@ export async function extractServers(id) {
1516
const data_id = $(element).attr("data-id");
1617
const server_id = $(element).attr("data-server-id");
1718
const type = $(element).attr("data-type");
19+
1820
const serverName = $(element).find("a").text().trim();
1921
serverData.push({
2022
type,
@@ -30,13 +32,7 @@ export async function extractServers(id) {
3032
}
3133
}
3234

33-
async function extractStreamingInfo(
34-
id,
35-
name,
36-
type,
37-
anilistId = null,
38-
epnum = null
39-
) {
35+
async function extractStreamingInfo(id, name, type) {
4036
try {
4137
const servers = await extractServers(id.split("?ep=").pop());
4238
let requestedServer = servers.filter(
@@ -51,17 +47,12 @@ async function extractStreamingInfo(
5147
server.type.toLowerCase() === "raw"
5248
);
5349
}
54-
if (requestedServer.length === 0 && name.toLowerCase() !== "hd-4") {
50+
if (requestedServer.length === 0) {
5551
throw new Error(
5652
`No matching server found for name: ${name}, type: ${type}`
5753
);
5854
}
59-
if (name.toLowerCase() === "hd-4" && anilistId && epnum) {
60-
const extractor = new AniplayExtractor();
61-
const streamingLink = await extractor.fetchEpisode(anilistId, epnum);
62-
return { streamingLink: streamingLink.sources, servers };
63-
}
64-
const streamingLink = await decryptMegacloud(
55+
const streamingLink = await decryptSources_v1(
6556
requestedServer[0].data_id,
6657
name,
6758
type

src/helper/getKey.helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ function getKeys(script) {
3131
}).filter((pair) => pair.length > 0);
3232
}
3333

34-
export default getKeys;
34+
export default getKeys;

0 commit comments

Comments
 (0)