diff --git a/package-lock.json b/package-lock.json index 2d48060..a67ece3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -582,6 +582,11 @@ "har-schema": "^2.0.0" } }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + }, "helmet": { "version": "3.22.0", "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.22.0.tgz", @@ -904,6 +909,14 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, + "node-html-parser": { + "version": "1.2.18", + "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-1.2.18.tgz", + "integrity": "sha512-DypklUSTuY9JDfYWz/NZYZA8mvgKmjRmHZe7at0H6O4KoXcs8QSpnH5mFk888gLsqXXRMVNmJGk/FdqaO9T1UQ==", + "requires": { + "he": "1.1.1" + } + }, "npm": { "version": "6.14.5", "resolved": "https://registry.npmjs.org/npm/-/npm-6.14.5.tgz", diff --git a/src/api/api.js b/src/api/api.js index a948930..2314714 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -1,12 +1,13 @@ const rss = require('rss-to-json'); const cloudscraper = require('cloudscraper'); const { - BASE_ANIMEFLV, BASE_JIKAN, BASE_IVOOX, BASE_KUDASAI, BASE_PALOMITRON + BASE_ANIMEFLV, BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_KUDASAI, BASE_PALOMITRON } = require('./urls'); const schedule = async (day) =>{ const data = await cloudscraper.get(`${BASE_JIKAN}schedule/${day}`); + const promises = [] let body; switch (day) { @@ -35,7 +36,16 @@ const schedule = async (day) =>{ body = JSON.parse(data).monday; } - return Promise.all(body); + body.map(doc =>{ + + promises.push({ + title: doc.title, + malid: doc.mal_id, + image: doc.image_url + }); + }); + + return Promise.all(promises); }; @@ -132,10 +142,52 @@ const getNews = async () =>{ }; +const season = async (year, type) =>{ + + const data = await cloudscraper.get(`${BASE_JIKAN}season/${year}/${type}`); + let body = JSON.parse(data).anime; + const promises = [] + + body.map(doc =>{ + + promises.push({ + title: doc.title, + malid: doc.mal_id, + image: doc.image_url + }); + }); + + return Promise.all(promises); + +}; + +const getLastEpisodes = async () =>{ + + const data = await cloudscraper.get(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`); + let body = JSON.parse(data).episodes; + const promises = [] + + body.map(doc =>{ + + promises.push({ + id: doc.id, + title: doc.title, + image: doc.poster, + episode: doc.episode, + servers: doc.servers.map(x => x) + }); + }); + + return Promise.all(promises); + +}; + module.exports = { schedule, top, getAllAnimes, getAnitakume, - getNews + getNews, + season, + getLastEpisodes }; diff --git a/src/api/index.js b/src/api/index.js index 6a9f87b..3feb678 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -7,15 +7,17 @@ router.get('/', (req, res) => { res.json({ message: 'Aruppi API - 🎏', author: 'Jéluchu', - version: '1.0.0', + version: '2.0.0', credits: 'The bitch loves APIs that offers data to Aruppi App', entries: [ { - 'Schedule': '/api/v1/schedule/:id', - 'Top': '/api/v1/top/:type/:subtype/:page', - 'GetAllAnimes': '/api/v1/getAllAnimes', - 'GetAnitakume': '/api/v1/getAnitakume', - 'GetNews': '/api/v1/getNews' + 'Schedule': '/api/v2/schedule/:day', + 'Top': '/api/v2/top/:type/:subtype/:page', + 'GetAllAnimes': '/api/v2/getAllAnimes', + 'GetAnitakume': '/api/v2/getAnitakume', + 'GetNews': '/api/v2/getNews', + 'Season': '/api/v2/season/:year/:type', + 'GetLastEpisodes': '/api/v2/getLastEpisodes' } ] }); diff --git a/src/api/routes/index.js b/src/api/routes/index.js index 451071b..b8d93fe 100644 --- a/src/api/routes/index.js +++ b/src/api/routes/index.js @@ -73,4 +73,33 @@ router.get('/getNews' , (req, res) =>{ }); +router.get('/season/:year/:type' , (req, res) =>{ + + let year = req.params.year; + let type = req.params.type; + + api.season(year, type) + .then(season =>{ + res.status(200).json({ + season + }); + }).catch((err) =>{ + console.error(err); + }); + +}); + +router.get('/getLastEpisodes' , (req, res) =>{ + + api.getLastEpisodes() + .then(episodes =>{ + res.status(200).json({ + episodes + }); + }).catch((err) =>{ + console.error(err); + }); + +}); + module.exports = router; diff --git a/src/api/urls.js b/src/api/urls.js index 40d56e4..d20bdd7 100644 --- a/src/api/urls.js +++ b/src/api/urls.js @@ -1,5 +1,6 @@ module.exports = { BASE_ANIMEFLV: 'https://animeflv.net/', + BASE_ANIMEFLV_JELU: 'https://dev.aruppi.jeluchu.xyz/apis/animeflv/v1/', BASE_JIKAN: 'https://dev.aruppi.jeluchu.xyz/apis/jikan/v3/', BASE_IVOOX: 'https://www.ivoox.com/podcast-anitakume_fg_f1660716_filtro_1.xml', BASE_KUDASAI: 'https://somoskudasai.com/feed/',