Compare commits

...

16 Commits
v4.1.8 ... v4

Author SHA1 Message Date
Darkangeel_hd 6c44d5a712 Fixed getImages urls
No more "https:https://"
Will this work tomorrow, i don't know
2 years ago
Darkangeel_hd cef7574083 Minor updates
Changed PromoVideos redis keyname, using mal_id now
Changed schedule key TTL from 2 to 6 hours
2 years ago
Darkangeel_hd 7c6307cb1e Expire getRelatedMAL_* faster
TTL set to 1h
Also, forgot to mention on last commit that we changed the key name to a more friendly one, using the mal_id now.
As the relation between mal_id and its content is 1:1 collisions are not possible
That way is easier to identify on the db
2 years ago
Darkangeel_hd 58ac761098 Reimplemented getRelatedAnimesMAL
Reimplemented getRelatedAnimesMAL using jikan v4 and aruppi DB
what a pain in the ass was this one...
2 years ago
Darkangeel_hd 3a633b2ff2 Migrating to jikan v4
moved v3 endpoints to jikan v4
Quick fixes, will review later (as in between a day and 2 years later UwU)
2 years ago
dependabot[bot] e39bb486b0 Bump http-cache-semantics from 4.1.0 to 4.1.1
Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] 189a5bfb79 Bump mongoose from 5.13.13 to 5.13.15
Bumps [mongoose](https://github.com/Automattic/mongoose) from 5.13.13 to 5.13.15.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/mongoose/compare/5.13.13...5.13.15)

---
updated-dependencies:
- dependency-name: mongoose
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] df30fd785e Bump json5 from 1.0.1 to 1.0.2
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] 656d4ce1ba Bump express from 4.17.1 to 4.17.3
Bumps [express](https://github.com/expressjs/express) from 4.17.1 to 4.17.3.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.17.3)

---
updated-dependencies:
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] a90e522c21 Bump minimatch from 3.0.4 to 3.1.2
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Darkangeel_hd faf0afee8c Updated utils/requestCall
Added new options to spoof user agent
New Aruppi APi user agent
Adapt relevant code to new funcionality

fixed line break on urls.ts
3 years ago
Darkangeel_hd 736ff79707 Update qwant api url 3 years ago
dependabot[bot] 2b4e3d0d7d
Bump minimist from 1.2.5 to 1.2.6 (#58)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
Jesús María fdb744582f
Merge pull request #57 from aruppi/dependabot/npm_and_yarn/got-11.8.5
Bump got from 11.8.3 to 11.8.5
3 years ago
dependabot[bot] c3fa6cd854
Bump got from 11.8.3 to 11.8.5
Bumps [got](https://github.com/sindresorhus/got) from 11.8.3 to 11.8.5.
- [Release notes](https://github.com/sindresorhus/got/releases)
- [Commits](https://github.com/sindresorhus/got/compare/v11.8.3...v11.8.5)

---
updated-dependencies:
- dependency-name: got
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Angel 868a958e36
Update README.md
Fixed Akiyama logo
Updated copyright year
3 years ago

@ -1,4 +1,4 @@
# **Aruppi API** (v4.1.8)
# **Aruppi API** (v4.2.2)
> This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture
>
@ -116,7 +116,7 @@ Currently the Aruppi app on Android is already using the v4.x.x API services fro
</td>
<td align="center">
<a href="https://github.com/Fmaldonado6/Akiyama">
<img src="https://raw.githubusercontent.com/Fmaldonado6/Akiyama/master/images/logo/web-logo.png" width="75px;" alt="Jeluchu"/><br />
<img src="https://raw.githubusercontent.com/Fmaldonado6/Akiyama/master/images/logo/logo.png" width="75px;" alt="Jeluchu"/><br />
<sub>
<b>Akiyama</b>
</sub>
@ -156,4 +156,4 @@ There are also **people who have made contributions** and therefore it is also i
- [Jéluchu](https://github.com/Jeluchu) (Multiplatform Developer, designer, and others)
- [Capitanwesler](https://github.com/capitanwesler) (Backend developer, web developer and others)
Copyright © 2021 [Jéluchu](https://about.jeluchu.com/).
Copyright © 2022 [Jéluchu](https://about.jeluchu.com/).

@ -1,6 +1,6 @@
{
"name": "aruppi",
"version": "4.1.8",
"version": "4.2.2",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.ts",
"scripts": {
@ -54,11 +54,11 @@
"compose-middleware": "^5.0.1",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"got": "^11.8.2",
"express": "^4.17.3",
"got": "^11.8.5",
"helmet": "^4.5.0",
"mongodb": "^3.6.6",
"mongoose": "^5.12.5",
"mongoose": "^5.13.15",
"redis": "^3.1.2",
"rss-parser": "^3.12.0",
"tough-cookie": "^4.0.0",

@ -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) {
@ -119,11 +119,11 @@ export default class AnimeController {
JSON.stringify({ day: animeList }),
);
/* After 24hrs expire the key. */
/* After 6hrs expire the key. */
redisClient.expireat(
redisClient.expire(
`schedule_${hashStringMd5(day)}`,
parseInt(`${+new Date() / 1000}`, 10) + 7200,
+ 21600,
);
}
@ -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,
@ -229,6 +230,7 @@ export default class AnimeController {
data = await requestGot(`${urls.BASE_ANIMEFLV}api/animes/list`, {
parse: true,
scrapy: false,
spoof: true,
});
} catch (err) {
return next(err);

@ -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,

@ -234,7 +234,7 @@ export default class UtilsController {
`${urls.BASE_QWANT}t=images&q=${encodeURIComponent(
title,
)}&count=51&locale=es_ES&safesearch=1`,
{ scrapy: false, parse: true },
{ scrapy: false, parse: true, spoof: true, },
);
} catch (err) {
return next(err);
@ -243,8 +243,8 @@ export default class UtilsController {
const results: any[] = data.data.result.items.map((item: any) => {
return {
type: item.thumb_type,
thumbnail: `https:${item.thumbnail}`,
fullsize: `https:${item.media_fullsize}`,
thumbnail: `${item.thumbnail}`,
fullsize: `${item.media_fullsize}`,
};
});
@ -637,6 +637,7 @@ export default class UtilsController {
data = await requestGot(`${urls.BASE_THEMEMOE}roulette`, {
parse: true,
scrapy: false,
spoof: true,
});
} catch (err) {
return next(err);

@ -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.2',
credits: 'The bitch loves /apis that offers data to Aruppi App',
entries: [
{

@ -285,6 +285,7 @@ async function redditocall(href: string) {
const resp = await requestGot(urls.REDDIT_ANIMETHEMES + href + '.json', {
parse: true,
scrapy: false,
spoof: true,
});
return cheerio.load(getHTML(resp.data.content_html));

@ -1,28 +1,52 @@
import got from 'got';
import cheerio from 'cheerio';
import { CookieJar } from 'tough-cookie';
// @ts-ignore
import * as got_pjson from 'got/package.json'
const pjson = require('../../package.json');
const cookieJar = new CookieJar();
const aruppi_options: any = {
cookieJar,
'headers': {
'user-agent': `Aruppi-API/${pjson.version} ${got_pjson.name}/${got_pjson.version}`,
'x-client': 'aruppi-api'
},
};
interface Options {
scrapy: boolean;
parse: boolean;
scrapy?: boolean,
parse?: boolean,
spoof?: boolean
}
export const requestGot = async (
url: string,
options?: Options,
url: string,
options?: Options,
): Promise<any> => {
if (options !== undefined) {
if (options.scrapy) {
const response = await got(url, { cookieJar });
return await cheerio.load(response.body);
}
const got_options: any = {...got.defaults.options, ...aruppi_options}
if (options) {
if (options.spoof != null) {
got_options.headers["user-agent"] = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/69.0";
delete got_options.headers['x-client'];
if (!options.spoof)
got_options.headers['user-agent'] = got.defaults.options.headers['user-agent'];
} else if (process.env.ALPI_KEY && (new URL(url)).hostname.match(/\.jeluchu\.xyz$/)) {
got_options.headers['x-aruppi-key'] = process.env.ALPI_KEY;
}
if (options.scrapy) {
const response = await got(url, got_options);
return cheerio.load(response.body);
}
if (options.parse) {
return await got(url, { cookieJar }).json();
if (options.parse) {
got_options.responseType = 'json';
const response = await got(url, got_options);
return response.body;
}
}
} else {
return await got.get(url, { cookieJar });
}
const response = await got.get(url, got_options);
return response;
};

@ -7,9 +7,8 @@ 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_IVOOX:
'https://www.ivoox.com/podcast-anitakume_fg_f1660716_filtro_1.xml',
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/',
BASE_CRUNCHYROLL: 'https://www.crunchyroll.com/newsrss?lang=esES',
@ -17,7 +16,7 @@ export default {
ANIMEFLV_SEARCH: 'https://animeflv.net/browse?',
SEARCH_DIRECTORY: 'https://animeflv.net/browse?order=title&page=',
BASE_EPISODE_IMG_URL: 'https://cdn.animeflv.net/screenshots/',
BASE_QWANT: 'https://api.qwant.com/search/images?',
BASE_QWANT: 'https://api.qwant.com/v3/search/images?',
REDDIT_ANIMETHEMES: 'https://reddit.com/r/AnimeThemes/wiki/',
BASE_THEMEMOE: 'https://themes.moe/api/',
BASE_ARUPPI_MONOSCHINOS: 'https://aruppi.jeluchu.xyz/apis/monoschinos/',

@ -4,6 +4,7 @@ import AnimeModel, {Anime} from '../database/models/anime.model';
import crypto from 'crypto';
import util from 'util';
import {redisClient} from '../database/connection';
import { stderr } from 'process';
// @ts-ignore
redisClient.get = util.promisify(redisClient.get);
@ -34,7 +35,7 @@ interface RelatedAnime {
}
export const animeExtraInfo = async (mal_id: number) => {
let data: any;
let info: any;
let broadcast: any;
const airDay: any = {
@ -68,40 +69,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,12 +129,12 @@ export const animeExtraInfo = async (mal_id: number) => {
};
export const getAnimeVideoPromo = async (mal_id: number) => {
let data: any;
let info: any;
try {
if (redisClient.connected) {
const resultQueryRedis: any = await redisClient.get(
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
`getMALpromoInfo_${mal_id}`,
);
if (resultQueryRedis) {
@ -143,7 +144,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 +152,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,
};
});
@ -164,15 +165,15 @@ export const getAnimeVideoPromo = async (mal_id: number) => {
/* Set the key in the redis cache. */
redisClient.set(
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
`getMALpromoInfo_${mal_id}`,
JSON.stringify(promo),
);
/* After 24hrs expire the key. */
/* After 2hrs expire the key. */
redisClient.expireat(
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
parseInt(`${+new Date() / 1000}`, 10) + 7200,
redisClient.expire(
`getMALpromoInfo_${mal_id}`,
7200,
);
}
@ -183,7 +184,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 +199,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,
};
});
@ -262,12 +263,12 @@ const getPosterAndType = async (
};
export const getRelatedAnimesMAL = async (mal_id: number) => {
let $: cheerio.Root;
let info: any;
try {
if (redisClient.connected) {
const resultQueryRedis: any = await redisClient.get(
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
`getRelatedMAL_${mal_id}`,
);
if (resultQueryRedis) {
@ -277,65 +278,52 @@ export const getRelatedAnimesMAL = async (mal_id: number) => {
}
}
$ = await requestGot(`https://myanimelist.net/anime/${mal_id}`, {
parse: false,
scrapy: true,
info = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}/relations`, {
parse: true,
scrapy: false,
});
} catch (err) {
stderr.write(`Error on getRelatedAnimesMAL http on mal_id: ${mal_id}\n`)
return err;
}
let listRelated: any = {};
let relatedAnimes: RelatedAnime[] = [];
if ($('table.anime_detail_related_anime').length > 0) {
$('table.anime_detail_related_anime')
.find('tbody tr')
.each((index: number, element: any) => {
if ($(element).find('td').eq(0).text() !== 'Adaptation:') {
listRelated[$(element).find('td').eq(1).text()] = $(element)
.find('td')
.children('a')
.attr('href');
}
const relatedAnimes = []
for (const relation_entry of info.data) {
for (const entry of relation_entry.entry){
if (entry.type != "anime")
break;
const queryRes: Anime | null = await AnimeModel.findOne({
mal_id: {$eq: entry.mal_id}
});
for (const related in listRelated) {
let posterUrl: any = await getPosterAndType(
undefined,
listRelated[related].split('/')[2],
);
if (posterUrl !== '') {
relatedAnimes.push({
title: related,
type: posterUrl[1],
poster: posterUrl[0],
});
}
if (queryRes == null)
break
relatedAnimes.push({
title: queryRes!.title,
type: queryRes?.type,
poster: queryRes?.poster
})
}
}
if (relatedAnimes.length > 0) {
if (redisClient.connected) {
/* Set the key in the redis cache. */
redisClient.set(
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
JSON.stringify(relatedAnimes),
);
if (relatedAnimes.length > 0) {
if (redisClient.connected) {
/* Set the key in the redis cache. */
/* After 24hrs expire the key. */
redisClient.set(
`getRelatedMAL_${mal_id}`,
JSON.stringify(relatedAnimes),
);
redisClient.expireat(
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
parseInt(`${+new Date() / 1000}`, 10) + 7200,
);
}
/* After 1hr expire the key. */
return relatedAnimes;
redisClient.expire(
`getRelatedMAL_${mal_id}`,
3600,
);
}
} else {
return [];
return relatedAnimes;
}
};
@ -606,6 +594,7 @@ export const tioanimeInfo = async (id: string | undefined, mal_id: number) => {
$ = await requestGot(`${urls.BASE_TIOANIME}anime/${id}`, {
scrapy: true,
parse: false,
spoof: true,
});
/* Extra info of the anime */
@ -785,6 +774,7 @@ export const videoServersTioAnime = async (id: string) => {
$ = await requestGot(`${urls.BASE_TIOANIME}${id}`, {
scrapy: true,
parse: false,
spoof: true,
});
} catch (err) {
return err;
@ -941,7 +931,7 @@ async function desuServerUrl(url: string) {
}
}
$ = await requestGot(url, {scrapy: true, parse: false});
$ = await requestGot(url, {scrapy: true, parse: false, spoof: true});
} catch (err) {
return err;
}
@ -1033,7 +1023,7 @@ export function getThemes(themes: any[]) {
}
export const imageUrlToBase64 = async (url: string) => {
let img: any = await requestGot(url);
let img: any = await requestGot(url,{spoof:false});
return img.rawBody.toString('base64');
};

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save