Missing a function to the funcionality of the app

pull/12/head
capitanwesler 5 years ago
parent b8374812e7
commit 1532e15bbf

@ -242,6 +242,7 @@ const getMoreInfo = async (title) =>{
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
let result = data.filter(anime => anime.title === title)[0];
console.log(result);
return {
title: result.title || null,
@ -257,7 +258,7 @@ const getMoreInfo = async (title) =>{
}
} catch (e) {
console.log(e)
console.log(e);
}
};
@ -267,16 +268,16 @@ const getEpisodes = async (title) =>{
try {
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
const res = data.filter(x => x.title === title || x.mal_title === title)[0];
const result = data.filter(x => x.title === title || x.mal_title === title)[0];
if (!res.jkanime) {
return await animeflvInfo(res.id).then(episodes => episodes || null)
if (!result.jkanime) {
return await animeflvInfo(result.id).then(episodes => episodes || null);
} else {
return await jkanimeInfo(res.id).then(episodes => episodes || null)
return await jkanimeInfo(result.id).then(episodes => episodes || null);
}
} catch (e) {
console.log(e)
console.log(e);
}
};

@ -310,9 +310,9 @@ router.get('/getAnimeServers/:id([^/]+/[^/]+)' , (req, res) =>{
res.status(200).json({
servers
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
)
} else {
res.status(500).json({ message: 'Aruppi lost in the shell'});
}
}).catch((err) =>{
console.error(err);
});

@ -48,6 +48,7 @@ async function videoServersJK(id) {
}
let serverList = [];
for (let server in servers) {
serverList.push({
id: serverNames[server].toLowerCase(),
@ -61,6 +62,7 @@ async function videoServersJK(id) {
return await Promise.all(serverList);
}
async function getVideoURL(url) {
const $ = await homgot(url, { scrapy: true });
@ -192,18 +194,18 @@ const animeflvInfo = async (id) => {
};
const getAnimeCharacters = async (mal_id) =>{
const getAnimeCharacters = async(title) =>{
const dataAnime = await homgot(`${BASE_JIKAN}/anime/${mal_id}/characters_staff`, { parse: true });
const matchAnime = await getMALid(title);
try {
if(matchAnime !== null) {
return dataAnime.characters.map(item=> ({
id: item.mal_id,
name: item.name,
image: item.image_url,
role: item.role
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}/characters_staff`, { parse: true });
return data.characters.map(doc => ({
id: doc.mal_id,
name: doc.name,
image: doc.image_url,
role: doc.role
}));
}
} catch (err) {
@ -212,41 +214,40 @@ const getAnimeCharacters = async (mal_id) =>{
};
const getAnimeVideoPromo = async(mal_id) =>{
const getAnimeVideoPromo = async(title) =>{
const dataAnime = await homgot(`${BASE_JIKAN}/anime/${mal_id}`);
const matchAnime = await getMALid(title);
try {
if(matchAnime !== null) {
if(dataAnime !== null) {
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}/videos`, {parse: true});
return dataAnime.promo.map(doc => ({
return data.promo.map(doc => ({
title: doc.title,
previewImage: doc.image_url,
videoURL: doc.video_url
}));
}
} catch (err) {
console.log(err)
console.log(err);
}
};
const animeExtraInfo = async (mal_id) => {
const animeExtraInfo = async (title) => {
//@TESTING
const dataAnime = await homgot(`${BASE_JIKAN}/anime/${mal_id}`, { parse: true });
console.log(dataAnime);
try {
const matchAnime = await getMALid(title)
if(dataAnime !== null) {
try {
if(matchAnime !== null) {
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}`, {parse: true})
const promises = [];
let broadcast = '';
let broadcast = ''
Array(dataAnime).map(doc => {
Array(data).map(doc => {
let airDay = {
'mondays': 'Lunes',
@ -267,11 +268,11 @@ const animeExtraInfo = async (mal_id) => {
};
if (doc.broadcast === null) {
broadcast = null;
broadcast = null
} else {
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()];
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()]
}
promises.push({
titleJapanese: doc.title_japanese,
source: doc.source,
@ -290,7 +291,7 @@ const animeExtraInfo = async (mal_id) => {
endingThemes: doc.ending_themes || null
});
});
return data;
return Promise.all(promises);
}
} catch (err) {
@ -299,6 +300,29 @@ const animeExtraInfo = async (mal_id) => {
};
const getMALid = async(title) =>{
if (title === undefined || title === null) {
return 1
} else {
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`,{ parse: true })
const matchAnime = res.results.find(x => x.title === title);
if(typeof matchAnime === 'undefined') {
return null;
} else {
return matchAnime;
}
}
};
const imageUrlToBase64 = async (url) => {
let img = await homgot(url)
@ -456,5 +480,6 @@ module.exports = {
obtainPreviewNews,
structureThemes,
getThemes,
getMALid,
videoServersJK
}

Loading…
Cancel
Save