Merge pull request #20 from aruppi/feature/improving

Fixing and adding the functions to get the related animes to a random…
pull/25/head^2
Jesús María 5 years ago committed by GitHub
commit 412897ca90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -509,6 +509,21 @@ async function getRandomAnime() {
const randomNumber = Math.floor(Math.random() * directory.length);
let result = directory[randomNumber];
if (!result.jkanime) {
return {
title: result.title || null,
poster: result.poster || null,
synopsis: result.description || null,
status: result.state || null,
type: result.type || null,
rating: result.score || null,
genres: result.genres || null,
moreInfo: await animeExtraInfo(result.mal_id).then(info => info || null),
promo: await getAnimeVideoPromo(result.mal_id).then(promo => promo || null),
characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null),
related: await getRelatedAnimesFLV(result.id)
};
}else {
return {
title: result.title || null,
poster: result.poster || null,
@ -517,11 +532,12 @@ async function getRandomAnime() {
type: result.type || null,
rating: result.score || null,
genres: result.genres || null,
moreInfo: await animeExtraInfo(result.mal_title).then(info => info || null),
promo: await getAnimeVideoPromo(result.mal_title).then(promo => promo || null),
characters: await getAnimeCharacters(result.mal_title).then(characters => characters || null),
related: await getRelatedAnimes(result.id)
moreInfo: await animeExtraInfo(result.mal_id).then(info => info || null),
promo: await getAnimeVideoPromo(result.mal_id).then(promo => promo || null),
characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null),
related: await getRelatedAnimesMAL(result.mal_id)
};
}
}
module.exports = {

@ -155,8 +155,7 @@ function getPosterAndType(id, mal_id) {
if (anime.mal_id === parseInt(mal_id)) {
return [
anime.poster,
anime.type,
anime.id
anime.type
];
}
}
@ -180,7 +179,6 @@ async function getRelatedAnimesFLV(id) {
relatedAnimes.push(
{
id: listRelated[related].split('/')[2],
title: related,
type: posterUrl[1],
poster: posterUrl[0]
@ -213,7 +211,6 @@ async function getRelatedAnimesMAL(mal_id) {
if (posterUrl !== "") {
relatedAnimes.push(
{
id: posterUrl[2],
title: related,
type: posterUrl[1],
poster: posterUrl[0]

Loading…
Cancel
Save