@ -1,5 +1,5 @@
const rss = require ( 'rss-to-json' ) ;
const fuzzball = require ( 'fuzzball' ) ;
const {
homgot
} = require ( '../api/apiCall' ) ;
@ -74,20 +74,29 @@ const getAllAnimes = async () =>{
} ;
const getAllDirectory = async ( genres ) => {
let data ;
if ( genres === 'sfw' ) {
data = directoryAnimes . filter ( function ( item ) {
return ! item . genres . includes ( "Ecchi" ) && ! item . genres . includes ( "ecchi" ) ;
return directoryAnimes . filter ( function ( doc ) {
if ( ! doc . genres . includes ( 'Ecchi' ) && ! doc . genres . includes ( 'ecchi' ) ) {
return {
id : doc . id ,
title : doc . title ,
mal _id : doc . mal _id ,
poster : doc . poster ,
type : doc . type ,
genres : doc . genres ,
state : doc . state ,
score : doc . score ,
jkanime : false ,
description : doc . description
} ;
}
} ) ;
} else {
data = directoryAnimes ;
}
return data . map ( doc => ( {
return d irectoryAnimes . map ( doc => ( {
id : doc . id ,
title : doc . title ,
mal _title : doc . mal _title ,
mal _ id: doc . mal _id ,
poster : doc . poster ,
type : doc . type ,
genres : doc . genres ,
@ -107,7 +116,7 @@ const getAnitakume = async () => {
const body = JSON . parse ( JSON . stringify ( rss , null , 3 ) ) . items
body . map ( doc => {
let time = new Date ( doc . created )
let time = new Date ( doc . created ) ;
const monthNames = [ "Enero" , "Febrero" , "Marzo" , "Abril" , "Mayo" , "Junio" , "Julio" , "Agosto" , "Septiembre" , "Octubre" , "Noviembre" , "Diciembre" ] ;
let day = time . getDate ( )
@ -220,8 +229,13 @@ const getSpecials = async (data) =>{
const getMoreInfo = async ( title ) => {
try {
let data = directoryAnimes ;
let result = data . filter ( anime => fuzzball . ratio ( anime . title , title ) > 90 ) [ 0 ] ;
const result = directoryAnimes . filter ( x => {
if ( x . title === title ) {
return x ;
} else {
return x . title === ` ${ title } (TV) ` ? x : undefined ;
}
} ) [ 0 ] ;
if ( ! result . jkanime ) {
return {
@ -259,8 +273,13 @@ const getMoreInfo = async (title) =>{
const getEpisodes = async ( title ) => {
try {
let data = directoryAnimes ;
const result = data . filter ( x => x . title === title ) [ 0 ] ;
const result = directoryAnimes . filter ( x => {
if ( x . title === title ) {
return x ;
} else {
return x . title === ` ${ title } (TV) ` ? x : undefined ;
}
} ) [ 0 ] ;
if ( ! result . jkanime ) {
return await animeflvInfo ( result . id ) . then ( episodes => episodes || null ) ;
@ -364,7 +383,7 @@ const getThemesYear = async (year) => {
const getRandomTheme = async ( ) => {
let data = await homgot ( ` ${ BASE _THEMEMOE } roulette ` , { parse : true } ) ;
let themes = await getThemes ( data . themes )
let themes = await getThemes ( data . themes ) ;
return themes . map ( doc => ( {
name : data . name ,
@ -459,11 +478,8 @@ const getPlatforms = async (id) => {
twitter : doc . twitter ,
instagram : doc . instagram ,
webInfo : doc . webInfo ,
webpage : doc . webpage ,
latitude : doc . latitude || null ,
longitude : doc . longitude || null
webpage : doc . webpage
} ) ) ;
} else {
data = await homgot ( ` ${ BASE _ARUPPI } res/documents/animelegal/type/ ${ id } .json ` , { parse : true } ) ;
@ -505,10 +521,8 @@ const getProfilePlatform = async (id) => {
} ;
async function getRandomAnime ( ) {
let data = directoryAnimes ;
const randomNumber = Math . floor ( Math . random ( ) * data . length ) ;
let result = data [ randomNumber ] ;
const randomNumber = Math . floor ( Math . random ( ) * directoryAnimes . length ) ;
let result = directoryAnimes [ randomNumber ] ;
if ( ! result . jkanime ) {
return {