Produccers refactor, Type Related and Movies, Ovas, Specials, etc

pull/15/head
Jéluchu 5 years ago
parent d671c6fc58
commit 17510dbb5b

@ -224,7 +224,8 @@ const getSpecials = async (data) =>{
return res[data.prop].map(doc =>({
id: doc.id,
title: doc.title,
type: doc.type,
type: data.url.toLowerCase(),
page: data.page,
banner: doc.banner,
image: doc.poster,
synopsis: doc.synopsis,
@ -471,6 +472,25 @@ const getPlatforms = async (id) => {
cover: doc.cover
}));
} if (id === "producers" || id === "apps" || id === "publishers") {
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
}));
} else {
data = await homgot(`${BASE_ARUPPI}res/documents/animelegal/type/${id}.json`, { parse: true });
@ -481,7 +501,8 @@ const getPlatforms = async (id) => {
type: doc.type,
logo: doc.logo,
cover: doc.cover,
link: doc.link
webpage: doc.webpage,
}));
}

@ -25,8 +25,8 @@ router.get('/', (req, res) => {
'Futures Seasons': '/api/v3/laterSeasons',
'LastEpisodes': '/api/v3/lastEpisodes',
'Movies': '/api/v3/movies/:type/:page',
'Ovas': '/api/v3/ovas/:type/:page',
'Specials': '/api/v3/specials/:type/:page',
'Ovas': '/api/v3/ova/:type/:page',
'Specials': '/api/v3/special/:type/:page',
'Tv': '/api/v3/tv/:type/:page',
'MoreInfo': '/api/v3/moreInfo/:title',
'GetEpisodes': '/api/v3/getEpisodes/:title',
@ -42,8 +42,7 @@ router.get('/', (req, res) => {
'Random Theme': '/api/v3/randomTheme',
'Artists Theme': '/api/v3/artists/:id?',
'Famous Platforms': '/api/v3/destAnimePlatforms',
'Legal Platforms': '/api/v3/platforms/:id?',
'Platforms Details': '/api/v3/profilePlatform/:id'
'Legal Platforms': '/api/v3/platforms/:id?'
}
]
});

@ -193,10 +193,10 @@ router.get('/movies/:type/:page' , (req, res) =>{
let data = {url: 'Movies', prop: 'movies', type: req.params.type, page: req.params.page }
api.getSpecials(data)
.then(movies =>{
if (movies.length > 0) {
.then(animes =>{
if (animes.length > 0) {
res.status(200).json({
movies
animes
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
@ -207,15 +207,15 @@ router.get('/movies/:type/:page' , (req, res) =>{
});
router.get('/ovas/:type/:page' , (req, res) =>{
router.get('/ova/:type/:page' , (req, res) =>{
let data = {url: 'Ova', prop: 'ova', type: req.params.type, page: req.params.page }
api.getSpecials(data)
.then(ovas =>{
if (ovas.length > 0) {
.then(animes =>{
if (animes.length > 0) {
res.status(200).json({
ovas
animes
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
@ -226,15 +226,15 @@ router.get('/ovas/:type/:page' , (req, res) =>{
});
router.get('/specials/:type/:page' , (req, res) =>{
router.get('/special/:type/:page' , (req, res) =>{
let data = {url: 'Special', prop: 'special', type: req.params.type, page: req.params.page }
api.getSpecials(data)
.then(specials =>{
if (specials.length > 0) {
.then(animes =>{
if (animes.length > 0) {
res.status(200).json({
specials
animes
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
@ -250,10 +250,10 @@ router.get('/tv/:type/:page' , (req, res) =>{
let data = {url: 'Tv', prop: 'tv', type: req.params.type, page: req.params.page }
api.getSpecials(data)
.then(tv =>{
if (tv.length > 0) {
.then(animes =>{
if (animes.length > 0) {
res.status(200).json({
tv
animes
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
@ -548,25 +548,7 @@ router.get('/platforms/:id?' , (req , res) =>{
api.getPlatforms(id)
.then(platforms =>{
if (platforms.length > 0) {
res.status(200).json({
platforms
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
)
}).catch((err) =>{
console.error(err);
});
});
router.get('/profilePlatform/:id' , (req , res) =>{
let id = req.params.id;
api.getProfilePlatform(id)
.then(info =>{
if (info.length > 0) {
res.status(200).json(info[0]);
res.status(200).json({platforms});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
)

@ -33,10 +33,10 @@ async function videoServersJK(id) {
script = $(element).html();
}
});
try {
let videoUrls = script.match(/(?<=src=").*?(?=[\*"])/gi);
for (let i = 0; i < serverNames.length; i++) {
servers[serverNames[i]] = videoUrls[i];
}
@ -45,7 +45,7 @@ async function videoServersJK(id) {
console.log(err);
return null;
}
let serverList = [];
for (let server in servers) {
@ -62,7 +62,7 @@ async function videoServersJK(id) {
direct: true
});
}
}
serverList = serverList.filter(x => x.id !== 'xtreme s' && x.id !== 'desuka');
@ -139,12 +139,13 @@ const jkanimeInfo = async (id) => {
};
function getPoster(id) {
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
//@CHECK
for (let anime of data) {
if (anime.id === id) {
return anime.poster;
return [anime.poster, anime.type];
}
}
@ -152,11 +153,11 @@ function getPoster(id) {
};
async function getRelatedAnimes(id) {
const $ = await homgot(`${BASE_ANIMEFLV}/anime/${id}`, { scrapy: true });
let listRelated = {};
let relatedAnimes = [];
if ($('ul.ListAnmRel').length) {
$('ul.ListAnmRel li a').each((index, element) => {
listRelated[$(element).text()] = $(element).attr('href');
@ -165,11 +166,13 @@ async function getRelatedAnimes(id) {
for (related in listRelated) {
let posterUrl = getPoster(listRelated[related].split('/')[2]);
//@CHECK
relatedAnimes.push(
{
id: listRelated[related].split('/')[2],
title: related,
poster: posterUrl
type: posterUrl[1],
poster: posterUrl[0]
}
);
}
@ -199,7 +202,7 @@ const animeflvInfo = async (id) => {
for (let script of scripts) {
const contents = $(script).html();
if ((contents || '').includes('var anime_info = [')) {
let anime_info = contents.split('var anime_info = ')[1].split(';\n')[0];
let dat_anime_info = JSON.parse(anime_info);
@ -328,7 +331,7 @@ const animeExtraInfo = async (title) => {
} else {
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()]
}
promises.push({
titleJapanese: doc.title_japanese,
source: doc.source,
@ -450,13 +453,13 @@ const obtainPreviewNews = (encoded) => {
/* - StructureThemes
/* - StructureThemes
This function only parses the theme/themes
if indv is true, then only return a object, if it's false
then returns a array with the themes selected.
*/
const structureThemes = async (body, indv) => {
if (indv === true) {
return {
@ -479,7 +482,7 @@ const structureThemes = async (body, indv) => {
return themes;
}
};
/* - GetThemesData
@ -503,7 +506,7 @@ const getThemesData = async (themes) => {
});
}
return items.filter(x => x.title !== 'Remasterización');
};

Loading…
Cancel
Save