-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.js
60 lines (52 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import express from "express";
import { getvidsrc } from "./src/vidsrcpro.js";
import { getasiaheroku } from "./src/asiaheroku.js";
const port = 3000;
const app = express()
app.get('/', (req, res) => {
res.status(200).json({
intro: "Welcome to the unofficial vidsrcPro provider",
routes: {
movie: "/vidsrc/:movieTMDBid",
show: "/vidsrc/:showTMDBid?s=seasonNumber&e=episodeNumber"
},
author: "This api is developed and created by Inside4ndroid Studios"
});
});
app.get('/vidsrc/: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 getvidsrc(id, season, episode);
res.status(200).json(vidsrcresponse);
} else {
const vidsrcresponse = await getvidsrc(id);
res.status(200).json(vidsrcresponse);
}
} catch (error) {
console.error('Error fetching data:', error);
res.status(500).json({ error: 'Failed to fetch data' });
}
});
app.get('/asiaheroku/:tmdbId', async (req, res) => {
const id = req.params.tmdbId;
const season = req.query.s;
const episode = req.query.e;
try {
if (season && episode) {
const srcresponse = await getasiaheroku(id, season, episode);
res.status(200).json(srcresponse);
} else {
const vidsrcresponse = await getasiaheroku(id);
res.status(200).json(vidsrcresponse);
}
} 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}`);
});