Fixing some issues with the directory.json in the v2 of the api

pull/26/head
capitanwesler 5 years ago
parent ebdbd6987b
commit 55b09858a3

@ -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') {
let data return directoryAnimes.filter(function (doc) {
if (genres === "sfw") { if (!doc.genres.includes('Ecchi') && !doc.genres.includes('ecchi')) {
data = directoryAnimes.filter(function (item) { return {
return !item.genres.includes("Ecchi") && !item.genres.includes("ecchi"); id: doc.id,
}) title: doc.title,
} else { mal_id: doc.mal_id,
data = directoryAnimes; poster: doc.poster,
type: doc.type,
genres: doc.genres,
state: doc.state,
score: doc.score,
jkanime: false,
description: doc.description
};
}
});
} }
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,
@ -494,7 +503,6 @@ const getDirectory = async (genres) => {
jkanime: false, jkanime: false,
description: doc.description description: doc.description
})); }));
}; };
module.exports = { module.exports = {

Loading…
Cancel
Save