mirror of https://github.com/aruppi/aruppi-api
v2.7.0 - Optimizations, acceleration, and refactoring
This commit is contained in:
parent
78ada322f0
commit
2b88dfb7a1
|
@ -1,4 +1,4 @@
|
|||
# **Aruppi API** (v2.6.8)
|
||||
# **Aruppi API** (v2.7.0)
|
||||
|
||||
> This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture
|
||||
>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "aruppi",
|
||||
"version": "2.6.8",
|
||||
"version": "2.7.0",
|
||||
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
|
||||
"main": "./src/api/api.js",
|
||||
"scripts": {
|
||||
|
@ -49,9 +49,9 @@
|
|||
"express": "^4.16.4",
|
||||
"got": "^11.3.0",
|
||||
"helmet": "^3.23.3",
|
||||
"hooman": "^1.2.5",
|
||||
"hooman": "^1.2.6",
|
||||
"node-fetch": "^2.6.0",
|
||||
"rss-to-json": "^1.1.1",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"node-fetch": "^2.6.0"
|
||||
"tough-cookie": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
|
435
src/api/api.js
435
src/api/api.js
|
@ -16,8 +16,6 @@ const {
|
|||
transformUrlServer,
|
||||
obtainPreviewNews,
|
||||
structureThemes,
|
||||
getAnimes,
|
||||
getDirectory,
|
||||
helper,
|
||||
videoServersJK,
|
||||
getThemes
|
||||
|
@ -27,39 +25,39 @@ const ThemeParser = require('../utils/animetheme');
|
|||
const parserThemes = new ThemeParser()
|
||||
|
||||
const {
|
||||
BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, GENRES_URL, BASE_THEMEMOE
|
||||
BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, GENRES_URL, BASE_THEMEMOE, BASE_ANIMEFLV
|
||||
} = require('./urls');
|
||||
|
||||
const schedule = async (day) =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_JIKAN}schedule/${day.current}`, options);
|
||||
const body = data[day.current];
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_JIKAN}schedule/${day.current}`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
return data[day.current].map(doc =>({
|
||||
title: doc.title,
|
||||
malid: doc.mal_id,
|
||||
image: doc.image_url
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return promises;
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const top = async (type, subtype, page) =>{
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_JIKAN}top/${type}/${page}/${subtype}`, options);
|
||||
return data.top;
|
||||
const top = async (top) =>{
|
||||
|
||||
const data = await homgot(`${BASE_JIKAN}top/${top.type}/${top.page}/${top.subtype}`, { parse: true });
|
||||
|
||||
return data.top.map(doc => ({
|
||||
rank: doc.rank,
|
||||
title: doc.title,
|
||||
image: doc.image_url,
|
||||
type: doc.type,
|
||||
startDate: doc.start_date,
|
||||
endDate: doc.end_date
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getAllAnimes = async () =>{
|
||||
|
||||
let data = await getAnimes()
|
||||
let data = await homgot(`${BASE_ANIMEFLV}api/animes/list`, { parse: true })
|
||||
|
||||
return data.map(item => ({
|
||||
index: item[0],
|
||||
|
@ -71,7 +69,24 @@ const getAllAnimes = async () =>{
|
|||
|
||||
};
|
||||
|
||||
const getAllDirectory = async () =>{ return await getDirectory(); };
|
||||
const getAllDirectory = async () =>{
|
||||
|
||||
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
|
||||
|
||||
return data.map(doc => ({
|
||||
id: doc.id,
|
||||
title: doc.title,
|
||||
mal_title: doc.mal_title,
|
||||
poster: doc.poster,
|
||||
type: doc.type,
|
||||
genres: doc.genres,
|
||||
state: doc.state,
|
||||
score: doc.score,
|
||||
jkanime: false,
|
||||
description: doc.description
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getAnitakume = async () =>{
|
||||
|
||||
|
@ -112,7 +127,7 @@ const getAnitakume = async () =>{
|
|||
|
||||
const getNews = async (pageRss) =>{
|
||||
|
||||
const promises = []
|
||||
let promises = []
|
||||
|
||||
for(let i = 0; i <= pageRss.length -1; i++) {
|
||||
|
||||
|
@ -139,70 +154,43 @@ const getNews = async (pageRss) =>{
|
|||
|
||||
};
|
||||
|
||||
const season = async (year, type) =>{
|
||||
const season = async (season) =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_JIKAN}season/${year}/${type}`, options);
|
||||
let body = data.anime;
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_JIKAN}season/${season.year}/${season.type}`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
title: doc.title,
|
||||
malid: doc.mal_id,
|
||||
image: doc.image_url,
|
||||
genres: doc.genres.map(x => x.name)
|
||||
});
|
||||
});
|
||||
|
||||
return promises;
|
||||
return data.anime.map(doc =>({
|
||||
title: doc.title,
|
||||
image: doc.image_url,
|
||||
genres: doc.genres.map(x => x.name)
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const allSeasons = async () =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_JIKAN}season/archive`, options);
|
||||
let body = data.archive;
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_JIKAN}season/archive`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
return data.archive.map(doc =>({
|
||||
year: doc.year,
|
||||
seasons: doc.seasons,
|
||||
});
|
||||
});
|
||||
|
||||
return promises;
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const laterSeasons = async () =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_JIKAN}season/later`, options);
|
||||
let body = data.anime;
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_JIKAN}season/later`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
malid: doc.mal_id,
|
||||
return data.anime.map(doc =>({
|
||||
title: doc.title,
|
||||
image: doc.image_url
|
||||
});
|
||||
});
|
||||
|
||||
return promises;
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getLastEpisodes = async () =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`, options);
|
||||
const data = await homgot(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`, { parse: true });
|
||||
let body = data.episodes;
|
||||
const promises = []
|
||||
|
||||
|
@ -222,16 +210,11 @@ const getLastEpisodes = async () =>{
|
|||
|
||||
};
|
||||
|
||||
const getSpecials = async (type, subType, page) =>{
|
||||
const getSpecials = async (data) =>{
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_ANIMEFLV_JELU}${type.url}/${subType}/${page}`, options);
|
||||
let body = data[type.prop];
|
||||
const promises = []
|
||||
const res = await homgot(`${BASE_ANIMEFLV_JELU}${data.url}/${data.type}/${data.page}`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
return res[data.prop].map(doc =>({
|
||||
id: doc.id,
|
||||
title: doc.title,
|
||||
type: doc.type,
|
||||
|
@ -242,163 +225,75 @@ const getSpecials = async (type, subType, page) =>{
|
|||
rate: doc.rating,
|
||||
genres: doc.genres.map(x => x),
|
||||
episodes: doc.episodes.map(x => x)
|
||||
});
|
||||
});
|
||||
|
||||
return promises;
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getMoreInfo = async (title) =>{
|
||||
|
||||
const promises = []
|
||||
let animeTitle = ''
|
||||
let animeId = ''
|
||||
let animeType = ''
|
||||
let animeIndex = ''
|
||||
|
||||
let seriesTitle
|
||||
let position
|
||||
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
|
||||
const res = data.filter(x => x.title === title || x.mal_title === title)[0];
|
||||
|
||||
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: 'Ansatsu Kyoushitsu (TV)', id: 'ansatsu-kyoushitsu-tv' },
|
||||
{ title: 'Ansatsu Kyoushitsu (TV) 2nd Season', id: 'ansatsu-kyoushitsu-tv-2nd-season' }
|
||||
];
|
||||
if (!res.jkanime) {
|
||||
if (res.type === 'Anime') {
|
||||
|
||||
const jkMyAnimetitles = [
|
||||
{ jkanime: 'Ansatsu Kyoushitsu (TV)', myanimelist: 'Ansatsu Kyoushitsu'},
|
||||
{ jkanime: 'Ansatsu Kyoushitsu (TV) 2nd Season', myanimelist: 'Ansatsu Kyoushitsu 2nd Season' }
|
||||
];
|
||||
|
||||
let jkanime = false
|
||||
let jkanimeID
|
||||
let jkanimeName
|
||||
for (let name in jkAnimeTitles) {
|
||||
if (title === jkAnimeTitles[name].title) {
|
||||
jkanime = true
|
||||
jkanimeID = jkAnimeTitles[name].id
|
||||
|
||||
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
|
||||
}
|
||||
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)
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (jkanime === false) {
|
||||
const titles = [
|
||||
{ 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: 'Hitoribocchi no ○○ Seikatsu', myanimelist: 'Hitoribocchi no Marumaru Seikatsu' },
|
||||
{ animeflv: 'Nekopara (TV)', myanimelist: 'Nekopara' },
|
||||
{ animeflv: 'Black Clover (TV)', myanimelist: 'Black Clover' }
|
||||
];
|
||||
|
||||
for (let name in titles) {
|
||||
if (title === titles[name].animeflv || title === titles[name].myanimelist || title === titles[name].alternative) {
|
||||
seriesTitle = titles[name].animeflv
|
||||
position = name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (seriesTitle === undefined) {
|
||||
seriesTitle = 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)` ||
|
||||
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
|
||||
animeIndex = animes[i].index
|
||||
animeType = animes[i].type.toLowerCase()
|
||||
|
||||
if (position !== undefined) {
|
||||
seriesTitle = titles[position].myanimelist
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
if (animeType === 'tv') {
|
||||
promises.push(await animeflvInfo(animeId, animeIndex).then(async extra => ({
|
||||
title: animeTitle || null,
|
||||
poster: await imageUrlToBase64(extra.animeExtraInfo[0].poster) || null,
|
||||
synopsis: extra.animeExtraInfo[0].synopsis || null,
|
||||
status: 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(seriesTitle).then(info =>{
|
||||
return info || null
|
||||
}),
|
||||
promo: await getAnimeVideoPromo(seriesTitle).then(promo =>{
|
||||
return promo || null
|
||||
}),
|
||||
characters: await getAnimeCharacters(seriesTitle).then(characters =>{
|
||||
return characters || null
|
||||
})
|
||||
})));
|
||||
} else {
|
||||
promises.push(await animeflvInfo(animeId).then(async extra => ({
|
||||
title: animeTitle || null,
|
||||
poster: await imageUrlToBase64(extra.animeExtraInfo[0].poster) || null,
|
||||
synopsis: extra.animeExtraInfo[0].synopsis || null,
|
||||
status: 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,
|
||||
})));
|
||||
}
|
||||
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
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 animeflvInfo(res.id).then(episodes => episodes || null)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
promises.push(await jkanimeInfo(jkanimeID).then(async extra => ({
|
||||
title: jkanimeName || null,
|
||||
poster: await imageUrlToBase64(extra.animeExtraInfo[0].poster) || null,
|
||||
synopsis: extra.animeExtraInfo[0].synopsis || null,
|
||||
status: 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(jkanimeName).then(info =>{
|
||||
return info || null
|
||||
}),
|
||||
promo: await getAnimeVideoPromo(jkanimeName).then(promo =>{
|
||||
return promo || null
|
||||
}),
|
||||
characters: await getAnimeCharacters(jkanimeName).then(characters =>{
|
||||
return characters || null
|
||||
})
|
||||
})));
|
||||
if (res.type === 'Anime') {
|
||||
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)
|
||||
});
|
||||
}
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return promises;
|
||||
|
@ -407,33 +302,11 @@ const getMoreInfo = async (title) =>{
|
|||
|
||||
const getAnimeServers = async (id) => {
|
||||
|
||||
const jkAnimeIDs = [
|
||||
{ id: 'the-god-of-high-school' },
|
||||
{ id: 'kami-no-tou' },
|
||||
{ id: 'bna' },
|
||||
{ id: 'ansatsu-kyoushitsu-tv' },
|
||||
{ id: 'ansatsu-kyoushitsu-tv-2nd-season' }
|
||||
];
|
||||
|
||||
let jkanime = false
|
||||
let jkanimeID
|
||||
for (let name in jkAnimeIDs) {
|
||||
if (id.includes(jkAnimeIDs[name].id)) {
|
||||
jkanime = true
|
||||
jkanimeID = id
|
||||
}
|
||||
}
|
||||
|
||||
if (jkanime === false) {
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_ANIMEFLV_JELU}GetAnimeServers/${id}`, options);
|
||||
let body = data.servers;
|
||||
|
||||
return await transformUrlServer(body);
|
||||
|
||||
if (isNaN(id.split('/')[0])) {
|
||||
return await videoServersJK(id)
|
||||
} else {
|
||||
return await videoServersJK(jkanimeID)
|
||||
const data = await homgot(`${BASE_ANIMEFLV_JELU}GetAnimeServers/${id}`, { parse: true });
|
||||
return await transformUrlServer(data.servers);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -442,60 +315,37 @@ const search = async (title) =>{ return await searchAnime(title); };
|
|||
|
||||
const getImages = async (query) => {
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, options);
|
||||
const body = data.data.result.items;
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_QWANT}count=${query.count}&q=${query.title}&t=${query.type}&safesearch=${query.safesearch}&locale=${query.country}&uiv=4`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
return data.data.result.items.map(doc =>({
|
||||
type: doc.thumb_type,
|
||||
thumbnail: `https:${doc.thumbnail}`,
|
||||
fullsize: `https:${doc.media_fullsize}`
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return promises;
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getYoutubeVideos = async (channelId) => {
|
||||
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, options);
|
||||
const body = data[channelId.prop];
|
||||
const promises = []
|
||||
const data = await homgot(`${BASE_YOUTUBE}${channelId.id}&part=${channelId.part}&order=${channelId.order}&maxResults=${channelId.maxResults}`, { parse: true });
|
||||
|
||||
body.map(doc =>{
|
||||
|
||||
promises.push({
|
||||
title: doc.snippet.title,
|
||||
videoId: doc.id.videoId,
|
||||
thumbDefault: doc.snippet.thumbnails.default.url,
|
||||
thumbMedium: doc.snippet.thumbnails.medium.url,
|
||||
thumbHigh: doc.snippet.thumbnails.high.url
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return promises;
|
||||
return data[channelId.prop].map(doc =>({
|
||||
title: doc.snippet.title,
|
||||
videoId: doc.id.videoId,
|
||||
thumbDefault: doc.snippet.thumbnails.default.url,
|
||||
thumbMedium: doc.snippet.thumbnails.medium.url,
|
||||
thumbHigh: doc.snippet.thumbnails.high.url
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const getRadioStations = async () => {
|
||||
return require('../assets/radiostations.json');
|
||||
}
|
||||
const getRadioStations = async () => require('../assets/radiostations.json');
|
||||
|
||||
const getOpAndEd = async (title) => {
|
||||
let data = await parserThemes.serie(title)
|
||||
return await structureThemes(data, true)
|
||||
};
|
||||
const getOpAndEd = async (title) => await structureThemes(await parserThemes.serie(title), true);
|
||||
|
||||
const getThemesYear = async (year) => {
|
||||
let data = []
|
||||
|
||||
let data = []
|
||||
if (year === undefined) {
|
||||
return await parserThemes.allYears();
|
||||
} else {
|
||||
|
@ -507,29 +357,23 @@ const getThemesYear = async (year) => {
|
|||
|
||||
const getRandomTheme = async () => {
|
||||
|
||||
let promise = []
|
||||
let options = { parse: true }
|
||||
const data = await homgot(`${BASE_THEMEMOE}roulette`, options);
|
||||
let data = await homgot(`${BASE_THEMEMOE}roulette`, { parse: true });
|
||||
let themes = await getThemes(data.themes)
|
||||
|
||||
promise.push({
|
||||
return themes.map(doc =>({
|
||||
name: data.name,
|
||||
title: themes[0].name,
|
||||
link: themes[0].video
|
||||
})
|
||||
title: doc.name,
|
||||
link: doc.video
|
||||
}));
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
const getArtist = async (id) => {
|
||||
|
||||
let data
|
||||
|
||||
if (id === undefined) {
|
||||
return await parserThemes.artists();
|
||||
} else {
|
||||
data = await parserThemes.artist(id)
|
||||
return await structureThemes(data, false)
|
||||
return await structureThemes(await parserThemes.artist(id), false)
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -538,15 +382,13 @@ const getAnimeGenres = async(genre, order, page) => {
|
|||
|
||||
let $
|
||||
let promises = []
|
||||
let options = { scrapy: true }
|
||||
|
||||
if (page !== undefined) {
|
||||
$ = await homgot(`${GENRES_URL}genre%5B%5D=${genre}&order=${order}&page=${page}`,options)
|
||||
$ = await homgot(`${GENRES_URL}genre%5B%5D=${genre}&order=${order}&page=${page}`,{ scrapy: true })
|
||||
} else {
|
||||
$ = await homgot(`${GENRES_URL}genre%5B%5D=${genre}&order=${order}`,options)
|
||||
$ = await homgot(`${GENRES_URL}genre%5B%5D=${genre}&order=${order}`,{ scrapy: true })
|
||||
}
|
||||
|
||||
|
||||
$('div.Container ul.ListAnimes li article').each((index , element) =>{
|
||||
const $element = $(element);
|
||||
const id = $element.find('div.Description a.Button').attr('href').slice(1);
|
||||
|
@ -574,10 +416,7 @@ const getAnimeGenres = async(genre, order, page) => {
|
|||
|
||||
};
|
||||
|
||||
const getAllThemes = async () => {
|
||||
let data = await parserThemes.all()
|
||||
return await structureThemes(data, false)
|
||||
};
|
||||
const getAllThemes = async () => await structureThemes(await parserThemes.all(), false);
|
||||
|
||||
module.exports = {
|
||||
schedule,
|
||||
|
|
|
@ -25,11 +25,9 @@ router.get('/schedule/:day' , (req, res) =>{
|
|||
|
||||
router.get('/top/:type/:subtype/:page' , (req, res) =>{
|
||||
|
||||
let type = req.params.type;
|
||||
let subtype = req.params.subtype;
|
||||
let page = req.params.page;
|
||||
let top = {type: req.params.type, subtype: req.params.subtype, page: req.params.page}
|
||||
|
||||
api.top(type, subtype, page)
|
||||
api.top(top)
|
||||
.then(top =>{
|
||||
if (top.length > 0) {
|
||||
res.status(200).json({
|
||||
|
@ -121,10 +119,9 @@ router.get('/news' , (req, res) =>{
|
|||
|
||||
router.get('/season/:year/:type' , (req, res) =>{
|
||||
|
||||
let year = req.params.year;
|
||||
let type = req.params.type;
|
||||
let season = {year: req.params.year, type: req.params.type}
|
||||
|
||||
api.season(year, type)
|
||||
api.season(season)
|
||||
.then(season =>{
|
||||
if (season.length > 0) {
|
||||
res.status(200).json({
|
||||
|
@ -192,11 +189,9 @@ router.get('/lastEpisodes' , (req, res) =>{
|
|||
|
||||
router.get('/movies/:type/:page' , (req, res) =>{
|
||||
|
||||
let type = {url: 'Movies', prop: 'movies'}
|
||||
let subType = req.params.type;
|
||||
let page = req.params.page;
|
||||
let data = {url: 'Movies', prop: 'movies', type: req.params.type, page: req.params.page }
|
||||
|
||||
api.getSpecials(type, subType, page)
|
||||
api.getSpecials(data)
|
||||
.then(movies =>{
|
||||
if (movies.length > 0) {
|
||||
res.status(200).json({
|
||||
|
@ -213,11 +208,9 @@ router.get('/movies/:type/:page' , (req, res) =>{
|
|||
|
||||
router.get('/ovas/:type/:page' , (req, res) =>{
|
||||
|
||||
let type = {url: 'Ova', prop: 'ova'}
|
||||
let subType = req.params.type;
|
||||
let page = req.params.page;
|
||||
let data = {url: 'Ova', prop: 'ova', type: req.params.type, page: req.params.page }
|
||||
|
||||
api.getSpecials(type, subType, page)
|
||||
api.getSpecials(data)
|
||||
.then(ovas =>{
|
||||
if (ovas.length > 0) {
|
||||
res.status(200).json({
|
||||
|
@ -234,11 +227,9 @@ router.get('/ovas/:type/:page' , (req, res) =>{
|
|||
|
||||
router.get('/specials/:type/:page' , (req, res) =>{
|
||||
|
||||
let type = {url: 'Special', prop: 'special'}
|
||||
let subType = req.params.type;
|
||||
let page = req.params.page;
|
||||
let data = {url: 'Special', prop: 'special', type: req.params.type, page: req.params.page }
|
||||
|
||||
api.getSpecials(type, subType, page)
|
||||
api.getSpecials(data)
|
||||
.then(specials =>{
|
||||
if (specials.length > 0) {
|
||||
res.status(200).json({
|
||||
|
@ -255,11 +246,9 @@ router.get('/specials/:type/:page' , (req, res) =>{
|
|||
|
||||
router.get('/tv/:type/:page' , (req, res) =>{
|
||||
|
||||
let type = {url: 'Tv', prop: 'tv'}
|
||||
let subType = req.params.type;
|
||||
let page = req.params.page;
|
||||
let data = {url: 'Tv', prop: 'tv', type: req.params.type, page: req.params.page }
|
||||
|
||||
api.getSpecials(type, subType, page)
|
||||
api.getSpecials(data)
|
||||
.then(tv =>{
|
||||
if (tv.length > 0) {
|
||||
res.status(200).json({
|
||||
|
|
|
@ -14,8 +14,6 @@ app.use(cors());
|
|||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.set('Cache-Control', 'no-store');
|
||||
res.redirect('/api/')
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,6 @@
|
|||
const app = require('./app');
|
||||
const port = process.env.PORT || 5000;
|
||||
const addr = isNaN(port) ?
|
||||
'' :
|
||||
(process.env.ADDR || '0.0.0.0');
|
||||
const addr = isNaN(port) ? '' : (process.env.ADDR || '0.0.0.0');
|
||||
|
||||
server = app.listen(port, addr, () => {
|
||||
/* eslint-disable no-console */
|
||||
|
@ -11,7 +9,7 @@ server = app.listen(port, addr, () => {
|
|||
});
|
||||
|
||||
function shutdown() {
|
||||
server.close(); // socket file is automatically removed here
|
||||
server.close();
|
||||
process.exit();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const {
|
||||
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, SEARCH_URL, SEARCH_DIRECTORY, BASE_ARUPPI, BASE_JKANIME, JKANIME_URL
|
||||
BASE_ANIMEFLV, BASE_JIKAN, BASE_ARUPPI, BASE_JKANIME
|
||||
} = require('../api/urls');
|
||||
|
||||
const {
|
||||
|
@ -21,23 +21,17 @@ global.btoa = btoa;
|
|||
|
||||
async function videoServersJK(id) {
|
||||
|
||||
let options = { scrapy: true }
|
||||
const $ = await homgot(`${BASE_JKANIME}${id}`, options);
|
||||
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) =>{
|
||||
const $element = $(element);
|
||||
const serverName = $element.find('a').text();
|
||||
serverNames.push(serverName);
|
||||
})
|
||||
episodes.each((index , element) => serverNames.push($(element).find('a').text()))
|
||||
|
||||
for(let i = 0; i < scripts.length; i++){
|
||||
const $script = $(scripts[i]);
|
||||
const contents = $script.html();
|
||||
const contents = $(scripts[i]).html();
|
||||
try{
|
||||
if ((contents || '').includes('var video = [];')) {
|
||||
Array.from({length: episodes.length} , (v , k) =>{
|
||||
|
@ -67,8 +61,7 @@ async function videoServersJK(id) {
|
|||
|
||||
async function getVideoURL(url) {
|
||||
|
||||
let options = { scrapy: true }
|
||||
const $ = await homgot(url, options);
|
||||
const $ = await homgot(url, { scrapy: true });
|
||||
|
||||
const video = $('video');
|
||||
if(video.length){
|
||||
|
@ -88,207 +81,76 @@ async function getVideoURL(url) {
|
|||
|
||||
const jkanimeInfo = async (id) => {
|
||||
|
||||
let poster = ""
|
||||
let banner = ""
|
||||
let synopsis = ""
|
||||
let rating = ""
|
||||
let debut = ""
|
||||
let type = ""
|
||||
let $
|
||||
let $ = await homgot(`${BASE_JKANIME}${id}`, { scrapy: true });
|
||||
|
||||
try {
|
||||
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${BASE_JKANIME}${id}`, options);
|
||||
|
||||
const animeExtraInfo = [];
|
||||
const genres = [];
|
||||
let listByEps;
|
||||
|
||||
poster = $('div[id="container"] div.serie-info div.cap-portada')[0].children[1].attribs.src;
|
||||
banner = $('div[id="container"] div.serie-info div.cap-portada')[0].children[1].attribs.src;
|
||||
synopsis = $('div[id="container"] div.serie-info div.sinopsis-box p')[0].children[1].data;
|
||||
rating = "Sin calificación"
|
||||
debut = $('div[id="container"] div.serie-info div.info-content div')[6].children[3].children[0].children[0].data;
|
||||
type = $('div[id="container"] div.serie-info div.info-content div')[0].children[3].children[0].data
|
||||
|
||||
animeExtraInfo.push({
|
||||
poster: poster,
|
||||
banner: banner,
|
||||
synopsis: synopsis,
|
||||
rating: rating,
|
||||
debut: debut,
|
||||
type: type,
|
||||
})
|
||||
|
||||
let rawGenres = $('div[id="container"] div.serie-info div.info-content div')[1].children[3].children
|
||||
for (let i = 0; i <= rawGenres.length -1; i++) {
|
||||
if (rawGenres[i].name === 'a') {
|
||||
const genre = rawGenres[i].children[0].data
|
||||
genres.push(genre)
|
||||
}
|
||||
}
|
||||
|
||||
let nextEpisodeDate
|
||||
let rawNextEpisode = $('div[id="container"] div.left-container div[id="proxep"] p')[0]
|
||||
if (rawNextEpisode === undefined) {
|
||||
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 {
|
||||
if (rawNextEpisode.children[1].data === ' ') {
|
||||
nextEpisodeDate = null
|
||||
} else {
|
||||
nextEpisodeDate = rawNextEpisode
|
||||
}
|
||||
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 imagePreview = $('div[id="container"] div.content-box div[id="episodes-content"]')[0].children[1].children[3].attribs.src
|
||||
let link = `${animeId}/${episode}`
|
||||
|
||||
animeListEps.push({
|
||||
episode: episode,
|
||||
id: link,
|
||||
imagePreview: imagePreview
|
||||
})
|
||||
}
|
||||
|
||||
listByEps = animeListEps;
|
||||
|
||||
return {listByEps, genres, animeExtraInfo};
|
||||
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
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 promises = [];
|
||||
|
||||
let options = { scrapy: true }
|
||||
let $ = await homgot(`${BASE_ANIMEFLV}${id}`, options);
|
||||
|
||||
let $ = await homgot(`${BASE_ANIMEFLV}${id}`, { scrapy: true });
|
||||
$('main.Main section.WdgtCn nav.Nvgnrs a').each((index, element) => {
|
||||
const $element = $(element);
|
||||
const genre = $element.attr('href').split('=')[1] || null;
|
||||
promises.push(genre);
|
||||
return $(element).attr('href').split('=')[1] || null;
|
||||
});
|
||||
|
||||
return promises;
|
||||
|
||||
}
|
||||
|
||||
const animeflvInfo = async (id, index) => {
|
||||
const animeflvInfo = async (id) => {
|
||||
|
||||
let poster = ""
|
||||
let banner = ""
|
||||
let synopsis = ""
|
||||
let rating = ""
|
||||
let debut = ""
|
||||
let type = ""
|
||||
let $
|
||||
let $ = await homgot(`${BASE_ANIMEFLV}anime/${id}`, { scrapy: true });
|
||||
let scripts = $('script').toArray();
|
||||
|
||||
try {
|
||||
for (const pata in scripts) {
|
||||
if (scripts[pata].children.length > 0) {
|
||||
if (scripts[pata].children[0].data.includes('var episodes')){
|
||||
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${BASE_ANIMEFLV}anime/${id}`, options);
|
||||
let scriptInnerHTML = scripts[pata].children[0].data.trim()
|
||||
const startIndex = scriptInnerHTML.indexOf('var episodes') + 'var episodes'.length
|
||||
const endIndex = scriptInnerHTML.indexOf(';', startIndex)
|
||||
|
||||
const scripts = $('script');
|
||||
const anime_info_ids = [];
|
||||
const anime_eps_data = [];
|
||||
const animeExtraInfo = [];
|
||||
const genres = [];
|
||||
let listByEps;
|
||||
const episodesJSON = JSON.parse(scriptInnerHTML.substring(startIndex, endIndex).split('=')[1].trim())
|
||||
return episodesJSON.map(item => ({
|
||||
index: item[0],
|
||||
id: `${item[1]}/${id}-${item[0]}`,
|
||||
}))
|
||||
|
||||
poster = `${BASE_ANIMEFLV}` + $('body div div div div div aside div.AnimeCover div.Image figure img').attr('src')
|
||||
banner = poster.replace('covers', 'banners').trim();
|
||||
synopsis = $('body div div div div div main section div.Description p').text().trim();
|
||||
rating = $('body div div div.Ficha.fchlt div.Container div.vtshr div.Votes span#votes_prmd').text();
|
||||
debut = $('body div.Wrapper div.Body div div.Container div.BX.Row.BFluid.Sp20 aside.SidebarA.BFixed p.AnmStts').text();
|
||||
type = $('body div.Wrapper div.Body div div.Ficha.fchlt div.Container span.Type').text()
|
||||
|
||||
animeExtraInfo.push({
|
||||
poster: poster,
|
||||
banner: banner,
|
||||
synopsis: synopsis,
|
||||
rating: rating,
|
||||
debut: debut,
|
||||
type: type,
|
||||
})
|
||||
|
||||
$('main.Main section.WdgtCn nav.Nvgnrs a').each((index, element) => {
|
||||
const $element = $(element);
|
||||
const genre = $element.attr('href').split('=')[1] || null;
|
||||
genres.push(genre);
|
||||
});
|
||||
|
||||
|
||||
Array.from({length: scripts.length}, (v, k) => {
|
||||
const $script = $(scripts[k]);
|
||||
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);
|
||||
anime_info_ids.push(dat_anime_info);
|
||||
}
|
||||
if ((contents || '').includes('var episodes = [')) {
|
||||
let episodes = contents.split('var episodes = ')[1].split(';')[0];
|
||||
let eps_data = JSON.parse(episodes)
|
||||
anime_eps_data.push(eps_data);
|
||||
}
|
||||
});
|
||||
const AnimeThumbnailsId = index;
|
||||
const animeId = id;
|
||||
let nextEpisodeDate
|
||||
|
||||
if (anime_info_ids.length > 0) {
|
||||
if (anime_info_ids[0].length === 4) {
|
||||
nextEpisodeDate = anime_info_ids[0][3]
|
||||
} else {
|
||||
nextEpisodeDate = null
|
||||
}
|
||||
}
|
||||
|
||||
const amimeTempList = [];
|
||||
for (const [key, value] of Object.entries(anime_eps_data)) {
|
||||
let episode = anime_eps_data[key].map(x => x[0]);
|
||||
let episodeId = anime_eps_data[key].map(x => x[1]);
|
||||
amimeTempList.push(episode, episodeId);
|
||||
}
|
||||
const animeListEps = [{nextEpisodeDate: nextEpisodeDate}];
|
||||
Array.from({length: amimeTempList[1].length}, (v, k) => {
|
||||
let data = amimeTempList.map(x => x[k]);
|
||||
let episode = data[0];
|
||||
let id = data[1];
|
||||
let imagePreview = `${BASE_EPISODE_IMG_URL}${AnimeThumbnailsId}/${episode}/th_3.jpg`
|
||||
let link = `${id}/${animeId}-${episode}`
|
||||
|
||||
animeListEps.push({
|
||||
episode: episode,
|
||||
id: link,
|
||||
imagePreview: imagePreview
|
||||
})
|
||||
})
|
||||
|
||||
listByEps = animeListEps;
|
||||
|
||||
return {listByEps, genres, animeExtraInfo};
|
||||
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -296,28 +158,21 @@ const animeflvInfo = async (id, index) => {
|
|||
const getAnimeCharacters = async (title) => {
|
||||
|
||||
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}`, { parse: true });
|
||||
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 malId === 'undefined') return null;
|
||||
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, options);
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}/characters_staff`, { parse: true });
|
||||
let body = data.characters;
|
||||
|
||||
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
|
||||
});
|
||||
const charactersId = body.map(doc => doc.mal_id)
|
||||
const charactersNames = body.map(doc => doc.name);
|
||||
const charactersImages = body.map(doc => doc.image_url);
|
||||
|
||||
let characters = [];
|
||||
Array.from({length: charactersNames.length}, (v, k) => {
|
||||
|
@ -341,14 +196,14 @@ const getAnimeCharacters = async (title) => {
|
|||
const getAnimeVideoPromo = async (title) => {
|
||||
|
||||
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}`, { parse: true });
|
||||
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 malId === 'undefined') return null;
|
||||
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, options);
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}/videos`, { parse: true });
|
||||
const body = data.promo;
|
||||
const promises = [];
|
||||
|
||||
|
@ -371,14 +226,13 @@ const animeExtraInfo = async (title) => {
|
|||
|
||||
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}`, { parse: true });
|
||||
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 malId === 'undefined') return null;
|
||||
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, options);
|
||||
const data = await homgot(`${BASE_JIKAN}anime/${malId}`, { parse: true });
|
||||
const body = Array(data);
|
||||
const promises = [];
|
||||
|
||||
|
@ -433,7 +287,6 @@ const animeExtraInfo = async (title) => {
|
|||
console.log(e.message)
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const imageUrlToBase64 = async (url) => {
|
||||
|
@ -445,93 +298,41 @@ const helper = async () => {}
|
|||
|
||||
const searchAnime = async (query) => {
|
||||
|
||||
let $
|
||||
let promises = []
|
||||
let data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
|
||||
const res = data.filter(x => x.title.includes(query));
|
||||
|
||||
const jkAnimeTitles = [
|
||||
{ title: 'BNA', search: 'BNA'},
|
||||
{ title: 'The God of High School', search: 'The god' },
|
||||
{ title: 'Ansatsu Kyoshitsu', search: 'Assassination Classroom' },
|
||||
];
|
||||
|
||||
let jkanime = false
|
||||
let jkanimeName
|
||||
for (let name in jkAnimeTitles) {
|
||||
if (query === jkAnimeTitles[name].title) {
|
||||
jkanime = true
|
||||
jkanimeName = jkAnimeTitles[name].search
|
||||
}
|
||||
}
|
||||
|
||||
if (jkanime === false) {
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${SEARCH_URL}${query}`, options);
|
||||
$('div.Container ul.ListAnimes li article').each((index, element) => {
|
||||
const $element = $(element);
|
||||
const id = $element.find('div.Description a.Button').attr('href').slice(1);
|
||||
const title = $element.find('a h3').text();
|
||||
let poster = $element.find('a div.Image figure img').attr('src') || $element.find('a div.Image figure img').attr('data-cfsrc');
|
||||
const type = $element.find('div.Description p span.Type').text();
|
||||
|
||||
promises.push(helper().then(async () => ({
|
||||
id: id || null,
|
||||
title: title || null,
|
||||
type: type || null,
|
||||
image: await imageUrlToBase64(poster) || null
|
||||
})));
|
||||
|
||||
})
|
||||
} else {
|
||||
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${JKANIME_URL}${jkanimeName}`, options);
|
||||
|
||||
$('.portada-box').each(function (index, element) {
|
||||
const $element = $(element);
|
||||
const title = $element.find('h2.portada-title a').attr('title');
|
||||
const id = $element.find('a.let-link').attr('href').split('/')[3];
|
||||
const poster = $element.find('a').children('img').attr('src');
|
||||
promises.push(helper().then(async () => ({
|
||||
id: id || null,
|
||||
title: title || null,
|
||||
type: 'Anime',
|
||||
image: await imageUrlToBase64(poster) || null
|
||||
})))
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
return res.map(doc => ({
|
||||
id: doc.id || null,
|
||||
title: doc.title || null,
|
||||
type: doc.type || null,
|
||||
image: doc.poster || null
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
const transformUrlServer = async (urlReal) => {
|
||||
|
||||
let res
|
||||
const promises = []
|
||||
|
||||
for (const index in urlReal) {
|
||||
if (urlReal[index].server === 'amus' || urlReal[index].server === 'natsuki') {
|
||||
|
||||
let options = { parse: true }
|
||||
res = await homgot(urlReal[index].code.replace("embed", "check"), options);
|
||||
|
||||
urlReal[index].code = res.file || null
|
||||
urlReal[index].direct = true
|
||||
} else if (urlReal[index].server === 'gocdn' ) {
|
||||
urlReal[index].code = `https://s1.streamium.xyz/gocdn.php?v=${urlReal[index].code.split('/player_gocdn.html#')[1]}`
|
||||
urlReal[index].direct = true
|
||||
for (const data of urlReal) {
|
||||
if (data.server === 'amus' || data.server === 'natsuki') {
|
||||
let res = await homgot(data.code.replace("embed", "check"), { parse: true });
|
||||
data.code = res.file || null
|
||||
data.direct = true
|
||||
} else if (data.server === 'gocdn' ) {
|
||||
if (data.code.split('/player_gocdn.html#')[1] === undefined) {
|
||||
data.code = `https://s1.streamium.xyz/gocdn.php?v=${data.code.split('/gocdn.html#')[1]}`
|
||||
} else {
|
||||
data.code = `https://s1.streamium.xyz/gocdn.php?v=${data.code.split('/player_gocdn.html#')[1]}`
|
||||
}
|
||||
data.direct = true
|
||||
}
|
||||
}
|
||||
|
||||
urlReal.map(doc => {
|
||||
promises.push({
|
||||
id: doc.title.toLowerCase(),
|
||||
url: doc.code,
|
||||
direct: doc.direct || false
|
||||
});
|
||||
});
|
||||
return urlReal.map(doc =>({
|
||||
id: doc.title.toLowerCase(),
|
||||
url: doc.code,
|
||||
direct: doc.direct || false
|
||||
}));
|
||||
|
||||
return promises;
|
||||
}
|
||||
|
||||
const obtainPreviewNews = (encoded) => {
|
||||
|
@ -539,7 +340,11 @@ const obtainPreviewNews = (encoded) => {
|
|||
let image;
|
||||
|
||||
if (encoded.includes('src="https://img1.ak.crunchyroll.com/')) {
|
||||
image = `https://img1.ak.crunchyroll.com/${encoded.split('https://img1.ak.crunchyroll.com/')[1].split('.jpg')[0]}.jpg`
|
||||
if (encoded.split('https://img1.ak.crunchyroll.com/')[1].includes('.jpg')) {
|
||||
image = `https://img1.ak.crunchyroll.com/${encoded.split('https://img1.ak.crunchyroll.com/')[1].split('.jpg')[0]}.jpg`
|
||||
} else {
|
||||
image = `https://img1.ak.crunchyroll.com/${encoded.split('https://img1.ak.crunchyroll.com/')[1].split('.png')[0]}.png`
|
||||
}
|
||||
} else if (encoded.includes('<img title=')) {
|
||||
image = encoded.substring(encoded.indexOf("<img title=\""), encoded.indexOf("\" alt")).split('src=\"')[1]
|
||||
} else if (encoded.includes('<img src=')) {
|
||||
|
@ -599,7 +404,6 @@ const structureThemes = async (body, indv) => {
|
|||
|
||||
};
|
||||
|
||||
|
||||
const getThemesData = async (themes) => {
|
||||
|
||||
let promises = []
|
||||
|
@ -621,61 +425,13 @@ const getThemesData = async (themes) => {
|
|||
|
||||
const getThemes = async (themes) => {
|
||||
|
||||
let promises = []
|
||||
return themes.map(doc =>({
|
||||
name: doc.themeName,
|
||||
type: doc.themeType,
|
||||
video: doc.mirror.mirrorURL
|
||||
`${BASE_ANIMEFLV}anime/${id}`
|
||||
}));
|
||||
|
||||
themes.map(doc => {
|
||||
|
||||
promises.push({
|
||||
name: doc.themeName,
|
||||
type: doc.themeType,
|
||||
video: doc.mirror.mirrorURL
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return promises;
|
||||
|
||||
};
|
||||
|
||||
const getAnimes = async () => {
|
||||
let options = { parse: true }
|
||||
return await homgot(`${BASE_ANIMEFLV}api/animes/list`, options);
|
||||
};
|
||||
|
||||
|
||||
const getDirectory = async () => {
|
||||
|
||||
let $
|
||||
let promises = []
|
||||
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${SEARCH_URL}`, options);
|
||||
const lastPage = $('body div.Wrapper div.Container main div.NvCnAnm ul li a')[11].children[0].data
|
||||
|
||||
for (let i = 1; i <= lastPage; i++) {
|
||||
|
||||
let options = { scrapy: true }
|
||||
$ = await homgot(`${SEARCH_DIRECTORY}${i}`, options);
|
||||
|
||||
$('div.Container ul.ListAnimes li article').each((index, element) => {
|
||||
const $element = $(element);
|
||||
const id = $element.find('div.Description a.Button').attr('href').slice(1);
|
||||
const title = $element.find('a h3').text();
|
||||
let poster = $element.find('a div.Image figure img').attr('src') || $element.find('a div.Image figure img').attr('data-cfsrc');
|
||||
const type = $element.find('div.Description p span.Type').text();
|
||||
|
||||
promises.push(helper().then(async () => ({
|
||||
id: id || null,
|
||||
title: title || null,
|
||||
type: type || null,
|
||||
image: await imageUrlToBase64(poster) || null
|
||||
})));
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -691,8 +447,6 @@ module.exports = {
|
|||
obtainPreviewNews,
|
||||
structureThemes,
|
||||
getThemes,
|
||||
getAnimes,
|
||||
getDirectory,
|
||||
helper,
|
||||
videoServersJK
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue