diff --git a/README.md b/README.md index 13c9e0c..1fb2e6d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# **Aruppi API** (v4.2.0) +# **Aruppi API** (v4.2.1) > This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture > diff --git a/package.json b/package.json index 4c9ebd0..72a7b13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aruppi", - "version": "4.2.0", + "version": "4.2.1", "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/controllers/AnimeController.ts b/src/controllers/AnimeController.ts index 7e7b76f..7d8724e 100644 --- a/src/controllers/AnimeController.ts +++ b/src/controllers/AnimeController.ts @@ -81,7 +81,7 @@ interface Movie { export default class AnimeController { async schedule(req: Request, res: Response, next: NextFunction) { const { day } = req.params; - let data: any; + let info: any; try { if (redisClient.connected) { @@ -96,7 +96,7 @@ export default class AnimeController { } } - data = await requestGot(`${urls.BASE_JIKAN}schedule/${day}`, { + info = await requestGot(`${urls.BASE_JIKAN}schedules?filter=${day}`, { parse: true, scrapy: false, }); @@ -104,10 +104,10 @@ export default class AnimeController { return next(err); } - const animeList: Schedule[] = data[day].map((item: Schedule) => ({ - title: item.title, + const animeList: Schedule[] = info.data.map((item: any) => ({ + title: item.titles.find((x: { type: string; }) => x.type === "Default").title, malid: item.mal_id, - image: item.image_url, + image: item.images.jpg.image_url, })); if (animeList.length > 0) { @@ -137,7 +137,7 @@ export default class AnimeController { async top(req: Request, res: Response, next: NextFunction) { const { type, subtype, page } = req.params; - let data: any; + let info: any; try { if (redisClient.connected) { @@ -161,12 +161,12 @@ export default class AnimeController { } if (subtype !== undefined) { - data = await requestGot( - `${urls.BASE_JIKAN}top/${type}/${page}/${subtype}`, + info = await requestGot( + `${urls.BASE_JIKAN}top/${type}?filter=${subtype}&page=${page}`, { parse: true, scrapy: false }, ); } else { - data = await requestGot(`${urls.BASE_JIKAN}top/${type}/${page}`, { + info = await requestGot(`${urls.BASE_JIKAN}top/${type}?page=${page}`, { parse: true, scrapy: false, }); @@ -175,11 +175,12 @@ export default class AnimeController { return next(err); } - const top: Top[] = data.top.map((item: Top) => ({ - rank: item.rank, - title: item.title, + const top: Top[] = info.data.map((item: any, index: number) => ({ + // A little hacky way to fix null ranks + rank: item.rank || index + 1 + (info.pagination.current_page-1)*info.pagination.items.per_page, + title: item.titles.find((x: { type: string; }) => x.type === "Default").title, url: item.url, - image_url: item.image_url, + image_url: item.images.jpg.image_url, type: type, subtype: subtype, page: page, diff --git a/src/controllers/DirectoryController.ts b/src/controllers/DirectoryController.ts index df0ef8d..f09210c 100644 --- a/src/controllers/DirectoryController.ts +++ b/src/controllers/DirectoryController.ts @@ -104,7 +104,7 @@ export default class DirectoryController { async getSeason(req: Request, res: Response, next: NextFunction) { const { year, type } = req.params; - let data: any; + let info: any; try { if (redisClient.connected) { @@ -119,7 +119,7 @@ export default class DirectoryController { } } - data = await requestGot(`${urls.BASE_JIKAN}season/${year}/${type}`, { + info = await requestGot(`${urls.BASE_JIKAN}seasons/${year}/${type}`, { scrapy: false, parse: true, }); @@ -127,10 +127,10 @@ export default class DirectoryController { return next(err); } - const season: TypeAnime[] = data.anime.map((item: any) => { + const season: TypeAnime[] = info.data.map((item: any) => { return { - title: item.title, - image: item.image_url, + title: item.titles.find((x: { type: string; }) => x.type === "Default").title, + image: item.images.jpg.image_url, genres: item.genres.map((genre: any) => genre.name), }; }); @@ -161,7 +161,7 @@ export default class DirectoryController { } async allSeasons(req: Request, res: Response, next: NextFunction) { - let data: any; + let info: any; try { if (redisClient.connected) { @@ -176,7 +176,7 @@ export default class DirectoryController { } } - data = await requestGot(`${urls.BASE_JIKAN}season/archive`, { + info = await requestGot(`${urls.BASE_JIKAN}seasons`, { parse: true, scrapy: false, }); @@ -184,7 +184,7 @@ export default class DirectoryController { return next(err); } - const archive: Archive[] = data.archive.map((item: any) => { + const archive: Archive[] = info.data.map((item: any) => { return { year: item.year, seasons: item.seasons, @@ -215,7 +215,7 @@ export default class DirectoryController { } async laterSeasons(req: Request, res: Response, next: NextFunction) { - let data: any; + let info: any; try { if (redisClient.connected) { @@ -230,7 +230,7 @@ export default class DirectoryController { } } - data = await requestGot(`${urls.BASE_JIKAN}season/later`, { + info = await requestGot(`${urls.BASE_JIKAN}seasons/upcoming`, { parse: true, scrapy: false, }); @@ -238,10 +238,10 @@ export default class DirectoryController { return next(err); } - const future: Season[] = data.anime.map((item: any) => { + const future: Season[] = info.data.map((item: any) => { return { - title: item.title, - image: item.image_url, + title: item.titles.find((x: { type: string; }) => x.type === "Default").title, + image: item.images.jpg.image_url, malink: item.url, }; }); @@ -294,6 +294,7 @@ export default class DirectoryController { const extraInfo: any = await animeExtraInfo(resultQuery!.mal_id); resultAnime = { + //aruppi_key: hashStringMd5(title), title: resultQuery?.title, poster: resultQuery?.poster, synopsis: resultQuery?.description, diff --git a/src/routes.ts b/src/routes.ts index a8007ba..a32361b 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.1.8', + version: '4.2.1', credits: 'The bitch loves /apis that offers data to Aruppi App', entries: [ { diff --git a/src/utils/urls.ts b/src/utils/urls.ts index a439e26..5b935d0 100644 --- a/src/utils/urls.ts +++ b/src/utils/urls.ts @@ -7,7 +7,7 @@ export default { BASE_ANIMEFLV_JELU: 'https://aruppi.jeluchu.xyz/apis/animeflv/v1/', BASE_YOUTUBE: 'https://aruppi.jeluchu.xyz/api/Youtube/?channelId=', BASE_YOUTUBE_PLAYLIST: 'https://aruppi.jeluchu.xyz/api/Youtube/playlist/?playlistId=', - BASE_JIKAN: 'https://aruppi.jeluchu.xyz/apis/jikan/v3/', + BASE_JIKAN: 'https://aruppi.jeluchu.xyz/apis/jikan/v4/', BASE_IVOOX: 'https://www.ivoox.com/podcast-anitakume_fg_f1660716_filtro_1.xml', BASE_KUDASAI: 'https://somoskudasai.com/feed/', BASE_RAMENPARADOS: 'https://ramenparados.com/category/noticias/anime/feed/', diff --git a/src/utils/util.ts b/src/utils/util.ts index da74cd6..8266606 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -34,7 +34,7 @@ interface RelatedAnime { } export const animeExtraInfo = async (mal_id: number) => { - let data: any; + let info: any; let broadcast: any; const airDay: any = { @@ -68,40 +68,40 @@ export const animeExtraInfo = async (mal_id: number) => { } } - data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}`, { + info = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}`, { parse: true, scrapy: false, }); - if (data.broadcast) { - broadcast = data.broadcast.split('at')[0].trim().toLowerCase() || null; + if (info.data.airing) { + broadcast = info.data.broadcast.string.split('at')[0].trim().toLowerCase() || null; } } catch (err) { return err; } if (airDay.hasOwnProperty(broadcast)) { - data.broadcast = airDay[broadcast]; + info.data.broadcast = airDay[broadcast]; } else { - data.broadcast = null; + info.data.broadcast = null; } const formattedObject: any = { - titleJapanese: data.title_japanese, - source: data.source, - totalEpisodes: data.episodes, + titleJapanese: info.data.titles.find((x: { type: string; }) => x.type === "Default").title, + source: info.data.source, + totalEpisodes: info.data.episodes, aired: { - from: data.aired.from, - to: data.aired.to, + from: info.data.aired.from, + to: info.data.aired.to, }, - duration: data.duration.split('per')[0], - rank: data.rank, - broadcast: data.broadcast, - producers: data.producers.map((item: any) => item.name) || null, - licensors: data.licensors.map((item: any) => item.name) || null, - studios: data.studios.map((item: any) => item.name) || null, - openingThemes: data.opening_themes || null, - endingThemes: data.ending_themes || null, + duration: info.data.duration.split('per')[0], + rank: info.data.rank, + broadcast: info.data.broadcast, + producers: info.data.producers.map((item: any) => item.name) || null, + licensors: info.data.licensors.map((item: any) => item.name) || null, + studios: info.data.studios.map((item: any) => item.name) || null, + openingThemes: info.data.opening_themes || null, + endingThemes: info.data.ending_themes || null, }; if (formattedObject) { @@ -128,7 +128,7 @@ export const animeExtraInfo = async (mal_id: number) => { }; export const getAnimeVideoPromo = async (mal_id: number) => { - let data: any; + let info: any; try { if (redisClient.connected) { @@ -143,7 +143,7 @@ export const getAnimeVideoPromo = async (mal_id: number) => { } } - data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}/videos`, { + info = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}/videos`, { parse: true, scrapy: false, }); @@ -151,11 +151,11 @@ export const getAnimeVideoPromo = async (mal_id: number) => { return err; } - const promo: Promo[] = data.promo.map((item: Promo) => { + const promo: Promo[] = info.data.promo.map((item: any) => { return { title: item.title, - previewImage: item.image_url, - videoURL: item.video_url, + previewImage: item.trailer.images.image_url, + videoURL: item.trailer.url, }; }); @@ -183,7 +183,7 @@ export const getAnimeVideoPromo = async (mal_id: number) => { }; export const getAnimeCharacters = async (mal_id: number) => { - let data: any; + let info: any; try { if (redisClient.connected) { @@ -198,19 +198,19 @@ export const getAnimeCharacters = async (mal_id: number) => { } } - data = await requestGot( - `${urls.BASE_JIKAN}anime/${mal_id}/characters_staff`, + info = await requestGot( + `${urls.BASE_JIKAN}anime/${mal_id}/characters`, {parse: true, scrapy: false}, ); } catch (err) { return err; } - const characters: Character[] = data.characters.map((item: any) => { + const characters: Character[] = info.data.map((item: any) => { return { - id: item.mal_id, - name: item.name, - image: item.image_url, + id: item.character.mal_id, + name: item.character.name, + image: item.character.images.jpg.image_url, role: item.role, }; });