diff --git a/.eslintrc.js b/.eslintrc.js index 7877f5f..a320bb9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { 'class-methods-use-this': 'off', camelcase: 'off', 'no-unused-vars': 'warn', + 'no-undef': 'warn', }, settings: { 'import/resolver': { diff --git a/README.md b/README.md index dd3d405..eee4cd8 100644 --- a/README.md +++ b/README.md @@ -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 > diff --git a/package.json b/package.json index fcdd4ff..f4f5291 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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", "main": "./src/api/api.ts", "scripts": { diff --git a/src/routes.ts b/src/routes.ts index d005e5c..9081e73 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -26,7 +26,7 @@ routes.get('/api/v4/', (req: Request, res: Response) => { res.json({ message: 'Aruppi /api - 🎏', author: 'Jéluchu', - version: '4.0.6', + version: '4.0.7', credits: 'The bitch loves /apis that offers data to Aruppi App', entries: [ { diff --git a/src/utils/util.ts b/src/utils/util.ts index 41c43a1..be35723 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -344,9 +344,6 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => { let countEpisodes: string[] = []; try { - /* Extra info of the anime */ - extraInfo = await animeExtraInfo(mal_id); - if (redisClient.connected) { const resultQueryRedis: any = await redisClient.get( `jkanimeInfo_${hashStringMd5(id!)}`, @@ -363,8 +360,11 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => { scrapy: true, parse: false, }); + + /* Extra info of the anime */ + extraInfo = (await animeExtraInfo(mal_id)) || undefined; } catch (err) { - return err; + console.log(err); } countEpisodes = $('div.anime__pagination a') @@ -377,55 +377,57 @@ export const jkanimeInfo = async (id: string | undefined, mal_id: number) => { '-', )[1]; - let broadCastDate = new Date(); - let dd: number, mm: string | number, yyyy: number; + if (extraInfo) { + let broadCastDate = new Date(); + let dd: number, mm: string | number, yyyy: number; + + const airDay: any = { + Lunes: 1, + Martes: 2, + Miércoles: 3, + Jueves: 4, + Viernes: 5, + Sábados: 6, + Domingos: 7, + 'Sin emisión': 'default', + }; - const airDay: any = { - Lunes: 1, - Martes: 2, - Miércoles: 3, - Jueves: 4, - Viernes: 5, - Sábados: 6, - Domingos: 7, - 'Sin emisión': 'default', - }; + if (!extraInfo.aired.to) { + if (airDay.hasOwnProperty(extraInfo.broadcast)) { + if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { + for ( + let i = broadCastDate.getDay(); + i < airDay[extraInfo.broadcast]; + i++ + ) { + broadCastDate.setDate(broadCastDate.getDate() + 1); + } + } else { + let counter = broadCastDate.getDay() + 1; - if (!extraInfo.aired.to) { - if (airDay.hasOwnProperty(extraInfo.broadcast)) { - if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { - for ( - let i = broadCastDate.getDay(); - i < airDay[extraInfo.broadcast]; - i++ - ) { + /* Adding one because of the day */ broadCastDate.setDate(broadCastDate.getDate() + 1); - } - } else { - let counter = broadCastDate.getDay() + 1; - - /* Adding one because of the day */ - broadCastDate.setDate(broadCastDate.getDate() + 1); - while (counter !== airDay[extraInfo.broadcast]) { - if (counter === 7) { - counter = 0; + while (counter !== airDay[extraInfo.broadcast]) { + if (counter === 7) { + counter = 0; + } + broadCastDate.setDate(broadCastDate.getDate() + 1); + counter++; } - broadCastDate.setDate(broadCastDate.getDate() + 1); - counter++; } - } - dd = broadCastDate.getDate(); - mm = - broadCastDate.getMonth() + 1 < 10 - ? `0${broadCastDate.getMonth() + 1}` - : broadCastDate.getMonth() + 1; - yyyy = broadCastDate.getFullYear(); + dd = broadCastDate.getDate(); + mm = + broadCastDate.getMonth() + 1 < 10 + ? `0${broadCastDate.getMonth() + 1}` + : broadCastDate.getMonth() + 1; + yyyy = broadCastDate.getFullYear(); - episodesList.push({ - nextEpisodeDate: `${yyyy}-${mm}-${dd}`, - }); + episodesList.push({ + nextEpisodeDate: `${yyyy}-${mm}-${dd}`, + }); + } } } @@ -468,9 +470,6 @@ export const monoschinosInfo = async ( let extraInfo: any; try { - /* Extra info of the anime */ - extraInfo = await animeExtraInfo(mal_id); - if (redisClient.connected) { const resultQueryRedis: any = await redisClient.get( `monoschinosInfo_${hashStringMd5(id!)}`, @@ -487,59 +486,64 @@ export const monoschinosInfo = async ( scrapy: true, parse: false, }); + + /* Extra info of the anime */ + extraInfo = (await animeExtraInfo(mal_id)) || undefined; } catch (err) { - return err; + console.log(err); } - let broadCastDate = new Date(); - let dd: number, mm: string | number, yyyy: number; + if (extraInfo) { + let broadCastDate = new Date(); + let dd: number, mm: string | number, yyyy: number; + + const airDay: any = { + Lunes: 1, + Martes: 2, + Miércoles: 3, + Jueves: 4, + Viernes: 5, + Sábados: 6, + Domingos: 7, + 'Sin emisión': 'default', + }; - const airDay: any = { - Lunes: 1, - Martes: 2, - Miércoles: 3, - Jueves: 4, - Viernes: 5, - Sábados: 6, - Domingos: 7, - 'Sin emisión': 'default', - }; + if (!extraInfo.aired.to) { + if (airDay.hasOwnProperty(extraInfo.broadcast)) { + if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { + for ( + let i = broadCastDate.getDay(); + i < airDay[extraInfo.broadcast]; + i++ + ) { + broadCastDate.setDate(broadCastDate.getDate() + 1); + } + } else { + let counter = broadCastDate.getDay() + 1; - if (!extraInfo.aired.to) { - if (airDay.hasOwnProperty(extraInfo.broadcast)) { - if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { - for ( - let i = broadCastDate.getDay(); - i < airDay[extraInfo.broadcast]; - i++ - ) { + /* Adding one because of the day */ broadCastDate.setDate(broadCastDate.getDate() + 1); - } - } else { - let counter = broadCastDate.getDay() + 1; - /* Adding one because of the day */ - broadCastDate.setDate(broadCastDate.getDate() + 1); - - while (counter !== airDay[extraInfo.broadcast]) { - if (counter === 7) { - counter = 0; + while (counter !== airDay[extraInfo.broadcast]) { + if (counter === 7) { + counter = 0; + } + broadCastDate.setDate(broadCastDate.getDate() + 1); + counter++; } - broadCastDate.setDate(broadCastDate.getDate() + 1); - counter++; } - } - dd = broadCastDate.getDate(); - mm = - broadCastDate.getMonth() + 1 < 10 - ? `0${broadCastDate.getMonth() + 1}` - : broadCastDate.getMonth() + 1; - yyyy = broadCastDate.getFullYear(); + dd = broadCastDate.getDate(); + mm = + broadCastDate.getMonth() + 1 < 10 + ? `0${broadCastDate.getMonth() + 1}` + : broadCastDate.getMonth() + 1; + yyyy = broadCastDate.getFullYear(); - episodeList.push({ - nextEpisodeDate: `${yyyy}-${mm}-${dd}`, - }); + episodeList.push({ + nextEpisodeDate: `${yyyy}-${mm}-${dd}`, + }); + } } } @@ -593,9 +597,6 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => { let extraInfo: any; try { - /* Extra info of the anime */ - extraInfo = await animeExtraInfo(mal_id); - if (redisClient.connected) { const resultQueryRedis: any = await redisClient.get( `tioanimeInfo_${hashStringMd5(id!)}`, @@ -612,59 +613,64 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => { scrapy: true, parse: false, }); + + /* Extra info of the anime */ + extraInfo = (await animeExtraInfo(mal_id)) || undefined; } catch (err) { - return err; + console.log(err); } - let broadCastDate = new Date(); - let dd: number, mm: string | number, yyyy: number; + if (extraInfo) { + let broadCastDate = new Date(); + let dd: number, mm: string | number, yyyy: number; + + const airDay: any = { + Lunes: 1, + Martes: 2, + Miércoles: 3, + Jueves: 4, + Viernes: 5, + Sábados: 6, + Domingos: 7, + 'Sin emisión': 'default', + }; - const airDay: any = { - Lunes: 1, - Martes: 2, - Miércoles: 3, - Jueves: 4, - Viernes: 5, - Sábados: 6, - Domingos: 7, - 'Sin emisión': 'default', - }; + if (!extraInfo.aired.to) { + if (airDay.hasOwnProperty(extraInfo.broadcast)) { + if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { + for ( + let i = broadCastDate.getDay(); + i < airDay[extraInfo.broadcast]; + i++ + ) { + broadCastDate.setDate(broadCastDate.getDate() + 1); + } + } else { + let counter = broadCastDate.getDay() + 1; - if (!extraInfo.aired.to) { - if (airDay.hasOwnProperty(extraInfo.broadcast)) { - if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { - for ( - let i = broadCastDate.getDay(); - i < airDay[extraInfo.broadcast]; - i++ - ) { + /* Adding one because of the day */ broadCastDate.setDate(broadCastDate.getDate() + 1); - } - } else { - let counter = broadCastDate.getDay() + 1; - /* Adding one because of the day */ - broadCastDate.setDate(broadCastDate.getDate() + 1); - - while (counter !== airDay[extraInfo.broadcast]) { - if (counter === 7) { - counter = 0; + while (counter !== airDay[extraInfo.broadcast]) { + if (counter === 7) { + counter = 0; + } + broadCastDate.setDate(broadCastDate.getDate() + 1); + counter++; } - broadCastDate.setDate(broadCastDate.getDate() + 1); - counter++; } - } - dd = broadCastDate.getDate(); - mm = - broadCastDate.getMonth() + 1 < 10 - ? `0${broadCastDate.getMonth() + 1}` - : broadCastDate.getMonth() + 1; - yyyy = broadCastDate.getFullYear(); + dd = broadCastDate.getDate(); + mm = + broadCastDate.getMonth() + 1 < 10 + ? `0${broadCastDate.getMonth() + 1}` + : broadCastDate.getMonth() + 1; + yyyy = broadCastDate.getFullYear(); - episodesList.push({ - nextEpisodeDate: `${yyyy}-${mm}-${dd}`, - }); + episodesList.push({ + nextEpisodeDate: `${yyyy}-${mm}-${dd}`, + }); + } } }