📋 replace get method in all files and remove axios from same files

master
carlos-burelo 3 years ago
parent 39dc81d9bd
commit bc64598d7d

@ -1,12 +1,10 @@
import { parse } from 'node-html-parser';
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
export async function getAnimes(req, res) {
try {
let { page = '1' } = req.params;
const { data } = await axios.get(`${api.all(page)}`);
const { data } = await get(`${api.all(page)}`);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {
@ -23,4 +21,3 @@ export async function getAnimes(req, res) {
});
}
}

@ -1,12 +1,11 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getAnime(req, res) {
try {
const url = 'https://monoschinos2.com/';
const { id } = req.params;
const { data } = await axios.get(api.anime(id));
const { data } = await get(api.anime(id));
const html = parse(data);
const date = html.querySelectorAll('.breadcrumb')[1].querySelector('.breadcrumb-item').text;
res.status(200).json({

@ -1,30 +1,26 @@
import { parse } from 'node-html-parser';
import { attr, api } from '../config.js';
import axios from 'axios';
import { attr, api, get } from '../config.js';
export async function getCalendar(req, res) {
try {
const { data } = await axios.get(api.calendar);
const { data } = await get(api.calendar);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain [data-dia]').map((i) => {
const day = i.getAttribute('data-dia');
return {
day,
animes: i
.querySelectorAll('.col-md-6.col-lg-4.col-sm-12.for768')
.map((i) => {
return {
id: attr(i, 'a', 'href').split('/').pop() || null,
title: i.querySelector('.serisdtls a h3').text.trim() || null,
image: attr(i, '.seriesimg a img') || null,
};
}),
animes: i.querySelectorAll('.col-md-6.col-lg-4.col-sm-12.for768').map((i) => {
return {
id: attr(i, 'a', 'href').split('/').pop() || null,
title: i.querySelector('.serisdtls a h3').text.trim() || null,
image: attr(i, '.seriesimg a img') || null,
};
}),
};
})
)
);
} catch (error) {
res.status(500).json({ message: error.message });
res.status(500).json({ message: error.message });
}
}

@ -1,11 +1,10 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getEmision(req, res) {
try {
let { page = '1' } = req.query;
const { data } = await axios.get(api.emision(page));
const { data } = await get(api.emision(page));
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {
@ -15,7 +14,7 @@ export async function getEmision(req, res) {
image: attr(i, '.animemainimg') || null,
};
})
)
);
} catch (error) {
res.status(500).json({ message: error.message });
}

@ -1,11 +1,10 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getEpisode(req, res) {
try {
const { id } = req.params;
const { data } = await axios.get(api.episode(id));
const { data } = await get(api.episode(id));
const html = parse(data);
const ctrls = html.querySelectorAll('.controldiv2 a');
let nav = {};
@ -63,4 +62,3 @@ export async function getEpisode(req, res) {
});
}
}

@ -1,6 +1,5 @@
import axios from 'axios';
import { parse } from 'node-html-parser';
import { api, attr } from '../config.js';
import { api, attr, get } from '../config.js';
export async function filterBy(req, res) {
try {
@ -11,7 +10,7 @@ export async function filterBy(req, res) {
letra = 'false',
pagina = '1',
} = req.query;
const { data } = await axios.get(`${api.filter({ categoria, fecha, genero, letra, pagina })}`);
const { data } = await get(`${api.filter({ categoria, fecha, genero, letra, pagina })}`);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {

@ -1,24 +1,21 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getLastest(req, res) {
try {
const { data } = await axios.get(api.home);
const { data } = await get(api.home);
const html = parse(data);
res.json(
html
.querySelectorAll('.row.row-cols-5 .col.col-md-6.col-lg-2.col-6')
.map((i) => {
const id = attr(i, 'a', 'href').split('/').pop();
return {
id: id || null,
title: i.querySelector('.animetitles')?.text || null,
image: attr(i, '.animeimghv') || null,
type: i.querySelector('.positioning button').text.trim() || null,
no: parseInt(i.querySelector('.positioning h5').text.trim() || '0') || null,
};
})
html.querySelectorAll('.row.row-cols-5 .col.col-md-6.col-lg-2.col-6').map((i) => {
const id = attr(i, 'a', 'href').split('/').pop();
return {
id: id || null,
title: i.querySelector('.animetitles')?.text || null,
image: attr(i, '.animeimghv') || null,
type: i.querySelector('.positioning button').text.trim() || null,
no: parseInt(i.querySelector('.positioning h5').text.trim() || '0') || null,
};
})
);
} catch (error) {
res.status(500).json({ message: error.message });

@ -1,12 +1,11 @@
import axios from 'axios';
import { parse } from 'node-html-parser';
import { api, attr } from '../config.js';
import { api, attr, get } from '../config.js';
export async function searchAnime(req, res) {
try {
let { id } = req.params;
let { page = '1' } = req.query;
const { data } = await axios.get(api.search(id, page));
const { data } = await get(api.search(id, page));
const html = parse(data);
res.json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {

Loading…
Cancel
Save