Major Update : Added 2Embed, Update api routes, update json response format.

This commit is contained in:
Inside4ndroid
2025-04-04 23:36:41 +01:00
parent 179c8c148f
commit ce1288490d
7 changed files with 1039 additions and 62 deletions
+57 -6
View File
@@ -1,5 +1,6 @@
import express from "express";
import { getEmbedSu } from "./src/extractors/embedsu.js";
import { getTwoEmbed } from "./src/extractors/2Embed.js";
const port = 3000;
@@ -7,12 +8,14 @@ const app = express()
app.get('/', (req, res) => {
res.status(200).json({
intro: "Welcome to the unofficial vidsrcPro provider",
routes: {
movie: "/embedsu/:movieTMDBid",
show: "/embedsu/:showTMDBid?s=seasonNumber&e=episodeNumber"
INTRO: "Welcome to the unofficial vidsrcPro provider",
ROUTES: {
movie: "/embedsu|2embed/:movieTMDBid",
show: "/embedsu|2embed/:showTMDBid?s=seasonNumber&e=episodeNumber",
all_movie: "/combined/:movieTMDBid",
all_show: "/combined/:showTMDBid?s=seasonNumber&e=episodeNumber"
},
author: "This api is developed and created by Inside4ndroid Studios"
AUTHOR: "This api is developed and created by Inside4ndroid Studios"
});
});
@@ -35,6 +38,54 @@ app.get('/embedsu/:tmdbId', async (req, res) => {
}
});
app.get('/2embed/:tmdbId', async (req, res) => {
const id = req.params.tmdbId;
const season = req.query.s;
const episode = req.query.e;
try {
if (season && episode) {
const vidsrcresponse = await getTwoEmbed(id, season, episode);
res.status(200).json(vidsrcresponse);
} else {
const vidsrcresponse = await getTwoEmbed(id, 0, 0);
res.status(200).json(vidsrcresponse);
}
} catch (error) {
console.error('Error fetching data:', error);
res.status(500).json({ error: 'Failed to fetch data' });
}
});
app.get('/combined/:tmdbId', async (req, res) => {
const id = req.params.tmdbId;
const season = req.query.s;
const episode = req.query.e;
try {
let embedSuResponse;
let twoEmbedResponse;
if (season && episode) {
embedSuResponse = await getEmbedSu(id, season, episode);
twoEmbedResponse = await getTwoEmbed(id, season, episode);
} else {
embedSuResponse = await getEmbedSu(id);
twoEmbedResponse = await getTwoEmbed(id, 0, 0);
}
const combinedResponse = {
embedsu: embedSuResponse,
twoembed: twoEmbedResponse,
};
res.status(200).json(combinedResponse);
} catch (error) {
console.error('Error fetching data:', error);
res.status(500).json({ error: 'Failed to fetch data' });
}
});
app.listen(port, () => {
console.log(`Example app listening on port http://localhost:${port}`);
console.log(`Api listening on port http://localhost:${port}`);
});