v3.3.1 - Fix v2 MoreInfo

pull/10/head v3.3.1
Jéluchu 5 years ago
parent 22c99e0641
commit 214a0aa15c

@ -1,4 +1,4 @@
# **Aruppi API** (v3.3.0) # **Aruppi API** (v3.3.1)
> This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture > This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture
> >

2
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "aruppi", "name": "aruppi",
"version": "3.2.10", "version": "3.3.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

@ -1,6 +1,6 @@
{ {
"name": "aruppi", "name": "aruppi",
"version": "3.3.0", "version": "3.3.1",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app", "description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.js", "main": "./src/api/api.js",
"scripts": { "scripts": {

@ -15,7 +15,8 @@ const {
obtainPreviewNews, obtainPreviewNews,
structureThemes, structureThemes,
videoServersJK, videoServersJK,
getThemes getThemes,
getMALid
} = require('../utils/index'); } = require('../utils/index');
const ThemeParser = require('../utils/animetheme'); const ThemeParser = require('../utils/animetheme');

@ -290,6 +290,13 @@ const animeExtraInfo = async (title) => {
const getMALid = async(title) =>{ 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 res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`,{ parse: true })
const matchAnime = res.results.find(x => x.title === title); const matchAnime = res.results.find(x => x.title === title);
@ -299,6 +306,9 @@ const getMALid = async(title) =>{
return matchAnime; return matchAnime;
} }
}
}; };
const imageUrlToBase64 = async (url) => { const imageUrlToBase64 = async (url) => {

@ -5,6 +5,7 @@ const {
} = require('./apiCall'); } = require('./apiCall');
const { const {
jkanimeInfo,
animeflvGenres, animeflvGenres,
animeflvInfo, animeflvInfo,
imageUrlToBase64, imageUrlToBase64,
@ -15,6 +16,7 @@ const {
transformUrlServer, transformUrlServer,
obtainPreviewNews, obtainPreviewNews,
structureThemes, structureThemes,
videoServersJK,
getAnimes, getAnimes,
getDirectory, getDirectory,
getThemes getThemes
@ -238,55 +240,60 @@ const getSpecials = async (type, subType, page) =>{
const getMoreInfo = async (title) =>{ const getMoreInfo = async (title) =>{
let promises = []; try {
let animeId = ''
let animeType = ''
let animeIndex = ''
await getAllAnimes().then(animes => {
for (const i in animes) {
if (animes[i].title.split('\t')[0] === title.split('\t')[0]) {
animeId = animes[i].id
animeIndex = animes[i].index
animeType = animes[i].type.toLowerCase()
break;
}
}
});
try{ const promises = []
promises.push(await animeflvInfo(`anime/${animeId}`, animeIndex).then(async extra => ({
title: title || null,
poster: await imageUrlToBase64(extra.animeExtraInfo[0].poster) || null,
banner: extra.animeExtraInfo[0].banner || null,
synopsis: extra.animeExtraInfo[0].synopsis || null,
debut: extra.animeExtraInfo[0].debut || null,
type: extra.animeExtraInfo[0].type || null,
rating: extra.animeExtraInfo[0].rating || null,
genres: extra.genres || null,
episodes: extra.listByEps || null,
moreInfo: await animeExtraInfo(title).then(info =>{
return info || null
}),
promoList: await getAnimeVideoPromo(title).then(promo =>{
return promo || null
}),
charactersList: await getAnimeCharacters(title).then(characters =>{
return characters || null
})
})));
return Promise.all(promises); let data = JSON.parse(JSON.stringify(require('../../assets/directory.json')));
const res = data.filter(x => x.title === title || x.mal_title === title)[0];
}catch(err){ if (!res.jkanime) {
console.log(err) promises.push({
title: res.title || null,
poster: res.poster || null,
synopsis: res.description || null,
status: res.state || null,
type: res.type || null,
rating: res.score || null,
genres: res.genres || null,
episodes: await animeflvInfo(res.id).then(episodes => episodes || null),
moreInfo: await animeExtraInfo(res.mal_title).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_title).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_title).then(characters => characters || null)
});
} else {
promises.push({
title: res.title || null,
poster: res.poster || null,
synopsis: res.description || null,
status: res.state || null,
type: res.type || null,
rating: res.score || null,
genres: res.genres || null,
episodes: await jkanimeInfo(res.id).then(episodes => episodes || null),
moreInfo: await animeExtraInfo(res.mal_title).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_title).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_title).then(characters => characters || null)
});
}
return promises;
} catch (e) {
console.log(e)
} }
}; };
const getAnimeServers = async (id) => { const getAnimeServers = async (id) => {
if (isNaN(id.split('/')[0])) {
return await videoServersJK(id)
} else {
const data = await homgot(`${BASE_ANIMEFLV_JELU}GetAnimeServers/${id}`, { parse: true }); const data = await homgot(`${BASE_ANIMEFLV_JELU}GetAnimeServers/${id}`, { parse: true });
return await transformUrlServer(data.servers); return await transformUrlServer(data.servers);
}
}; };
const search = async (title) =>{ return await searchAnime(title); }; const search = async (title) =>{ return await searchAnime(title); };

@ -1,11 +1,127 @@
const { const {
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, BASE_ARUPPI, ANIMEFLV_SEARCH BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, BASE_ARUPPI, ANIMEFLV_SEARCH, BASE_JKANIME
} = require('../api/urls.js'); } = require('../api/urls.js');
const { const {
homgot homgot
} = require('../api/apiCall.js'); } = require('../api/apiCall.js');
function btoa(str) {
let buffer;
if (str instanceof Buffer) {
buffer = str;
}
else {
buffer = Buffer.from(str.toString(), 'binary');
}
return buffer.toString('base64');
}
global.btoa = btoa;
async function videoServersJK(id) {
const $ = await homgot(`${BASE_JKANIME}${id}`, { scrapy: true });
const scripts = $('script');
const episodes = $('div#reproductor-box li');
const serverNames = [];
let servers = [];
episodes.each((index, element) => serverNames.push($(element).find('a').text()))
for (let i = 0; i < scripts.length; i++) {
try {
const contents = $(scripts[i]).html();
if ((contents || '').includes('var video = [];')) {
Array.from({ length: episodes.length }, (v, k) => {
let index = Number(k + 1);
let videoPageURL = contents.split(`video[${index}] = \'<iframe class="player_conte" src="`)[1].split('"')[0];
servers.push({ iframe: videoPageURL });
});
}
} catch (err) {
console.log(err)
return null;
}
}
let serverList = [];
for (let server in servers) {
serverList.push({
id: serverNames[server].toLowerCase(),
url: servers[server].iframe,
direct: false
});
}
serverList = serverList.filter(x => x.id !== 'xtreme s' && x.id !== 'desuka');
return await Promise.all(serverList);
}
async function getVideoURL(url) {
const $ = await homgot(url, { scrapy: true });
const video = $('video');
if (video.length) {
const src = $(video).find('source').attr('src');
return src || null;
}
else {
const scripts = $('script');
const l = global;
const ll = String;
const $script2 = $(scripts[1]).html();
eval($script2);
return l.ss || null;
}
}
const jkanimeInfo = async (id) => {
let $ = await homgot(`${BASE_JKANIME}${id}`, { scrapy: true });
let nextEpisodeDate
let rawNextEpisode = $('div[id="container"] div.left-container div[id="proxep"] p')[0]
if (rawNextEpisode === undefined) {
nextEpisodeDate = null
} else {
if (rawNextEpisode.children[1].data === ' ') {
nextEpisodeDate = null
} else {
nextEpisodeDate = rawNextEpisode.children[1].data.trim()
}
}
const eps_temp_list = [];
let episodes_aired = '';
$('div#container div.left-container div.navigation a').each(async (index, element) => {
const $element = $(element);
const total_eps = $element.text();
eps_temp_list.push(total_eps);
})
try { episodes_aired = eps_temp_list[0].split('-')[1].trim(); } catch (err) { }
const animeListEps = [{ nextEpisodeDate: nextEpisodeDate }];
for (let i = 1; i <= episodes_aired; i++) {
let episode = i;
let animeId = $('div[id="container"] div.content-box div[id="episodes-content"]')[0].children[1].children[3].attribs.src.split('/')[7].split('.jpg')[0];
let link = `${animeId}/${episode}`
animeListEps.push({
episode: episode,
id: link
})
}
return animeListEps;
};
const animeflvGenres = async (id) => { const animeflvGenres = async (id) => {
const promises = []; const promises = [];
@ -23,65 +139,37 @@ const animeflvGenres = async (id) => {
} }
const animeflvInfo = async (id, index) => { const animeflvInfo = async (id) => {
try { let $ = await homgot(`${BASE_ANIMEFLV}anime/${id}`, { scrapy: true });
let scripts = $('script').toArray();
let $ = await homgot(`${BASE_ANIMEFLV}/${id}`, { scrapy: true })
const scripts = $('script');
const anime_info_ids = []; const anime_info_ids = [];
const anime_eps_data = []; const anime_eps_data = [];
const animeExtraInfo = [];
const genres = [];
let listByEps;
const animeTitle = $('body div.Wrapper div.Body div div.Ficha.fchlt div.Container h2.Title').text();
const poster = `${BASE_ANIMEFLV}` + $('body div div div div div aside div.AnimeCover div.Image figure img').attr('src')
const banner = poster.replace('covers', 'banners').trim();
const synopsis = $('body div div div div div main section div.Description p').text().trim();
const rating = $('body div div div.Ficha.fchlt div.Container div.vtshr div.Votes span#votes_prmd').text();
const debut = $('body div.Wrapper div.Body div div.Container div.BX.Row.BFluid.Sp20 aside.SidebarA.BFixed p.AnmStts').text();
const type = $('body div.Wrapper div.Body div div.Ficha.fchlt div.Container span.Type').text()
animeExtraInfo.push({
title: animeTitle,
poster: poster,
banner: banner,
synopsis: synopsis,
rating: rating,
debut: debut,
type: type,
})
$('main.Main section.WdgtCn nav.Nvgnrs a').each((index, element) => Array.from({ length: scripts.length }, (v, k) => {
genres.push($(element).attr('href').split('=')[1] || null) const contents = $(scripts[k]).html();
); if ((contents || '').includes('var anime_info = [')) {
let anime_info = contents.split('var anime_info = ')[1].split(';\n')[0];
Array.from({length: scripts.length} , (v , k) =>{ let dat_anime_info = JSON.parse(anime_info);
const $script = $(scripts[k]);
const contents = $script.html();
if((contents || '').includes('var anime_info = [')) {
let anime_info = contents.split('var anime_info = ')[1].split(';')[0];
let dat_anime_info = JSON.parse(JSON.stringify(anime_info));//JSON.parse(anime_info);
anime_info_ids.push(dat_anime_info); anime_info_ids.push(dat_anime_info);
} }
if((contents || '').includes('var episodes = [')) { if ((contents || '').includes('var episodes = [')) {
let episodes = contents.split('var episodes = ')[1].split(';')[0]; let episodes = contents.split('var episodes = ')[1].split(';')[0];
let eps_data = JSON.parse(episodes) let eps_data = JSON.parse(episodes)
anime_eps_data.push(eps_data); anime_eps_data.push(eps_data);
} }
}); });
const animeId = id;
const AnimeThumbnailsId = index;
const animeId = id.split('anime/')[1];
let nextEpisodeDate let nextEpisodeDate
if (JSON.parse(JSON.stringify(anime_info_ids[0])).split('\"').length === 9) {
nextEpisodeDate = JSON.parse(JSON.stringify(anime_info_ids[0])).split("\"")[7] if (anime_info_ids.length > 0) {
if (anime_info_ids[0].length === 4) {
nextEpisodeDate = anime_info_ids[0][3]
} else { } else {
nextEpisodeDate = null nextEpisodeDate = null
} }
}
const amimeTempList = []; const amimeTempList = [];
for (const [key] of Object.entries(anime_eps_data)) { for (const [key] of Object.entries(anime_eps_data)) {
@ -89,28 +177,20 @@ const animeflvInfo = async (id, index) => {
let episodeId = anime_eps_data[key].map(x => x[1]); let episodeId = anime_eps_data[key].map(x => x[1]);
amimeTempList.push(episode, episodeId); amimeTempList.push(episode, episodeId);
} }
const listEps = [{nextEpisodeDate: nextEpisodeDate}]; const animeListEps = [{ nextEpisodeDate: nextEpisodeDate }];
Array.from({length: amimeTempList[1].length}, (v, k) => { Array.from({ length: amimeTempList[1].length }, (v, k) => {
let data = amimeTempList.map(x => x[k]); let data = amimeTempList.map(x => x[k]);
let episode = data[0]; let episode = data[0];
let id = data[1]; let id = data[1];
let imagePreview = `${BASE_EPISODE_IMG_URL}${AnimeThumbnailsId}/${episode}/th_3.jpg`
let link = `${id}/${animeId}-${episode}` let link = `${id}/${animeId}-${episode}`
listEps.push({ animeListEps.push({
episode: episode, episode: episode,
id: link, id: link,
imagePreview: imagePreview
}) })
}) })
listByEps = listEps return animeListEps
return {listByEps , genres , animeExtraInfo};
} catch (e) {
console.log(e)
}
}; };
@ -426,6 +506,7 @@ const getDirectory = async () => {
}; };
module.exports = { module.exports = {
jkanimeInfo,
animeflvGenres, animeflvGenres,
animeflvInfo, animeflvInfo,
getAnimeCharacters, getAnimeCharacters,
@ -439,5 +520,6 @@ module.exports = {
structureThemes, structureThemes,
getThemes, getThemes,
getAnimes, getAnimes,
getDirectory getDirectory,
videoServersJK
} }

Loading…
Cancel
Save