forked from Davenchy/live-torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yts-api.js
47 lines (43 loc) · 1.2 KB
/
yts-api.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
const router = require("express").Router();
const axios = require("axios").default;
router.get("/list", (req, res) => {
const { query: q } = req;
axios
.get("https://yts.lt/api/v2/list_movies.json", {
params: {
query_term: q.query || q.q || 0,
page: q.page || q.p || 1,
genre: q.genre || q.g || "all",
limit: q.limit || q.l || 20,
minimum_rating: q.rate || q.r || 0,
sort_by: q.sort || q.s || "date_added",
order_by: q.order || q.o || "desc",
with_rt_ratings: true
}
})
.then(r => res.send(r.data))
.catch(err => res.status(400).send(err));
});
router.get("/movie/:id", (req, res) =>
axios
.get("https://yts.lt/api/v2/movie_details.json", {
params: {
with_images: true,
with_cast: true,
movie_id: req.params.id
}
})
.then(r => res.send(r.data))
.catch(err => res.status(400).send(err))
);
router.get("/movie/:id/suggestions", (req, res) =>
axios
.get("https://yts.lt/api/v2/movie_suggestions.json", {
params: {
movie_id: req.params.id
}
})
.then(r => res.send(r.data))
.catch(err => res.status(400).send(err))
);
module.exports = router;