v2.6.4 - Fixes some series

pull/1/head v2.6.4
Jéluchu 5 years ago
parent 61c14e9ccd
commit 36e1665ea6

876
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{ {
"name": "aruppi", "name": "aruppi",
"version": "2.6.3", "version": "2.6.4",
"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": {

@ -262,7 +262,14 @@ const getMoreInfo = async (title) =>{
const jkAnimeTitles = [ const jkAnimeTitles = [
{ title: 'The God of High School', id: 'the-god-of-high-school' }, { title: 'The God of High School', id: 'the-god-of-high-school' },
{ title: 'Kami no Tou', id: 'kami-no-tou' }, { title: 'Kami no Tou', id: 'kami-no-tou' },
{ title: 'BNA', id: 'bna' } { title: 'BNA', id: 'bna' },
{ title: 'Ansatsu Kyoushitsu (TV)', id: 'ansatsu-kyoushitsu-tv' },
{ title: 'Ansatsu Kyoushitsu (TV) 2nd Season', id: 'ansatsu-kyoushitsu-tv-2nd-season' }
];
const jkMyAnimetitles = [
{ jkanime: 'Ansatsu Kyoushitsu (TV)', myanimelist: 'Ansatsu Kyoushitsu'},
{ jkanime: 'Ansatsu Kyoushitsu (TV) 2nd Season', myanimelist: 'Ansatsu Kyoushitsu 2nd Season' }
]; ];
let jkanime = false let jkanime = false
@ -272,7 +279,18 @@ const getMoreInfo = async (title) =>{
if (title === jkAnimeTitles[name].title) { if (title === jkAnimeTitles[name].title) {
jkanime = true jkanime = true
jkanimeID = jkAnimeTitles[name].id jkanimeID = jkAnimeTitles[name].id
jkanimeName = jkAnimeTitles[name].title
for (let name in jkMyAnimetitles) {
if (title === jkMyAnimetitles[name].jkanime || title === jkMyAnimetitles[name].myanimelist) {
jkanimeName = jkMyAnimetitles[name].myanimelist
position = name
}
}
if (jkanimeName === undefined) {
jkanimeName = jkAnimeTitles[name].title
}
} }
} }
@ -281,7 +299,9 @@ const getMoreInfo = async (title) =>{
{ animeflv: 'Kaguya-sama wa Kokurasetai: Tensai-tachi no Renai Zunousen 2nd Season', myanimelist: 'Kaguya-sama wa Kokurasetai?: Tensai-tachi no Renai Zunousen', alternative: 'Kaguya-sama wa Kokurasetai'}, { animeflv: 'Kaguya-sama wa Kokurasetai: Tensai-tachi no Renai Zunousen 2nd Season', myanimelist: 'Kaguya-sama wa Kokurasetai?: Tensai-tachi no Renai Zunousen', alternative: 'Kaguya-sama wa Kokurasetai'},
{ animeflv: 'Naruto Shippuden', myanimelist: 'Naruto: Shippuuden' }, { animeflv: 'Naruto Shippuden', myanimelist: 'Naruto: Shippuuden' },
{ animeflv: 'Rock Lee no Seishun Full-Power Ninden', myanimelist: 'Naruto SD: Rock Lee no Seishun Full-Power Ninden' }, { animeflv: 'Rock Lee no Seishun Full-Power Ninden', myanimelist: 'Naruto SD: Rock Lee no Seishun Full-Power Ninden' },
{ animeflv: 'BAKI: dai reitaisai-hen', myanimelist: 'Baki 2nd Season' } { animeflv: 'BAKI: dai reitaisai-hen', myanimelist: 'Baki 2nd Season' },
{ animeflv: 'Hitoribocchi no ○○ Seikatsu', myanimelist: 'Hitoribocchi no Marumaru Seikatsu' },
{ animeflv: 'Nekopara (TV)', myanimelist: 'Nekopara' }
]; ];
for (let name in titles) { for (let name in titles) {
@ -291,6 +311,7 @@ const getMoreInfo = async (title) =>{
} }
} }
if (seriesTitle === undefined) { if (seriesTitle === undefined) {
seriesTitle = title seriesTitle = title
} }
@ -298,7 +319,10 @@ const getMoreInfo = async (title) =>{
await getAllAnimes().then(animes => { await getAllAnimes().then(animes => {
for (const i in animes) { for (const i in animes) {
if (animes[i].title.split('\t')[0] === seriesTitle.split('\t')[0] || animes[i].title === `${seriesTitle} (TV)`) { if (animes[i].title.split('\t')[0] === seriesTitle.split('\t')[0] ||
animes[i].title === `${seriesTitle} (TV)` ||
animes[i].title.includes(seriesTitle.split('○')[0])
) {
if (animes[i].title.includes('(TV)', 0)) { animeTitle = animes[i].title.split('\t')[0].replace(' (TV)', '') } if (animes[i].title.includes('(TV)', 0)) { animeTitle = animes[i].title.split('\t')[0].replace(' (TV)', '') }
else { animeTitle = animes[i].title.split('\t')[0] } else { animeTitle = animes[i].title.split('\t')[0] }
animeId = animes[i].id animeId = animes[i].id
@ -384,7 +408,9 @@ const getAnimeServers = async (id) => {
const jkAnimeIDs = [ const jkAnimeIDs = [
{ id: 'the-god-of-high-school' }, { id: 'the-god-of-high-school' },
{ id: 'kami-no-tou' }, { id: 'kami-no-tou' },
{ id: 'bna' } { id: 'bna' },
{ id: 'ansatsu-kyoushitsu-tv' },
{ id: 'ansatsu-kyoushitsu-tv-2nd-season' }
]; ];
let jkanime = false let jkanime = false

@ -7,7 +7,7 @@ router.get('/', (req, res) => {
res.json({ res.json({
message: 'Aruppi API - 🎏', message: 'Aruppi API - 🎏',
author: 'Jéluchu', author: 'Jéluchu',
version: '2.6.3', version: '2.6.4',
credits: 'The bitch loves APIs that offers data to Aruppi App', credits: 'The bitch loves APIs that offers data to Aruppi App',
entries: [ entries: [
{ {

@ -6,7 +6,6 @@ const {
homgot homgot
} = require('../api/apiCall'); } = require('../api/apiCall');
function btoa(str) { function btoa(str) {
let buffer; let buffer;
if (str instanceof Buffer) { if (str instanceof Buffer) {
@ -26,11 +25,11 @@ async function videoServersJK(id) {
const $ = await homgot(`${BASE_JKANIME}${id}`, options); const $ = await homgot(`${BASE_JKANIME}${id}`, options);
const scripts = $('script'); const scripts = $('script');
const totalEps = $('div#container div#reproductor-box div ul li').length; const episodes = $('div#reproductor-box li');
const serverNames = []; const serverNames = [];
let servers = []; let servers = [];
$('div#container div#reproductor-box div ul li').each((index , element) =>{ episodes.each((index , element) =>{
const $element = $(element); const $element = $(element);
const serverName = $element.find('a').text(); const serverName = $element.find('a').text();
serverNames.push(serverName); serverNames.push(serverName);
@ -40,9 +39,8 @@ async function videoServersJK(id) {
const $script = $(scripts[i]); const $script = $(scripts[i]);
const contents = $script.html(); const contents = $script.html();
try{ try{
if ((contents || '').includes('var video = [];')) { if ((contents || '').includes('var video = [];')) {
Array.from({length: totalEps} , (v , k) =>{ Array.from({length: episodes.length} , (v , k) =>{
let index = Number(k + 1); let index = Number(k + 1);
let videoPageURL = contents.split(`video[${index}] = \'<iframe class="player_conte" src="`)[1].split('"')[0]; let videoPageURL = contents.split(`video[${index}] = \'<iframe class="player_conte" src="`)[1].split('"')[0];
servers.push({iframe: videoPageURL}); servers.push({iframe: videoPageURL});
@ -52,24 +50,17 @@ async function videoServersJK(id) {
return null; return null;
} }
} }
let serverList = []; let serverList = [];
let serverTempList = []; for(let server in servers) {
for(const [key , value] of Object.entries(servers)) {
let video = await getVideoURL(value.iframe)
serverTempList.push(video);
}
Array.from({length: serverTempList.length} , (v , k) =>{
let name = serverNames[k];
let video = serverTempList[k];
serverList.push({ serverList.push({
id: name.toLowerCase(), id: serverNames[server].toLowerCase(),
url: video, url: await getVideoURL(servers[server].iframe),
direct: true direct: true
}); });
}); }
serverList = serverList.filter(function( obj ) {
return obj.id !== 'xtreme s'; serverList = serverList.filter(x => x.id !== 'xtreme s' && x.id !== 'desuka' );
});
return await Promise.all(serverList); return await Promise.all(serverList);
} }
@ -304,127 +295,145 @@ const animeflvInfo = async (id, index) => {
const getAnimeCharacters = async (title) => { const getAnimeCharacters = async (title) => {
let options = { parse: true } try {
let options = { parse: true }
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options); const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options);
const matchAnime = res.results.filter(x => x.title === title); const matchAnime = res.results.filter(x => x.title === title);
const malId = matchAnime[0].mal_id; const malId = matchAnime[0].mal_id;
if (typeof matchAnime[0].mal_id === 'undefined') return null; if (typeof matchAnime[0].mal_id === 'undefined') return null;
const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, options); const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, options);
let body = data.characters; let body = data.characters;
if (typeof body === 'undefined') return null; if (typeof body === 'undefined') return null;
const charactersId = body.map(doc => { const charactersId = body.map(doc => {
return doc.mal_id return doc.mal_id
}) })
const charactersNames = body.map(doc => { const charactersNames = body.map(doc => {
return doc.name; return doc.name;
}); });
const charactersImages = body.map(doc => { const charactersImages = body.map(doc => {
return doc.image_url return doc.image_url
}); });
let characters = []; let characters = [];
Array.from({length: charactersNames.length}, (v, k) => { Array.from({length: charactersNames.length}, (v, k) => {
const id = charactersId[k]; const id = charactersId[k];
let name = charactersNames[k]; let name = charactersNames[k];
let characterImg = charactersImages[k]; let characterImg = charactersImages[k];
characters.push({ characters.push({
id: id, id: id,
name: name, name: name,
image: characterImg image: characterImg
});
}); });
});
return Promise.all(characters); return Promise.all(characters);
} catch (e) {
console.log(e.message)
}
}; };
const getAnimeVideoPromo = async (title) => { const getAnimeVideoPromo = async (title) => {
let options = { parse: true } try {
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options); let options = { parse: true }
const matchAnime = res.results.filter(x => x.title === title); const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options);
const malId = matchAnime[0].mal_id; const matchAnime = res.results.filter(x => x.title === title);
const malId = matchAnime[0].mal_id;
if (typeof matchAnime[0].mal_id === 'undefined') return null; if (typeof matchAnime[0].mal_id === 'undefined') return null;
const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, options); const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, options);
const body = data.promo; const body = data.promo;
const promises = []; const promises = [];
body.map(doc => { body.map(doc => {
promises.push({ promises.push({
title: doc.title, title: doc.title,
previewImage: doc.image_url, previewImage: doc.image_url,
videoURL: doc.video_url videoURL: doc.video_url
});
}); });
});
return Promise.all(promises); return Promise.all(promises);
} catch (e) {
console.log(e.message)
}
}; };
const animeExtraInfo = async (title) => { const animeExtraInfo = async (title) => {
let options = { parse: true } try {
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options);
const matchAnime = res.results.filter(x => x.title === title);
const malId = matchAnime[0].mal_id;
if (typeof matchAnime[0].mal_id === 'undefined') return null; let options = { parse: true }
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`, options);
const matchAnime = res.results.filter(x => x.title === title);
const malId = matchAnime[0].mal_id;
if (typeof matchAnime[0].mal_id === 'undefined') return null;
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, options);
const body = Array(data);
const promises = [];
body.map(doc => {
let airDay = {
'mondays': 'Lunes',
'monday': 'Lunes',
'tuesdays': 'Martes',
'tuesday': 'Martes',
'wednesdays': 'Miércoles',
'wednesday': 'Miércoles',
'thursdays': 'Jueves',
'thursday': 'Jueves',
'fridays': 'Viernes',
'friday': 'Viernes',
'saturdays': 'Sábados',
'saturday': 'Sábados',
'sundays': 'Domingos',
'sunday': 'Domingos',
'default': 'Sin emisión'
};
let broadcast
if (doc.broadcast === null) {
broadcast = null
} else {
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()]
}
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, options); promises.push({
const body = Array(data); titleJapanese: doc.title_japanese,
const promises = []; source: doc.source,
totalEpisodes: doc.episodes,
aired: {
from: doc.aired.from,
to: doc.aired.to
},
duration: doc.duration.split('per')[0],
rank: doc.rank,
broadcast: broadcast,
producers: doc.producers.map(x => x.name) || null,
licensors: doc.licensors.map(x => x.name) || null,
studios: doc.studios.map(x => x.name) || null,
openingThemes: doc.opening_themes || null,
endingThemes: doc.ending_themes || null
});
});
return Promise.all(promises);
} catch (e) {
console.log(e.message)
}
body.map(doc => {
let airDay = {
'mondays': 'Lunes',
'monday': 'Lunes',
'tuesdays': 'Martes',
'tuesday': 'Martes',
'wednesdays': 'Miércoles',
'wednesday': 'Miércoles',
'thursdays': 'Jueves',
'thursday': 'Jueves',
'fridays': 'Viernes',
'friday': 'Viernes',
'saturdays': 'Sábados',
'saturday': 'Sábados',
'sundays': 'Domingos',
'sunday': 'Domingos',
'default': 'Sin emisión'
};
let broadcast
if (doc.broadcast === null) {
broadcast = null
} else {
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()]
}
promises.push({
titleJapanese: doc.title_japanese,
source: doc.source,
totalEpisodes: doc.episodes,
aired: {
from: doc.aired.from,
to: doc.aired.to
},
duration: doc.duration.split('per')[0],
rank: doc.rank,
broadcast: broadcast,
producers: doc.producers.map(x => x.name) || null,
licensors: doc.licensors.map(x => x.name) || null,
studios: doc.studios.map(x => x.name) || null,
openingThemes: doc.opening_themes || null,
endingThemes: doc.ending_themes || null
});
});
return Promise.all(promises);
}; };
const imageUrlToBase64 = async (url) => { const imageUrlToBase64 = async (url) => {
@ -441,7 +450,8 @@ const searchAnime = async (query) => {
const jkAnimeTitles = [ const jkAnimeTitles = [
{ title: 'BNA', search: 'BNA'}, { title: 'BNA', search: 'BNA'},
{ title: 'The God of High School', search: 'The god' } { title: 'The God of High School', search: 'The god' },
{ title: 'Ansatsu Kyoshitsu', search: 'Assassination Classroom' },
]; ];
let jkanime = false let jkanime = false

Loading…
Cancel
Save