v2.6.4 - Fixes some series

This commit is contained in:
Jéluchu 2020-07-27 14:38:26 +02:00
parent 61c14e9ccd
commit 36e1665ea6
5 changed files with 1032 additions and 122 deletions

876
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"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",
"main": "./src/api/api.js",
"scripts": {

View File

@ -262,7 +262,14 @@ const getMoreInfo = async (title) =>{
const jkAnimeTitles = [
{ title: 'The God of High School', id: 'the-god-of-high-school' },
{ 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
@ -272,7 +279,18 @@ const getMoreInfo = async (title) =>{
if (title === jkAnimeTitles[name].title) {
jkanime = true
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: 'Naruto Shippuden', myanimelist: 'Naruto: Shippuuden' },
{ 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) {
@ -291,6 +311,7 @@ const getMoreInfo = async (title) =>{
}
}
if (seriesTitle === undefined) {
seriesTitle = title
}
@ -298,7 +319,10 @@ const getMoreInfo = async (title) =>{
await getAllAnimes().then(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)', '') }
else { animeTitle = animes[i].title.split('\t')[0] }
animeId = animes[i].id
@ -384,7 +408,9 @@ const getAnimeServers = async (id) => {
const jkAnimeIDs = [
{ id: 'the-god-of-high-school' },
{ id: 'kami-no-tou' },
{ id: 'bna' }
{ id: 'bna' },
{ id: 'ansatsu-kyoushitsu-tv' },
{ id: 'ansatsu-kyoushitsu-tv-2nd-season' }
];
let jkanime = false

View File

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

View File

@ -6,7 +6,6 @@ const {
homgot
} = require('../api/apiCall');
function btoa(str) {
let buffer;
if (str instanceof Buffer) {
@ -26,11 +25,11 @@ async function videoServersJK(id) {
const $ = await homgot(`${BASE_JKANIME}${id}`, options);
const scripts = $('script');
const totalEps = $('div#container div#reproductor-box div ul li').length;
const episodes = $('div#reproductor-box li');
const serverNames = [];
let servers = [];
$('div#container div#reproductor-box div ul li').each((index , element) =>{
episodes.each((index , element) =>{
const $element = $(element);
const serverName = $element.find('a').text();
serverNames.push(serverName);
@ -40,9 +39,8 @@ async function videoServersJK(id) {
const $script = $(scripts[i]);
const contents = $script.html();
try{
if ((contents || '').includes('var video = [];')) {
Array.from({length: totalEps} , (v , k) =>{
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});
@ -52,24 +50,17 @@ async function videoServersJK(id) {
return null;
}
}
let serverList = [];
let serverTempList = [];
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];
for(let server in servers) {
serverList.push({
id: name.toLowerCase(),
url: video,
id: serverNames[server].toLowerCase(),
url: await getVideoURL(servers[server].iframe),
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);
}
@ -304,127 +295,145 @@ const animeflvInfo = async (id, index) => {
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 matchAnime = res.results.filter(x => x.title === title);
const malId = matchAnime[0].mal_id;
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;
if (typeof matchAnime[0].mal_id === 'undefined') return null;
const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, options);
let body = data.characters;
const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, options);
let body = data.characters;
if (typeof body === 'undefined') return null;
if (typeof body === 'undefined') return null;
const charactersId = body.map(doc => {
return doc.mal_id
})
const charactersNames = body.map(doc => {
return doc.name;
});
const charactersImages = body.map(doc => {
return doc.image_url
});
let characters = [];
Array.from({length: charactersNames.length}, (v, k) => {
const id = charactersId[k];
let name = charactersNames[k];
let characterImg = charactersImages[k];
characters.push({
id: id,
name: name,
image: characterImg
const charactersId = body.map(doc => {
return doc.mal_id
})
const charactersNames = body.map(doc => {
return doc.name;
});
const charactersImages = body.map(doc => {
return doc.image_url
});
});
return Promise.all(characters);
let characters = [];
Array.from({length: charactersNames.length}, (v, k) => {
const id = charactersId[k];
let name = charactersNames[k];
let characterImg = charactersImages[k];
characters.push({
id: id,
name: name,
image: characterImg
});
});
return Promise.all(characters);
} catch (e) {
console.log(e.message)
}
};
const getAnimeVideoPromo = async (title) => {
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;
try {
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;
if (typeof matchAnime[0].mal_id === 'undefined') return null;
const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, options);
const body = data.promo;
const promises = [];
const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, options);
const body = data.promo;
const promises = [];
body.map(doc => {
promises.push({
title: doc.title,
previewImage: doc.image_url,
videoURL: doc.video_url
body.map(doc => {
promises.push({
title: doc.title,
previewImage: doc.image_url,
videoURL: doc.video_url
});
});
});
return Promise.all(promises);
return Promise.all(promises);
} catch (e) {
console.log(e.message)
}
};
const animeExtraInfo = async (title) => {
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;
try {
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;
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, options);
const body = Array(data);
const promises = [];
if (typeof matchAnime[0].mal_id === 'undefined') return null;
body.map(doc => {
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, options);
const body = Array(data);
const promises = [];
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'
};
body.map(doc => {
let broadcast
if (doc.broadcast === null) {
broadcast = null
} else {
broadcast = airDay[doc.broadcast.split('at')[0].replace(" ", "").toLowerCase()]
}
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'
};
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
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);
return Promise.all(promises);
} catch (e) {
console.log(e.message)
}
};
const imageUrlToBase64 = async (url) => {
@ -441,7 +450,8 @@ const searchAnime = async (query) => {
const jkAnimeTitles = [
{ 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