|
|
@ -56,22 +56,24 @@ export const animeExtraInfo = async (mal_id: number) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}`, {
|
|
|
|
|
|
|
|
parse: true,
|
|
|
|
|
|
|
|
scrapy: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
broadcast = data.broadcast.split('at')[0].trim().toLowerCase() || null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}`, {
|
|
|
|
|
|
|
|
parse: true,
|
|
|
|
|
|
|
|
scrapy: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
broadcast = data.broadcast.split('at')[0].trim().toLowerCase() || null;
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,19 +103,21 @@ export const animeExtraInfo = async (mal_id: number) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (formattedObject) {
|
|
|
|
if (formattedObject) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
JSON.stringify(formattedObject),
|
|
|
|
JSON.stringify(formattedObject),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`extraInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return formattedObject;
|
|
|
|
return formattedObject;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -125,20 +129,22 @@ export const getAnimeVideoPromo = async (mal_id: number) => {
|
|
|
|
let data: any;
|
|
|
|
let data: any;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}/videos`, {
|
|
|
|
|
|
|
|
parse: true,
|
|
|
|
|
|
|
|
scrapy: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = await requestGot(`${urls.BASE_JIKAN}anime/${mal_id}/videos`, {
|
|
|
|
|
|
|
|
parse: true,
|
|
|
|
|
|
|
|
scrapy: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,19 +158,21 @@ export const getAnimeVideoPromo = async (mal_id: number) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (promo.length > 0) {
|
|
|
|
if (promo.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
JSON.stringify(promo),
|
|
|
|
JSON.stringify(promo),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`promoInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return promo;
|
|
|
|
return promo;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -176,20 +184,22 @@ export const getAnimeCharacters = async (mal_id: number) => {
|
|
|
|
let data: any;
|
|
|
|
let data: any;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
data = await requestGot(
|
|
|
|
|
|
|
|
`${urls.BASE_JIKAN}anime/${mal_id}/characters_staff`,
|
|
|
|
|
|
|
|
{ parse: true, scrapy: false },
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = await requestGot(
|
|
|
|
|
|
|
|
`${urls.BASE_JIKAN}anime/${mal_id}/characters_staff`,
|
|
|
|
|
|
|
|
{ parse: true, scrapy: false },
|
|
|
|
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -204,19 +214,21 @@ export const getAnimeCharacters = async (mal_id: number) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (characters.length > 0) {
|
|
|
|
if (characters.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
JSON.stringify(characters),
|
|
|
|
JSON.stringify(characters),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`charactersInfo_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return characters;
|
|
|
|
return characters;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -251,20 +263,22 @@ export const getRelatedAnimesFLV = async (id: string) => {
|
|
|
|
let $: cheerio.Root;
|
|
|
|
let $: cheerio.Root;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_ANIMEFLV}/anime/${id}`, {
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_ANIMEFLV}/anime/${id}`, {
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -292,19 +306,21 @@ export const getRelatedAnimesFLV = async (id: string) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (relatedAnimes.length > 0) {
|
|
|
|
if (relatedAnimes.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
JSON.stringify(relatedAnimes),
|
|
|
|
JSON.stringify(relatedAnimes),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
`relatedFLV_${hashStringMd5(id)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return relatedAnimes;
|
|
|
|
return relatedAnimes;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -316,20 +332,22 @@ export const getRelatedAnimesMAL = async (mal_id: number) => {
|
|
|
|
let $: cheerio.Root;
|
|
|
|
let $: cheerio.Root;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`https://myanimelist.net/anime/${mal_id}`, {
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`https://myanimelist.net/anime/${mal_id}`, {
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -365,19 +383,21 @@ export const getRelatedAnimesMAL = async (mal_id: number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (relatedAnimes.length > 0) {
|
|
|
|
if (relatedAnimes.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
JSON.stringify(relatedAnimes),
|
|
|
|
JSON.stringify(relatedAnimes),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
`getRelatedMAL_${hashStringMd5(`${mal_id}`)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return relatedAnimes;
|
|
|
|
return relatedAnimes;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -394,20 +414,22 @@ export const animeFlvInfo = async (id: string | undefined) => {
|
|
|
|
let episodes: any[] = [];
|
|
|
|
let episodes: any[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_ANIMEFLV}/anime/${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_ANIMEFLV}/anime/${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -442,19 +464,21 @@ export const animeFlvInfo = async (id: string | undefined) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (episodes.length > 0) {
|
|
|
|
if (episodes.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
JSON.stringify(episodes),
|
|
|
|
JSON.stringify(episodes),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
`animeflvInfo_${hashStringMd5(id!)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return episodes;
|
|
|
|
return episodes;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -470,20 +494,22 @@ export const jkanimeInfo = async (id: string | undefined) => {
|
|
|
|
let countEpisodes: string[] = [];
|
|
|
|
let countEpisodes: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_JKANIME}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_JKANIME}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -510,19 +536,21 @@ export const jkanimeInfo = async (id: string | undefined) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (episodesList.length > 0) {
|
|
|
|
if (episodesList.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
JSON.stringify(episodesList),
|
|
|
|
JSON.stringify(episodesList),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
`jkanimeInfo_${hashStringMd5(id!)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return episodesList;
|
|
|
|
return episodesList;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -530,29 +558,90 @@ export const jkanimeInfo = async (id: string | undefined) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const monoschinosInfo = async (id: string | undefined) => {
|
|
|
|
export const monoschinosInfo = async (
|
|
|
|
|
|
|
|
id: string | undefined,
|
|
|
|
|
|
|
|
mal_id: number,
|
|
|
|
|
|
|
|
) => {
|
|
|
|
let $: cheerio.Root;
|
|
|
|
let $: cheerio.Root;
|
|
|
|
let episodeList: any[] = [];
|
|
|
|
let episodeList: any[] = [];
|
|
|
|
|
|
|
|
let extraInfo: any;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
/* Extra info of the anime */
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
extraInfo = await animeExtraInfo(mal_id);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_MONOSCHINOS}anime/${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_MONOSCHINOS}anime/${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Adding one because of the day */
|
|
|
|
|
|
|
|
broadCastDate.setDate(broadCastDate.getDate() + 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (counter !== airDay[extraInfo.broadcast]) {
|
|
|
|
|
|
|
|
if (counter === 7) {
|
|
|
|
|
|
|
|
counter = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
broadCastDate.setDate(broadCastDate.getDate() + 1);
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dd = broadCastDate.getDate();
|
|
|
|
|
|
|
|
mm =
|
|
|
|
|
|
|
|
broadCastDate.getMonth() + 1 < 10
|
|
|
|
|
|
|
|
? `0${broadCastDate.getMonth() + 1}`
|
|
|
|
|
|
|
|
: broadCastDate.getMonth() + 1;
|
|
|
|
|
|
|
|
yyyy = broadCastDate.getFullYear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
episodeList.push({
|
|
|
|
|
|
|
|
nextEpisodeDate: `${yyyy}-${mm}-${dd}`,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('.SerieCaps a').each((index: number, element: cheerio.Element) => {
|
|
|
|
$('.SerieCaps a').each((index: number, element: cheerio.Element) => {
|
|
|
|
let episode: number;
|
|
|
|
let episode: number;
|
|
|
|
|
|
|
|
|
|
|
@ -574,19 +663,21 @@ export const monoschinosInfo = async (id: string | undefined) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (episodeList.length > 0) {
|
|
|
|
if (episodeList.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
JSON.stringify(episodeList),
|
|
|
|
JSON.stringify(episodeList),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
`monoschinosInfo_${hashStringMd5(id!)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return episodeList;
|
|
|
|
return episodeList;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -599,20 +690,22 @@ export const videoServersMonosChinos = async (id: string) => {
|
|
|
|
let videoServers: any[] = [];
|
|
|
|
let videoServers: any[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_MONOSCHINOS}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_MONOSCHINOS}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -656,19 +749,21 @@ export const videoServersMonosChinos = async (id: string) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (videoServers.length > 0) {
|
|
|
|
if (videoServers.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
JSON.stringify(videoServers),
|
|
|
|
JSON.stringify(videoServers),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
`videoServersMonosChinos_${hashStringMd5(id)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return videoServers;
|
|
|
|
return videoServers;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -682,20 +777,22 @@ export const videoServersJK = async (id: string) => {
|
|
|
|
let script: string | null = '';
|
|
|
|
let script: string | null = '';
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`videoServersJK_${hashStringMd5(id)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`videoServersJK_${hashStringMd5(id)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(`${urls.BASE_JKANIME}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(`${urls.BASE_JKANIME}${id}`, {
|
|
|
|
|
|
|
|
scrapy: true,
|
|
|
|
|
|
|
|
parse: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -748,19 +845,21 @@ export const videoServersJK = async (id: string) => {
|
|
|
|
serverList = serverList.filter(x => x.id !== 'xtreme s' && x.id !== 'desuka');
|
|
|
|
serverList = serverList.filter(x => x.id !== 'xtreme s' && x.id !== 'desuka');
|
|
|
|
|
|
|
|
|
|
|
|
if (serverList.length > 0) {
|
|
|
|
if (serverList.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`videoServersJK_${hashStringMd5(id!)}`,
|
|
|
|
`videoServersJK_${hashStringMd5(id!)}`,
|
|
|
|
JSON.stringify(serverList),
|
|
|
|
JSON.stringify(serverList),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`videoServersJK_${hashStringMd5(id!)}`,
|
|
|
|
`videoServersJK_${hashStringMd5(id!)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return serverList;
|
|
|
|
return serverList;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -772,17 +871,19 @@ async function desuServerUrl(url: string) {
|
|
|
|
let $: cheerio.Root;
|
|
|
|
let $: cheerio.Root;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
if (redisClient.connected) {
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
const resultQueryRedis: any = await redisClient.get(
|
|
|
|
);
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
if (resultQueryRedis) {
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
const resultRedis: any = JSON.parse(resultQueryRedis);
|
|
|
|
|
|
|
|
|
|
|
|
return resultRedis;
|
|
|
|
return resultRedis;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ = await requestGot(url, { scrapy: true, parse: false });
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ = await requestGot(url, { scrapy: true, parse: false });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -805,19 +906,21 @@ async function desuServerUrl(url: string) {
|
|
|
|
.split("'")[1];
|
|
|
|
.split("'")[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (result.length > 0) {
|
|
|
|
if (result.length > 0) {
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
if (redisClient.connected) {
|
|
|
|
|
|
|
|
/* Set the key in the redis cache. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.set(
|
|
|
|
redisClient.set(
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
JSON.stringify(result),
|
|
|
|
JSON.stringify(result),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
/* After 24hrs expire the key. */
|
|
|
|
|
|
|
|
|
|
|
|
redisClient.expireat(
|
|
|
|
redisClient.expireat(
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
`desuServerUrl_${hashStringMd5(url)}`,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
parseInt(`${+new Date() / 1000}`, 10) + 7200,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|