🤖 Fixing some issues with extraInfo in the call to getEpisodes

pull/46/head
capitanwesler 4 years ago
parent 5708086201
commit f2e13f5201

@ -19,6 +19,7 @@ module.exports = {
'class-methods-use-this': 'off', 'class-methods-use-this': 'off',
camelcase: 'off', camelcase: 'off',
'no-unused-vars': 'warn', 'no-unused-vars': 'warn',
'no-undef': 'warn',
}, },
settings: { settings: {
'import/resolver': { 'import/resolver': {

@ -1,4 +1,4 @@
# **Aruppi API** (v4.0.6) # **Aruppi API** (v4.0.7)
> 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
> >

@ -1,6 +1,6 @@
{ {
"name": "aruppi", "name": "aruppi",
"version": "4.0.6", "version": "4.0.7",
"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.ts", "main": "./src/api/api.ts",
"scripts": { "scripts": {

@ -26,7 +26,7 @@ routes.get('/api/v4/', (req: Request, res: Response) => {
res.json({ res.json({
message: 'Aruppi /api - 🎏', message: 'Aruppi /api - 🎏',
author: 'Jéluchu', author: 'Jéluchu',
version: '4.0.6', version: '4.0.7',
credits: 'The bitch loves /apis that offers data to Aruppi App', credits: 'The bitch loves /apis that offers data to Aruppi App',
entries: [ entries: [
{ {

@ -344,9 +344,6 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => {
let countEpisodes: string[] = []; let countEpisodes: string[] = [];
try { try {
/* Extra info of the anime */
extraInfo = await animeExtraInfo(mal_id);
if (redisClient.connected) { if (redisClient.connected) {
const resultQueryRedis: any = await redisClient.get( const resultQueryRedis: any = await redisClient.get(
`jkanimeInfo_${hashStringMd5(id!)}`, `jkanimeInfo_${hashStringMd5(id!)}`,
@ -363,8 +360,11 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => {
scrapy: true, scrapy: true,
parse: false, parse: false,
}); });
/* Extra info of the anime */
extraInfo = (await animeExtraInfo(mal_id)) || undefined;
} catch (err) { } catch (err) {
return err; console.log(err);
} }
countEpisodes = $('div.anime__pagination a') countEpisodes = $('div.anime__pagination a')
@ -377,6 +377,7 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => {
'-', '-',
)[1]; )[1];
if (extraInfo) {
let broadCastDate = new Date(); let broadCastDate = new Date();
let dd: number, mm: string | number, yyyy: number; let dd: number, mm: string | number, yyyy: number;
@ -428,6 +429,7 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => {
}); });
} }
} }
}
for (let i = 1; i <= parseInt(episodesCount); i++) { for (let i = 1; i <= parseInt(episodesCount); i++) {
episodesList.push({ episodesList.push({
@ -468,9 +470,6 @@ export const monoschinosInfo = async (
let extraInfo: any; let extraInfo: any;
try { try {
/* Extra info of the anime */
extraInfo = await animeExtraInfo(mal_id);
if (redisClient.connected) { if (redisClient.connected) {
const resultQueryRedis: any = await redisClient.get( const resultQueryRedis: any = await redisClient.get(
`monoschinosInfo_${hashStringMd5(id!)}`, `monoschinosInfo_${hashStringMd5(id!)}`,
@ -487,10 +486,14 @@ export const monoschinosInfo = async (
scrapy: true, scrapy: true,
parse: false, parse: false,
}); });
/* Extra info of the anime */
extraInfo = (await animeExtraInfo(mal_id)) || undefined;
} catch (err) { } catch (err) {
return err; console.log(err);
} }
if (extraInfo) {
let broadCastDate = new Date(); let broadCastDate = new Date();
let dd: number, mm: string | number, yyyy: number; let dd: number, mm: string | number, yyyy: number;
@ -542,6 +545,7 @@ export const monoschinosInfo = async (
}); });
} }
} }
}
$('.SerieCaps a').each((index: number, element: cheerio.Element) => { $('.SerieCaps a').each((index: number, element: cheerio.Element) => {
let episode: number; let episode: number;
@ -593,9 +597,6 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => {
let extraInfo: any; let extraInfo: any;
try { try {
/* Extra info of the anime */
extraInfo = await animeExtraInfo(mal_id);
if (redisClient.connected) { if (redisClient.connected) {
const resultQueryRedis: any = await redisClient.get( const resultQueryRedis: any = await redisClient.get(
`tioanimeInfo_${hashStringMd5(id!)}`, `tioanimeInfo_${hashStringMd5(id!)}`,
@ -612,10 +613,14 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => {
scrapy: true, scrapy: true,
parse: false, parse: false,
}); });
/* Extra info of the anime */
extraInfo = (await animeExtraInfo(mal_id)) || undefined;
} catch (err) { } catch (err) {
return err; console.log(err);
} }
if (extraInfo) {
let broadCastDate = new Date(); let broadCastDate = new Date();
let dd: number, mm: string | number, yyyy: number; let dd: number, mm: string | number, yyyy: number;
@ -667,6 +672,7 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => {
}); });
} }
} }
}
const scripts: cheerio.Element[] = $('script').toArray(); const scripts: cheerio.Element[] = $('script').toArray();

Loading…
Cancel
Save