😎 Refactoring the getAnimeServers

Adding the possibility to target another source, if one of them doesn't work, if any source doesn't work at all, just return undefined to the data options.
pull/49/head v4.1.0
capitanwesler 4 years ago
parent 2afd59cf7a
commit 0a60814065

@ -1,4 +1,4 @@
# **Aruppi API** (v4.0.9) # **Aruppi API** (v4.1.0)
> 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.9", "version": "4.1.0",
"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": {

@ -271,7 +271,6 @@ export default class AnimeController {
scrapy: true, scrapy: true,
parse: false, parse: false,
}); });
} catch (err) { } catch (err) {
return next(err); return next(err);
} }
@ -710,15 +709,36 @@ export default class AnimeController {
} }
} }
if ( let indicator = false;
id.split('/')[0] === 'ver' &&
id.split('-').indexOf('espanol') !== -1 if (id.split('/')[0] === 'ver' && !indicator) {
) {
data = await videoServersMonosChinos(id);
} else if (id.split('/')[0] === 'ver') {
data = await videoServersTioAnime(id); data = await videoServersTioAnime(id);
} else {
data = await videoServersJK(id); if (!data.name) {
indicator = true;
}
}
if (id.split('/')[0] === 'ver' && !indicator) {
data = await videoServersMonosChinos(id);
if (!data.name) {
console.log(data.name);
indicator = true;
}
}
if (!indicator) {
data = undefined;
indicator = true;
/*
This part is just for handling the error
if the two above doesn't complete the operation
does not make sense to have the getServers from
JKAnime.
*/
} }
if (data) { if (data) {

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

Loading…
Cancel
Save