Fixing the issue with randomAnime not showing the exact object and adding it to the schedule

pull/15/head
capitanwesler 5 years ago
parent 720cddb4d5
commit 7930667295

@ -532,11 +532,11 @@ const getProfilePlatform = async (id) => {
};
function getRandomAnime() {
async function getRandomAnime() {
let directory = JSON.parse(JSON.stringify(require('../assets/directory.json')));
const randomNumber = Math.floor(Math.random() * directory.length);
return directory[randomNumber];
return await getMoreInfo(directory[randomNumber].title);
}
module.exports = {

@ -16,6 +16,7 @@ router.get('/', (req, res) => {
'Schedule': '/api/v3/schedule/:day',
'Top': '/api/v3/top/:type/:subtype/:page',
'AllAnimes': '/api/v3/allAnimes',
'RandomAnime': '/api/v3/randomAnime',
'Anitakume': '/api/v3/anitakume',
'News': '/api/v3/news',
'Season': '/api/v3/season/:year/:type',

@ -517,13 +517,17 @@ router.get('/getByGenres/:genre?/:order?/:page?' , (req , res) =>{
});
router.get('/randomAnime', (req, res) => {
let randomAnime = api.getRandomAnime();
if (randomAnime) {
res.status(200).json({randomAnime});
}else {
res.status(500).json({ message: 'Aruppi lost in the shell'});
}
api.getRandomAnime()
.then(anime => {
if (anime) {
res.status(200).json(anime);
}else {
res.status(500).json({ message: 'Aruppi lost in the shell'});
}
})
.catch(error => {
console.log(error);
});
});
router.get('/destAnimePlatforms' , (req , res) =>{

@ -158,13 +158,12 @@ class ThemeParser {
for (let i = 0; i < data.length; i++) {
let parsed = await this.parseAnime(data[i])
let parsed = await this.parseAnime(data[i]);
promises.push(parsed)
if (i === data.length - 1) {
resolve(promises)
resolve(promises);
}
}
})

@ -510,13 +510,11 @@ const getThemesData = async (themes) => {
};
const getThemes = async (themes) => {
return themes.map(doc => ({
name: doc.themeName,
type: doc.themeType,
video: doc.mirror.mirrorURL
}));
};
module.exports = {

Loading…
Cancel
Save