Merge pull request #26 from aruppi/feature/improving

Deleting fuzzball unused package.
pull/29/head
Jesús María 5 years ago committed by GitHub
commit 2394fff966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,7 +47,6 @@
"compose-middleware": "^5.0.1", "compose-middleware": "^5.0.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.17.1", "express": "^4.17.1",
"fuzzball": "^1.3.1",
"got": "^11.8.1", "got": "^11.8.1",
"helmet": "^4.3.1", "helmet": "^4.3.1",
"rss-to-json": "^1.1.2", "rss-to-json": "^1.1.2",

@ -1,5 +1,5 @@
const rss = require('rss-to-json'); const rss = require('rss-to-json');
const fuzzball = require('fuzzball');
const { const {
homgot homgot
} = require('../api/apiCall'); } = require('../api/apiCall');
@ -30,17 +30,17 @@ const {
BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, BASE_THEMEMOE, BASE_ANIMEFLV, BASE_ARUPPI BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, BASE_THEMEMOE, BASE_ANIMEFLV, BASE_ARUPPI
} = require('./urls'); } = require('./urls');
const schedule = async (day) =>{ const schedule = async (day) => {
const data = await homgot(`${BASE_JIKAN}schedule/${day.current}`, { parse: true }); const data = await homgot(`${BASE_JIKAN}schedule/${day.current}`, { parse: true });
return data[day.current].map(doc =>({ return data[day.current].map(doc => ({
title: doc.title, title: doc.title,
malid: doc.mal_id, malid: doc.mal_id,
image: doc.image_url image: doc.image_url
})); }));
}; };
const top = async (top) =>{ const top = async (top) => {
let data; let data;
if (top.subtype !== undefined) { if (top.subtype !== undefined) {
@ -49,7 +49,7 @@ const top = async (top) =>{
data = await homgot(`${BASE_JIKAN}top/${top.type}/${top.page}`, { parse: true }); data = await homgot(`${BASE_JIKAN}top/${top.type}/${top.page}`, { parse: true });
} }
return data.top.map(doc =>({ return data.top.map(doc => ({
rank: doc.rank, rank: doc.rank,
title: doc.title, title: doc.title,
url: doc.url, url: doc.url,
@ -61,7 +61,7 @@ const top = async (top) =>{
})); }));
}; };
const getAllAnimes = async () =>{ const getAllAnimes = async () => {
let data = await homgot(`${BASE_ANIMEFLV}api/animes/list`, { parse: true }) let data = await homgot(`${BASE_ANIMEFLV}api/animes/list`, { parse: true })
return data.map(item => ({ return data.map(item => ({
@ -74,20 +74,29 @@ const getAllAnimes = async () =>{
}; };
const getAllDirectory = async (genres) => { const getAllDirectory = async (genres) => {
let data;
if (genres === 'sfw') { if (genres === 'sfw') {
data = directoryAnimes.filter(function (item) { return directoryAnimes.filter(function (doc) {
return !item.genres.includes("Ecchi") && !item.genres.includes("ecchi"); 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 directoryAnimes.map(doc => ({
id: doc.id, id: doc.id,
title: doc.title, title: doc.title,
mal_title: doc.mal_title, mal_id: doc.mal_id,
poster: doc.poster, poster: doc.poster,
type: doc.type, type: doc.type,
genres: doc.genres, genres: doc.genres,
@ -105,9 +114,9 @@ const getAnitakume = async () => {
await rss.load(BASE_IVOOX).then(rss => { await rss.load(BASE_IVOOX).then(rss => {
const body = JSON.parse(JSON.stringify(rss, null, 3)).items const body = JSON.parse(JSON.stringify(rss, null, 3)).items
body.map(doc =>{ 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"]; const monthNames = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
let day = time.getDate() let day = time.getDate()
@ -115,9 +124,9 @@ const getAnitakume = async () => {
let year = time.getFullYear() let year = time.getFullYear()
let date let date
if(month < 10){ if (month < 10) {
date = `${day} de 0${month} de ${year}` date = `${day} de 0${month} de ${year}`
}else{ } else {
date = `${day} de ${month} de ${year}` date = `${day} de ${month} de ${year}`
} }
@ -135,10 +144,10 @@ const getAnitakume = async () => {
}; };
const getNews = async (pageRss) =>{ const getNews = async (pageRss) => {
let promises = []; let promises = [];
for(let i = 0; i <= pageRss.length -1; i++) { for (let i = 0; i <= pageRss.length - 1; i++) {
await rss.load(pageRss[i].url).then(rss => { await rss.load(pageRss[i].url).then(rss => {
const body = JSON.parse(JSON.stringify(rss, null, 3)).items const body = JSON.parse(JSON.stringify(rss, null, 3)).items
@ -158,36 +167,36 @@ const getNews = async (pageRss) =>{
return promises; return promises;
}; };
const season = async (season) =>{ const season = async (season) => {
const data = await homgot(`${BASE_JIKAN}season/${season.year}/${season.type}`, { parse: true }); const data = await homgot(`${BASE_JIKAN}season/${season.year}/${season.type}`, { parse: true });
return data.anime.map(doc =>({ return data.anime.map(doc => ({
title: doc.title, title: doc.title,
image: doc.image_url, image: doc.image_url,
genres: doc.genres.map(x => x.name) genres: doc.genres.map(x => x.name)
})); }));
}; };
const allSeasons = async () =>{ const allSeasons = async () => {
const data = await homgot(`${BASE_JIKAN}season/archive`, { parse: true }); const data = await homgot(`${BASE_JIKAN}season/archive`, { parse: true });
return data.archive.map(doc =>({ return data.archive.map(doc => ({
year: doc.year, year: doc.year,
seasons: doc.seasons, seasons: doc.seasons,
})); }));
}; };
const laterSeasons = async () =>{ const laterSeasons = async () => {
const data = await homgot(`${BASE_JIKAN}season/later`, { parse: true }); const data = await homgot(`${BASE_JIKAN}season/later`, { parse: true });
return data.anime.map(doc =>({ return data.anime.map(doc => ({
title: doc.title, title: doc.title,
image: doc.image_url, image: doc.image_url,
malink: doc.url malink: doc.url
})); }));
}; };
const getLastEpisodes = async () =>{ const getLastEpisodes = async () => {
const data = await homgot(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`, { parse: true }); const data = await homgot(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`, { parse: true });
return await Promise.all(data.episodes.map(async (item) => ({ return await Promise.all(data.episodes.map(async (item) => ({
@ -199,29 +208,34 @@ const getLastEpisodes = async () =>{
}))); })));
}; };
const getSpecials = async (data) =>{ const getSpecials = async (data) => {
const res = await homgot(`${BASE_ANIMEFLV_JELU}${data.url}/${data.type}/${data.page}`, { parse: true }); const res = await homgot(`${BASE_ANIMEFLV_JELU}${data.url}/${data.type}/${data.page}`, { parse: true });
return res[data.prop].map(doc =>({ return res[data.prop].map(doc => ({
id: doc.id, id: doc.id,
title: doc.title, title: doc.title,
type: data.url.toLowerCase(), type: data.url.toLowerCase(),
page: data.page, page: data.page,
banner: doc.banner, banner: doc.banner,
image: doc.poster, image: doc.poster,
synopsis: doc.synopsis, synopsis: doc.synopsis,
status: doc.debut, status: doc.debut,
rate: doc.rating, rate: doc.rating,
genres: doc.genres.map(x => x), genres: doc.genres.map(x => x),
episodes: doc.episodes.map(x => x) episodes: doc.episodes.map(x => x)
})); }));
}; };
const getMoreInfo = async (title) =>{ const getMoreInfo = async (title) => {
try { try {
let data = directoryAnimes; const result = directoryAnimes.filter(x => {
let result = data.filter(anime => fuzzball.ratio(anime.title, title) > 90)[0]; if (x.title === title) {
return x;
} else {
return x.title === `${title} (TV)` ? x : undefined;
}
})[0];
if (!result.jkanime) { if (!result.jkanime) {
return { return {
@ -237,7 +251,7 @@ const getMoreInfo = async (title) =>{
characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null), characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null),
related: await getRelatedAnimesFLV(result.id) related: await getRelatedAnimesFLV(result.id)
}; };
}else { } else {
return { return {
title: result.title || null, title: result.title || null,
poster: result.poster || null, poster: result.poster || null,
@ -257,10 +271,15 @@ const getMoreInfo = async (title) =>{
} }
}; };
const getEpisodes = async (title) =>{ const getEpisodes = async (title) => {
try { try {
let data = directoryAnimes; const result = directoryAnimes.filter(x => {
const result = data.filter(x => x.title === title)[0]; if (x.title === title) {
return x;
} else {
return x.title === `${title} (TV)` ? x : undefined;
}
})[0];
if (!result.jkanime) { if (!result.jkanime) {
return await animeflvInfo(result.id).then(episodes => episodes || null); return await animeflvInfo(result.id).then(episodes => episodes || null);
@ -284,12 +303,12 @@ const getAnimeServers = async (id) => {
} }
}; };
const search = async (title) =>{ return await searchAnime(title); }; const search = async (title) => { return await searchAnime(title); };
const getImages = async (query) => { const getImages = async (query) => {
try { try {
const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, { parse: true }); const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, { parse: true });
return data.data.result.items.map(doc =>({ return data.data.result.items.map(doc => ({
type: doc.thumb_type, type: doc.thumb_type,
thumbnail: `https:${doc.thumbnail}`, thumbnail: `https:${doc.thumbnail}`,
fullsize: `https:${doc.media_fullsize}` fullsize: `https:${doc.media_fullsize}`
@ -302,12 +321,12 @@ const getImages = async (query) => {
const getYoutubeVideos = async (channelId) => { const getYoutubeVideos = async (channelId) => {
const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, { parse: true }); const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, { parse: true });
return data[channelId.prop].map(doc =>({ return data[channelId.prop].map(doc => ({
title: doc.snippet.title, title: doc.snippet.title,
videoId: doc.id.videoId, videoId: doc.id.videoId,
thumbDefault: doc.snippet.thumbnails.default.url, thumbDefault: doc.snippet.thumbnails.default.url,
thumbMedium: doc.snippet.thumbnails.medium.url, thumbMedium: doc.snippet.thumbnails.medium.url,
thumbHigh: doc.snippet.thumbnails.high.url thumbHigh: doc.snippet.thumbnails.high.url
})); }));
}; };
@ -315,7 +334,7 @@ const getSectionYoutubeVideos = async (type) => {
if (type === 'learn') { if (type === 'learn') {
let data = await homgot(`${BASE_YOUTUBE}UCCyQwSS6m2mVB0-H2FOFJtw&part=snippet,id&order=date&maxResults=50`, { parse: true }); let data = await homgot(`${BASE_YOUTUBE}UCCyQwSS6m2mVB0-H2FOFJtw&part=snippet,id&order=date&maxResults=50`, { parse: true });
return data.items.map(doc =>({ return data.items.map(doc => ({
title: doc.snippet.title, title: doc.snippet.title,
videoId: doc.id.videoId, videoId: doc.id.videoId,
thumbDefault: doc.snippet.thumbnails.default.url, thumbDefault: doc.snippet.thumbnails.default.url,
@ -325,18 +344,18 @@ const getSectionYoutubeVideos = async (type) => {
} else if (type === 'amv') { } else if (type === 'amv') {
let yt1 = await homgot(`${BASE_YOUTUBE}UCkTFkshjAsLMKwhAe1uPC1A&part=snippet,id&order=date&maxResults=25`, { parse: true }); let yt1 = await homgot(`${BASE_YOUTUBE}UCkTFkshjAsLMKwhAe1uPC1A&part=snippet,id&order=date&maxResults=25`, { parse: true });
let yt2 = await homgot(`${BASE_YOUTUBE}UC2cpvlLeowpqnR6bQofwNew&part=snippet,id&order=date&maxResults=25`, { parse: true }); let yt2 = await homgot(`${BASE_YOUTUBE}UC2cpvlLeowpqnR6bQofwNew&part=snippet,id&order=date&maxResults=25`, { parse: true });
return yt1.items.concat(yt2.items).map(doc =>({ return yt1.items.concat(yt2.items).map(doc => ({
title: doc.snippet.title, title: doc.snippet.title,
videoId: doc.id.videoId, videoId: doc.id.videoId,
thumbDefault: doc.snippet.thumbnails.default.url, thumbDefault: doc.snippet.thumbnails.default.url,
thumbMedium: doc.snippet.thumbnails.medium.url, thumbMedium: doc.snippet.thumbnails.medium.url,
thumbHigh: doc.snippet.thumbnails.high.url thumbHigh: doc.snippet.thumbnails.high.url
})); }));
} else if (type === 'produccer'){ } else if (type === 'produccer') {
let yt1 = await homgot(`${BASE_YOUTUBE}UC-5MT-BUxTzkPTWMediyV0w&part=snippet,id&order=date&maxResults=25`, { parse: true }); let yt1 = await homgot(`${BASE_YOUTUBE}UC-5MT-BUxTzkPTWMediyV0w&part=snippet,id&order=date&maxResults=25`, { parse: true });
let yt2 = await homgot(`${BASE_YOUTUBE}UCwUeTOXP3DD9DIvHttowuSA&part=snippet,id&order=date&maxResults=25`, { parse: true }); let yt2 = await homgot(`${BASE_YOUTUBE}UCwUeTOXP3DD9DIvHttowuSA&part=snippet,id&order=date&maxResults=25`, { parse: true });
let yt3 = await homgot(`${BASE_YOUTUBE}UCA8Vj7nN8bzT3rsukD2ypUg&part=snippet,id&order=date&maxResults=25`, { parse: true }); let yt3 = await homgot(`${BASE_YOUTUBE}UCA8Vj7nN8bzT3rsukD2ypUg&part=snippet,id&order=date&maxResults=25`, { parse: true });
return yt1.items.concat(yt2.items.concat(yt3.items)).map(doc =>({ return yt1.items.concat(yt2.items.concat(yt3.items)).map(doc => ({
title: doc.snippet.title, title: doc.snippet.title,
videoId: doc.id.videoId, videoId: doc.id.videoId,
thumbDefault: doc.snippet.thumbnails.default.url, thumbDefault: doc.snippet.thumbnails.default.url,
@ -364,9 +383,9 @@ const getThemesYear = async (year) => {
const getRandomTheme = async () => { const getRandomTheme = async () => {
let data = await homgot(`${BASE_THEMEMOE}roulette`, { parse: true }); 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 =>({ return themes.map(doc => ({
name: data.name, name: data.name,
title: doc.name, title: doc.name,
link: doc.video link: doc.video
@ -381,18 +400,18 @@ const getArtist = async (id) => {
} }
}; };
const getAnimeGenres = async(genres) => { const getAnimeGenres = async (genres) => {
let res; let res;
let promises = []; let promises = [];
if (genres.genre === undefined && genres.page === undefined && genres.order === undefined) { if (genres.genre === undefined && genres.page === undefined && genres.order === undefined) {
return animeGenres; return animeGenres;
} else { } else {
if (genres.page !== undefined) { if (genres.page !== undefined) {
res = await homgot(`${BASE_ANIMEFLV_JELU}Genres/${genres.genre}/${genres.order}/${genres.page}`,{ parse: true }) res = await homgot(`${BASE_ANIMEFLV_JELU}Genres/${genres.genre}/${genres.order}/${genres.page}`, { parse: true })
} else { } else {
res = await homgot(`${BASE_ANIMEFLV_JELU}Genres/${genres.genre}/${genres.order}/1`,{ parse: true }) res = await homgot(`${BASE_ANIMEFLV_JELU}Genres/${genres.genre}/${genres.order}/1`, { parse: true })
} }
let data = res.animes let data = res.animes
@ -421,7 +440,7 @@ const getAllThemes = async () => animeThemes;
const getDestAnimePlatforms = async () => { const getDestAnimePlatforms = async () => {
let data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/top.json`, { parse: true }); let data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/top.json`, { parse: true });
return data.map(doc =>({ return data.map(doc => ({
id: doc.id, id: doc.id,
name: doc.name, name: doc.name,
logo: doc.logo, logo: doc.logo,
@ -436,7 +455,7 @@ const getPlatforms = async (id) => {
data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/typeplatforms.json`, { parse: true }); data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/typeplatforms.json`, { parse: true });
return data.map(doc =>({ return data.map(doc => ({
id: doc.id, id: doc.id,
name: doc.name, name: doc.name,
comming: doc.comming || false, comming: doc.comming || false,
@ -445,30 +464,27 @@ const getPlatforms = async (id) => {
} if (id === "producers" || id === "apps" || id === "publishers" || "events") { } if (id === "producers" || id === "apps" || id === "publishers" || "events") {
data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/type/${id}.json`, { parse: true }); data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/type/${id}.json`, { parse: true });
return data.map(doc =>({
id: doc.id,
name: doc.name,
logo: doc.logo,
cover: doc.cover,
description: doc.description,
type: doc.type,
moreInfo: doc.moreInfo,
facebook: doc.facebook,
twitter: doc.twitter,
instagram: doc.instagram,
webInfo: doc.webInfo,
webpage: doc.webpage,
latitude: doc.latitude || null,
longitude: doc.longitude || null
}));
return data.map(doc => ({
id: doc.id,
name: doc.name,
logo: doc.logo,
cover: doc.cover,
description: doc.description,
type: doc.type,
moreInfo: doc.moreInfo,
facebook: doc.facebook,
twitter: doc.twitter,
instagram: doc.instagram,
webInfo: doc.webInfo,
webpage: doc.webpage
}));
} else { } else {
data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/type/${id}.json`, { parse: true }); data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/type/${id}.json`, { parse: true });
return data.map(doc =>({ return data.map(doc => ({
id: doc.id, id: doc.id,
name: doc.name, name: doc.name,
type: doc.type, type: doc.type,
@ -482,10 +498,10 @@ const getPlatforms = async (id) => {
const getProfilePlatform = async (id) => { const getProfilePlatform = async (id) => {
let data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/platforms/${id}.json`, { parse: true }); let data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/platforms/${id}.json`, { parse: true });
let channelId = { id: data[0].youtubeId, part: 'snippet,id', order: 'date', maxResults: '50', prop: 'items' }; let channelId = { id: data[0].youtubeId, part: 'snippet,id', order: 'date', maxResults: '50', prop: 'items' };
let videos = await getYoutubeVideos(channelId) let videos = await getYoutubeVideos(channelId)
return data.map(doc =>({ return data.map(doc => ({
id: doc.id, id: doc.id,
name: doc.name, name: doc.name,
logo: doc.logo, logo: doc.logo,
@ -505,10 +521,8 @@ const getProfilePlatform = async (id) => {
}; };
async function getRandomAnime() { async function getRandomAnime() {
let data = directoryAnimes; const randomNumber = Math.floor(Math.random() * directoryAnimes.length);
let result = directoryAnimes[randomNumber];
const randomNumber = Math.floor(Math.random() * data.length);
let result = data[randomNumber];
if (!result.jkanime) { if (!result.jkanime) {
return { return {
@ -524,7 +538,7 @@ async function getRandomAnime() {
characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null), characters: await getAnimeCharacters(result.mal_id).then(characters => characters || null),
related: await getRelatedAnimesFLV(result.id) related: await getRelatedAnimesFLV(result.id)
}; };
}else { } else {
return { return {
title: result.title || null, title: result.title || null,
poster: result.poster || null, poster: result.poster || null,

@ -60,8 +60,8 @@ router.get('/allAnimes' , (req, res) =>{
}); });
router.get('/allDirectory/:genres?' , (req, res) =>{ router.get('/allDirectory/:genres?' , (req, res) =>{
let genres = req.params.genres; let genres = req.params.genres;
api.getAllDirectory(genres) api.getAllDirectory(genres)
.then(directory =>{ .then(directory =>{
if (directory.length > 0) { if (directory.length > 0) {

@ -57172,6 +57172,7 @@
"Shounen" "Shounen"
], ],
"state": "En emision", "state": "En emision",
"score": "4.4",
"jkanime": false, "jkanime": false,
"description": "Un fatídico día, toda la humanidad quedó petrificada por un destello de luz cegadora. Después de varios milenios, el estudiante de instituto Taiju se despierta y se encuentra perdido en un mundo de estatuas. Sin embargo, no está solo; su amigo, amante de la ciencia, ha estado trabajando durante unos meses y tiene un gran plan en mente: ¡poner en marcha la civilización con el poder de la ciencia!" "description": "Un fatídico día, toda la humanidad quedó petrificada por un destello de luz cegadora. Después de varios milenios, el estudiante de instituto Taiju se despierta y se encuentra perdido en un mundo de estatuas. Sin embargo, no está solo; su amigo, amante de la ciencia, ha estado trabajando durante unos meses y tiene un gran plan en mente: ¡poner en marcha la civilización con el poder de la ciencia!"
} }

@ -140,10 +140,8 @@ const jkanimeInfo = async (id) => {
}; };
function getPosterAndType(id, mal_id) { function getPosterAndType(id, mal_id) {
let data = directoryAnimes;
if (id) { if (id) {
for (let anime of data) { for (let anime of directoryAnimes) {
if (anime.id === id) { if (anime.id === id) {
return [ return [
anime.poster, anime.poster,
@ -154,7 +152,7 @@ function getPosterAndType(id, mal_id) {
} }
if (mal_id) { if (mal_id) {
for (let anime of data) { for (let anime of directoryAnimes) {
if (anime.mal_id === parseInt(mal_id)) { if (anime.mal_id === parseInt(mal_id)) {
return [ return [
anime.poster, anime.poster,
@ -401,9 +399,8 @@ const imageUrlToBase64 = async (url) => {
}; };
const searchAnime = async (query) => { const searchAnime = async (query) => {
let data = directoryAnimes;
let queryLowerCase = query.toLowerCase(); let queryLowerCase = query.toLowerCase();
const res = data.filter(x => x.title.toLowerCase().includes(queryLowerCase)); const res = directoryAnimes.filter(x => x.title.toLowerCase().includes(queryLowerCase));
return res.map(doc => ({ return res.map(doc => ({
id: doc.id || null, id: doc.id || null,

@ -62,7 +62,7 @@ const top = async (type, subtype, page) =>{
const getAllAnimes = async () =>{ const getAllAnimes = async () =>{
let data = await getAnimes() let data = await getAnimes();
return data.map(item => ({ return data.map(item => ({
index: item[0], index: item[0],
@ -78,7 +78,7 @@ const getAllDirectory = async (genres) =>{ return await getDirectory(genres); };
const getAnitakume = async () =>{ const getAnitakume = async () =>{
const promises = [] const promises = [];
await rss.load(BASE_IVOOX).then(rss => { await rss.load(BASE_IVOOX).then(rss => {
@ -121,7 +121,7 @@ const getNews = async (pageRss) =>{
await rss.load(pageRss[i].url).then(rss => { await rss.load(pageRss[i].url).then(rss => {
const body = JSON.parse(JSON.stringify(rss, null, 3)).items const body = JSON.parse(JSON.stringify(rss, null, 3)).items;
body.map(doc => { body.map(doc => {
promises.push({ promises.push({
@ -247,9 +247,13 @@ const getMoreInfo = async (title) =>{
try { try {
const promises = []; const promises = [];
const res = directoryAnimes.filter(x => {
let data = directoryAnimes; if (x.title === title) {
const res = data.filter(x => x.title === title)[0]; return x;
} else {
return x.title === `${title} (TV)` ? x : undefined;
}
})[0];
if (!res.jkanime) { if (!res.jkanime) {
promises.push({ promises.push({
@ -307,7 +311,7 @@ const getImages = async (query) => {
let options = { parse: true } let options = { parse: true }
const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, options); const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, options);
const body = data.data.result.items; const body = data.data.result.items;
const promises = [] const promises = [];
body.map(doc =>{ body.map(doc =>{
@ -328,7 +332,7 @@ const getYoutubeVideos = async (channelId) => {
let options = { parse: true } let options = { parse: true }
const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, options); const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, options);
const body = data[channelId.prop]; const body = data[channelId.prop];
const promises = [] const promises = [];
body.map(doc =>{ body.map(doc =>{
@ -351,12 +355,12 @@ const getRadioStations = async () => {
} }
const getOpAndEd = async (title) => { const getOpAndEd = async (title) => {
let data = await parserThemes.serie(title) let data = await parserThemes.serie(title);
return await structureThemes(data, true) return await structureThemes(data, true);
}; };
const getThemesYear = async (year) => { const getThemesYear = async (year) => {
let data = [] let data = [];
if (year === undefined) { if (year === undefined) {
return await parserThemes.allYears(); return await parserThemes.allYears();
@ -369,7 +373,7 @@ const getThemesYear = async (year) => {
const getRandomTheme = async () => { const getRandomTheme = async () => {
let promise = [] let promise = [];
let options = { parse: true } let options = { parse: true }
const data = await homgot(`${BASE_THEMEMOE}roulette`, options); const data = await homgot(`${BASE_THEMEMOE}roulette`, options);
let themes = await getThemes(data.themes) let themes = await getThemes(data.themes)
@ -378,14 +382,14 @@ const getRandomTheme = async () => {
name: data.name, name: data.name,
title: themes[0].name, title: themes[0].name,
link: themes[0].video link: themes[0].video
}) });
return promise; return promise;
}; };
const getArtist = async (id) => { const getArtist = async (id) => {
let data let data;
if (id === undefined) { if (id === undefined) {
return await parserThemes.artists(); return await parserThemes.artists();

@ -307,7 +307,7 @@ const searchAnime = async (query) => {
const obtainAnimeSeries = async ($) => { const obtainAnimeSeries = async ($) => {
let promises = [] let promises = [];
await asyncForEach($('div.Container ul.ListAnimes li article'), async (element) => { await asyncForEach($('div.Container ul.ListAnimes li article'), async (element) => {
@ -472,20 +472,29 @@ const getThemes = async (themes) => {
const getAnimes = async () => await homgot(`${BASE_ANIMEFLV}api/animes/list`, { parse: true }); const getAnimes = async () => await homgot(`${BASE_ANIMEFLV}api/animes/list`, { parse: true });
const getDirectory = async (genres) => { const getDirectory = async (genres) => {
if (genres === 'sfw') {
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
};
}
});
}
let data return directoryAnimes.map(doc => ({
if (genres === "sfw") {
data = directoryAnimes.filter(function (item) {
return !item.genres.includes("Ecchi") && !item.genres.includes("ecchi");
})
} else {
data = directoryAnimes;
}
return data.map(doc => ({
id: doc.id, id: doc.id,
title: doc.title, title: doc.title,
mal_title: doc.mal_title, mal_id: doc.mal_id,
poster: doc.poster, poster: doc.poster,
type: doc.type, type: doc.type,
genres: doc.genres, genres: doc.genres,
@ -493,8 +502,7 @@ const getDirectory = async (genres) => {
score: doc.score, score: doc.score,
jkanime: false, jkanime: false,
description: doc.description description: doc.description
})); }));
}; };
module.exports = { module.exports = {

Loading…
Cancel
Save