mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-21 02:42:03 +00:00
improve baixa title parsing
This commit is contained in:
parent
ccecf68ecb
commit
807f53587e
2 changed files with 6 additions and 7 deletions
|
|
@ -113,13 +113,12 @@ function parseTorrentPage(body) {
|
|||
const category = details.find('strong:contains(\'Gêneros: \')').next().attr('href').split('/')[0]
|
||||
const torrents = magnets.map(magnetLink => {
|
||||
const decodedMagnet = decode(magnetLink);
|
||||
const name = escapeHTML(decodedMagnet.name || '').replace(/\+/g, ' ');
|
||||
const sanitizedTitle = sanitizePtName(name);
|
||||
const name = sanitizePtName(escapeHTML(decodedMagnet.name || '').replace(/\+/g, ' '));
|
||||
const originalTitle = details.find('strong:contains(\'Baixar\')')[0].nextSibling.nodeValue.split('-')[0];
|
||||
const year = details.find('strong:contains(\'Data de Lançamento: \')').next().text().trim();
|
||||
const fallBackTitle = `${originalTitle.trim()} ${year.trim()} ${sanitizedTitle.trim()}`;
|
||||
const fallBackTitle = `${originalTitle.trim()} ${year.trim()} ${name.trim()}`;
|
||||
return {
|
||||
title: sanitizedTitle.length > 5 ? sanitizedTitle : fallBackTitle,
|
||||
title: name.length > 5 ? name : fallBackTitle,
|
||||
infoHash: decodedMagnet.infoHash,
|
||||
magnetLink: magnetLink,
|
||||
category: category,
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ function parseTorrentPage(body) {
|
|||
const category = details.find('span:contains(\'Gêneros: \')').next().html()
|
||||
const torrents = magnets.map(magnetLink => {
|
||||
const decodedMagnet = decode(magnetLink);
|
||||
const name = escapeHTML(decodedMagnet.name || '').replace(/\+/g, ' ');
|
||||
const name = sanitizePtName(escapeHTML(decodedMagnet.name || '').replace(/\+/g, ' '));
|
||||
const originalTitle = details.find('span:contains(\'Título Original: \')').next().text().trim();
|
||||
const year = details.find('span:contains(\'Ano de Lançamento: \')').next().text().trim();
|
||||
const fallbackTitle = `${originalTitle} ${year}`;
|
||||
const fallBackTitle = `${originalTitle.trim()} ${year.trim()} ${name.trim()}`;
|
||||
return {
|
||||
title: name ? sanitizePtName(name) : fallbackTitle,
|
||||
title: name.length > 5 ? name : fallBackTitle,
|
||||
originalName: sanitizePtOriginalName(originalTitle),
|
||||
year: year,
|
||||
infoHash: decodedMagnet.infoHash,
|
||||
|
|
|
|||
Loading…
Reference in a new issue