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 =>({ return res[data.prop].map(doc =>({
id: doc.id, id: doc.id,
title: doc.title, title: doc.title,
type: doc.type, type: data.url.toLowerCase(),
page: data.page,
banner: doc.banner, banner: doc.banner,
image: doc.poster, image: doc.poster,
synopsis: doc.synopsis, synopsis: doc.synopsis,
@ -471,6 +472,25 @@ const getPlatforms = async (id) => {
cover: doc.cover 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 { } 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 });
@ -481,7 +501,8 @@ const getPlatforms = async (id) => {
type: doc.type, type: doc.type,
logo: doc.logo, logo: doc.logo,
cover: doc.cover, cover: doc.cover,
link: doc.link webpage: doc.webpage,
})); }));
} }

@ -25,8 +25,8 @@ router.get('/', (req, res) => {
'Futures Seasons': '/api/v3/laterSeasons', 'Futures Seasons': '/api/v3/laterSeasons',
'LastEpisodes': '/api/v3/lastEpisodes', 'LastEpisodes': '/api/v3/lastEpisodes',
'Movies': '/api/v3/movies/:type/:page', 'Movies': '/api/v3/movies/:type/:page',
'Ovas': '/api/v3/ovas/:type/:page', 'Ovas': '/api/v3/ova/:type/:page',
'Specials': '/api/v3/specials/:type/:page', 'Specials': '/api/v3/special/:type/:page',
'Tv': '/api/v3/tv/:type/:page', 'Tv': '/api/v3/tv/:type/:page',
'MoreInfo': '/api/v3/moreInfo/:title', 'MoreInfo': '/api/v3/moreInfo/:title',
'GetEpisodes': '/api/v3/getEpisodes/:title', 'GetEpisodes': '/api/v3/getEpisodes/:title',
@ -42,8 +42,7 @@ router.get('/', (req, res) => {
'Random Theme': '/api/v3/randomTheme', 'Random Theme': '/api/v3/randomTheme',
'Artists Theme': '/api/v3/artists/:id?', 'Artists Theme': '/api/v3/artists/:id?',
'Famous Platforms': '/api/v3/destAnimePlatforms', 'Famous Platforms': '/api/v3/destAnimePlatforms',
'Legal Platforms': '/api/v3/platforms/:id?', 'Legal Platforms': '/api/v3/platforms/:id?'
'Platforms Details': '/api/v3/profilePlatform/: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 } let data = {url: 'Movies', prop: 'movies', type: req.params.type, page: req.params.page }
api.getSpecials(data) api.getSpecials(data)
.then(movies =>{ .then(animes =>{
if (movies.length > 0) { if (animes.length > 0) {
res.status(200).json({ res.status(200).json({
movies animes
}); });
} else ( } else (
res.status(500).json({ message: 'Aruppi lost in the shell'}) 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 } let data = {url: 'Ova', prop: 'ova', type: req.params.type, page: req.params.page }
api.getSpecials(data) api.getSpecials(data)
.then(ovas =>{ .then(animes =>{
if (ovas.length > 0) { if (animes.length > 0) {
res.status(200).json({ res.status(200).json({
ovas animes
}); });
} else ( } else (
res.status(500).json({ message: 'Aruppi lost in the shell'}) 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 } let data = {url: 'Special', prop: 'special', type: req.params.type, page: req.params.page }
api.getSpecials(data) api.getSpecials(data)
.then(specials =>{ .then(animes =>{
if (specials.length > 0) { if (animes.length > 0) {
res.status(200).json({ res.status(200).json({
specials animes
}); });
} else ( } else (
res.status(500).json({ message: 'Aruppi lost in the shell'}) 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 } let data = {url: 'Tv', prop: 'tv', type: req.params.type, page: req.params.page }
api.getSpecials(data) api.getSpecials(data)
.then(tv =>{ .then(animes =>{
if (tv.length > 0) { if (animes.length > 0) {
res.status(200).json({ res.status(200).json({
tv animes
}); });
} else ( } else (
res.status(500).json({ message: 'Aruppi lost in the shell'}) res.status(500).json({ message: 'Aruppi lost in the shell'})
@ -548,25 +548,7 @@ router.get('/platforms/:id?' , (req , res) =>{
api.getPlatforms(id) api.getPlatforms(id)
.then(platforms =>{ .then(platforms =>{
if (platforms.length > 0) { if (platforms.length > 0) {
res.status(200).json({ res.status(200).json({platforms});
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]);
} else ( } else (
res.status(500).json({ message: 'Aruppi lost in the shell'}) res.status(500).json({ message: 'Aruppi lost in the shell'})
) )

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

Loading…
Cancel
Save