diff --git a/src/controllers/getAnime.js b/src/controllers/getAnime.js index 346dff3..7db445e 100644 --- a/src/controllers/getAnime.js +++ b/src/controllers/getAnime.js @@ -10,39 +10,32 @@ export async function getAnime(req, res) { const { id } = req.params; const { data } = await axios.get(`${urls.anime}/${id}`); const html = parse(data); - const image = getAttr(html, '.Banner img', 'src'); + const urlMatch = /url\((.+)\)/gim; + const image = getAttr(html, '.heroarea', 'style') + .match(urlMatch)[0] + .replace(/url\(|\)/g, ''); res.status(200).json({ banner: image == noImage ? defaulImage : image || null, - image: getAttr(html, 'figure img.img-fluid', 'src') || null, + image: getAttr(html, '.chapterpic img', 'src') || null, title: html - .querySelector('h1.Title') + .querySelector('.chapterdetails h1') .text.replace(/Sub Español/gi, '') .trim() || null, - sinopsis: html.querySelector('.row .col-sm-9 .Description p').text || null, - status: html.querySelector('.row .col-sm-9 .Type').text.trim() || null, - date: html.querySelector('.after-title.mb-2').text.match(/\d+-\d+-\d+/)[0] || null, - type: - html.querySelector('.after-title.mb-2').text.match(/(\d+-\d+-\d+)\s?\|\s([A-Za-z]+)/)[2] || - null, - genders: html.querySelectorAll('.generos a').map((g) => g.text) || null, + sinopsis: html.querySelector('.chapterdetails p').text || null, + status: html.querySelector('.butns .btn1').text.trim() || null, + date: parseInt(html.querySelector('.butns .btn2').text.trim()) || null, + rating: html.querySelector('.chapterpic p').text || null, + genders: html.querySelectorAll('.breadcrumb .breadcrumb-item a').map((g) => g.text) || null, episodes: - html.querySelectorAll('.SerieCaps a').map((cap) => { + html.querySelectorAll('.row.jpage.row-cols-md-6 .col-item a').map((cap) => { const epId = cap.attributes['href'].replace(`${url}ver/`, ''); return { + image: getAttr(cap, '.animeimghv', 'src'), no: parseInt(epId.split('-').pop()), id: epId, }; }) || null, - sugestions: - html.querySelectorAll('.recom article').map((i) => { - return { - id: getAttr(i, 'a', 'href').replace(`${url}anime/`, ''), - image: getAttr(i, 'a .Image img', 'src'), - title: i.querySelector('a .Title').text, - year: parseInt(i.querySelector('.fecha').text), - }; - }) || null, }); } catch (error) { res.status(500).json({ diff --git a/src/controllers/getAnimes.js b/src/controllers/getAnimes.js index 97c2325..0b3ab31 100644 --- a/src/controllers/getAnimes.js +++ b/src/controllers/getAnimes.js @@ -7,15 +7,12 @@ export async function getAnimes(req, res) { let { page = '1' } = req.params; const { data } = await axios.get(`${urls.main}/animes?page=${page}`); const html = parse(data); - res.json( - html.querySelectorAll('.animes .container .row article').map((i) => { - const id = getAttr(i, 'a', 'href'); + res.status(200).json( + html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => { return { - id: id.split('/').pop() || null, - title: i.querySelector('.Title').text || null, - image: getAttr(i, '.Image img', 'src') || null, - type: i.querySelector('.category.text-uppercase').text || null, - year: parseInt(i.querySelector('.fecha').text) || null, + id: getAttr(i, 'a', 'href').split('/').pop() || null, + title: i.querySelector('.seristitles').text.trim() || null, + image: getAttr(i, '.animemainimg', 'src') || null, }; }) ); diff --git a/src/controllers/getEmision.js b/src/controllers/getEmision.js index 7874ae1..04f4c80 100644 --- a/src/controllers/getEmision.js +++ b/src/controllers/getEmision.js @@ -8,13 +8,11 @@ export async function getEmision(req, res) { const { data } = await axios.get(`${urls.emision}${page}`); const html = parse(data); res.status(200).json( - html.querySelectorAll('.animes .container .row article').map((i) => { + html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => { return { - id: getAttr(i, 'a', 'href').split('/').pop(), - title: i.querySelector('.Title').text.trim(), - image: getAttr(i, '.Image img', 'src'), - type: i.querySelector('.category').text.trim(), - year: parseInt(i.querySelector('.fecha').text), + id: getAttr(i, 'a', 'href').split('/').pop() || null, + title: i.querySelector('.seristitles').text.trim() || null, + image: getAttr(i, '.animemainimg', 'src') || null, }; }) ); diff --git a/src/controllers/getEpisode.js b/src/controllers/getEpisode.js index c871f5d..8f7f7b3 100644 --- a/src/controllers/getEpisode.js +++ b/src/controllers/getEpisode.js @@ -7,38 +7,54 @@ export async function getEpisode(req, res) { const { id } = req.params; const { data } = await axios.get(`${urls.episode}/${id}`); const html = parse(data); - const map = { - Anterior: true, - Siguiente: true, - }; - const videos = html.querySelectorAll('.TPlayer.mt-3.mb-3 .TPlayerTb').map((i) => { - const tag = parse(i.text); - return tag.querySelector('iframe')?.attributes['src']; + const ctrls = html.querySelectorAll('.controldiv2 a'); + let nav = {}; + let mapc = ctrls.map((e, i) => { + let elem = e.querySelector('img').classList; + return !elem.contains('playlist'); }); - const servers = html.querySelectorAll('#downloads table tbody tr').map((i) => { + if (mapc.length == 3) { + nav = { next: true, prev: true }; + } else { + if (mapc[1] == true) nav = { next: true, prev: false }; + if (mapc[1] == false) nav = { next: false, prev: true }; + } + const nextEpisodes = html.querySelectorAll('.nextplay:nth-child(1) .nextplays a').map((i) => { return { - name: getAttr(i, 'a', 'href').match(/\/\/(.+)\//)[1], - url: getAttr(i, 'a', 'href'), + image: getAttr(i, '.nxtmainimg', 'src'), + date: i.querySelector('.nxtplaybtn p').text, + title: i.querySelector('.nxtplaybtn h5').text, + no: i.querySelector('.nxtplaybtn span').text, }; }); - const ctrls = {}; - html.querySelectorAll('.d-flex.justify-content-center.mb-4 a').forEach((i) => { - const id = i.text.replace(/\s/g, ''); - let key; - id == 'Siguiente' ? (key = 'next') : id == 'Anterior' ? (key = 'prev') : 'menu'; - ctrls[key] = map[id]; - }); - delete ctrls['menu']; + const imgNotFound = + 'https://konachan.com/image/bbb46f65d3130526c20fcd781d6800cf/Konachan.com%20-%2041974%20fuura_kafuka%20itoshiki_nozomu%20sayonara_zetsubou_sensei%20white.png'; res.json({ - title: html.querySelector('.Title-epi').text, - no: parseInt(id.split('-').pop()) || 0, - animeId: getAttr(html, 'a.btnWeb.green.Current', 'href').replace( - 'https://monoschinos2.com/anime/', - '' - ), - videos: videos.filter((i) => i !== undefined), - servers, - ctrls, + title: html.querySelector('.heromain_h1').text.replace(/Sub\sEspañol/gi, ''), + nextEpisodes: nextEpisodes.length == 0 ? null : nextEpisodes, + ctrs: nav, + sugestions: html.querySelectorAll('.nextplay:nth-child(2) .nextplays a').map((i) => { + const image = getAttr(i, '.nxtmainimg', 'src'); + return { + image: image.length == 0 || !image ? imgNotFound : image, + date: i.querySelector('.nxtplaybtn p').text, + title: i.querySelector('.nxtplaybtn h5').text, + no: i.querySelector('.nxtplaybtn span').text, + }; + }), + videos: html.querySelectorAll('.dropdown-menu.dropcap #play-video').map((i) => { + const base64 = getAttr(i, 'a', 'data-player'); + return { + title: i.querySelector('a').text, + url: Buffer.from(base64, 'base64').toString('ascii'), + }; + }), + downloads: html.querySelectorAll('.downbtns a').map((i) => { + return { + title: i.text, + url: i.attrs['href'], + }; + }), }); } catch (err) { res.status(500).json({ diff --git a/src/controllers/getLastest.js b/src/controllers/getLastest.js index 2456936..1c23ba8 100644 --- a/src/controllers/getLastest.js +++ b/src/controllers/getLastest.js @@ -7,14 +7,14 @@ export async function getLastest(req, res) { const { data } = await axios.get(urls.main); const html = parse(data); res.json( - html.querySelectorAll('.row article').map((i) => { + html.querySelectorAll('.row.row-cols-5 .col.col-md-6.col-lg-2.col-6').map((i) => { const id = getAttr(i, 'a', 'href').split('/').pop(); return { id: id || null, - title: i.querySelector('.Title').text || null, - image: getAttr(i, '.Image img', 'src') || null, - type: i.querySelector('.Image figure span').text.trim() || null, - episode: parseInt(id.split('-').pop()) || null, + title: i.querySelector('.animetitles').text || null, + image: getAttr(i, '.animeimghv', 'src') || null, + type: i.querySelector('.positioning button').text.trim() || null, + episode: parseInt(i.querySelector('.positioning h5').text.trim()) || null, }; }) );