From b7f8574851e894d002352e9f0c5c037695a5e781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9luchu?= Date: Thu, 11 Jun 2020 19:12:57 +0200 Subject: [PATCH] Add Future Seasons Service - v2.2.0 --- README.md | 2 +- src/api/api.js | 20 ++++++++++++++++++++ src/api/index.js | 3 ++- src/api/routes/index.js | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7264846..bbd680c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# **Aruppi API** (v2.0.0) +# **Aruppi API** (v2.2.0) > This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture > diff --git a/src/api/api.js b/src/api/api.js index 08e497b..db065e3 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -161,6 +161,25 @@ const allSeasons = async () =>{ }; +const laterSeasons = async () =>{ + + const data = await html(`${BASE_JIKAN}season/later`).json(); + let body = data.anime; + const promises = [] + + body.map(doc =>{ + + promises.push({ + malid: doc.mal_id, + title: doc.title, + image: doc.image_url + }); + }); + + return promises; + +}; + const getLastEpisodes = async () =>{ const data = await html(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`).json(); @@ -388,6 +407,7 @@ module.exports = { getNews, season, allSeasons, + laterSeasons, getLastEpisodes, getSpecials, getMoreInfo, diff --git a/src/api/index.js b/src/api/index.js index 49ec561..4d7a913 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -7,7 +7,7 @@ router.get('/', (req, res) => { res.json({ message: 'Aruppi API - 🎏', author: 'Jéluchu', - version: '2.0.0', + version: '2.2.0', credits: 'The bitch loves APIs that offers data to Aruppi App', entries: [ { @@ -18,6 +18,7 @@ router.get('/', (req, res) => { 'News': '/api/v2/news', 'Season': '/api/v2/season/:year/:type', 'All Seasons': '/api/v2/allSeasons', + 'Futures Seasons': '/api/v2/laterSeasons', 'LastEpisodes': '/api/v2/lastEpisodes', 'Movies': '/api/v2/movies/:type/:page', 'Ovas': '/api/v2/ovas/:type/:page', diff --git a/src/api/routes/index.js b/src/api/routes/index.js index b2dbfc8..86a3d63 100644 --- a/src/api/routes/index.js +++ b/src/api/routes/index.js @@ -139,6 +139,23 @@ router.get('/allSeasons' , (req, res) =>{ }); +router.get('/laterSeasons' , (req, res) =>{ + + api.laterSeasons() + .then(archive =>{ + if (archive.length > 0) { + res.status(200).json({ + archive + }); + } else ( + res.status(500).json({ message: 'Aruppi lost in the shell'}) + ) + }).catch((err) =>{ + console.error(err); + }); + +}); + router.get('/lastEpisodes' , (req, res) =>{ api.getLastEpisodes()