[scraper] include languages from tpb

This commit is contained in:
TheBeastLT
2020-04-15 14:46:26 +02:00
parent 09ce0f7594
commit 6d0763ba20
2 changed files with 11 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ const defaultProxies = [
'https://ukpiratebayproxy.com', 'https://ukpiratebayproxy.com',
'https://thepiratebayproxy.info', 'https://thepiratebayproxy.info',
'https://mypiratebay.co', 'https://mypiratebay.co',
'https://thehiddenbay.com',
// 'https://thepiratebay10.org', // 'https://thepiratebay10.org',
// 'https://thepiratebay0.org', // 'https://thepiratebay0.org',
]; ];
@@ -179,9 +180,9 @@ function parseBody(body) {
} }
torrents.push({ torrents.push({
name: name, name: name,
magnetLink: magnetLink,
infoHash: decode(magnetLink).infoHash,
torrentId: $(this).find('.detLink').attr('href').match(/torrent\/([^/]+)/)[1], torrentId: $(this).find('.detLink').attr('href').match(/torrent\/([^/]+)/)[1],
infoHash: decode(magnetLink).infoHash,
magnetLink: magnetLink,
seeders: parseInt($(this).find('td[align=\'right\']').eq(0).text(), 10), seeders: parseInt($(this).find('td[align=\'right\']').eq(0).text(), 10),
leechers: parseInt($(this).find('td[align=\'right\']').eq(1).text(), 10), leechers: parseInt($(this).find('td[align=\'right\']').eq(1).text(), 10),
@@ -206,17 +207,19 @@ function parseTorrentPage(body) {
const details = $('div[id=\'details\']'); const details = $('div[id=\'details\']');
const col1 = details.find('dl[class=\'col1\']'); const col1 = details.find('dl[class=\'col1\']');
const imdbIdMatch = col1.html().match(/imdb\.com\/title\/(tt\d+)/i); const imdbIdMatch = col1.html().match(/imdb\.com\/title\/(tt\d+)/i);
const magnetLink = details.find('a[title=\'Get this torrent\']').attr('href');
const torrent = { const torrent = {
name: $('div[id=\'title\']').text().trim(), name: $('div[id=\'title\']').text().trim(),
infoHash: decode(magnetLink).infoHash,
magnetLink: magnetLink,
seeders: parseInt(details.find('dt:contains(\'Seeders:\')').next().text(), 10), seeders: parseInt(details.find('dt:contains(\'Seeders:\')').next().text(), 10),
leechers: parseInt(details.find('dt:contains(\'Leechers:\')').next().text(), 10), leechers: parseInt(details.find('dt:contains(\'Leechers:\')').next().text(), 10),
magnetLink: details.find('a[title=\'Get this torrent\']').attr('href'),
infoHash: decode(details.find('a[title=\'Get this torrent\']').attr('href')).infoHash,
category: Categories.VIDEO.ALL, category: Categories.VIDEO.ALL,
subcategory: parseInt(col1.find('a[title=\'More from this category\']').eq(0).attr('href').match(/\d+$/)[0], 10), subcategory: parseInt(col1.find('a[title=\'More from this category\']').eq(0).attr('href').match(/\d+$/)[0], 10),
size: parseSize(details.find('dt:contains(\'Size:\')').next().text().match(/(\d+)(?:.?Bytes)/)[1]), size: parseSize(details.find('dt:contains(\'Size:\')').next().text().match(/(\d+)(?:.?Bytes)/)[1]),
uploadDate: new Date(details.find('dt:contains(\'Uploaded:\')').next().text()), uploadDate: new Date(details.find('dt:contains(\'Uploaded:\')').next().text()),
languages: details.find('dt:contains(\'Spoken language(s):\')').next().text(),
imdbId: imdbIdMatch && imdbIdMatch[1] imdbId: imdbIdMatch && imdbIdMatch[1]
}; };
resolve(torrent); resolve(torrent);

View File

@@ -79,11 +79,12 @@ async function processTorrentRecord(record) {
provider: NAME, provider: NAME,
torrentId: torrentFound.torrentId, torrentId: torrentFound.torrentId,
title: torrentFound.name.replace(/\t|\s+/g, ' '), title: torrentFound.name.replace(/\t|\s+/g, ' '),
size: torrentFound.size,
type: seriesCategories.includes(torrentFound.subcategory) ? Type.SERIES : Type.MOVIE, type: seriesCategories.includes(torrentFound.subcategory) ? Type.SERIES : Type.MOVIE,
imdbId: seriesCategories.includes(torrentFound.subcategory) && torrentFound.imdbId || undefined, size: torrentFound.size,
uploadDate: torrentFound.uploadDate,
seeders: torrentFound.seeders, seeders: torrentFound.seeders,
uploadDate: torrentFound.uploadDate,
imdbId: seriesCategories.includes(torrentFound.subcategory) && torrentFound.imdbId || undefined,
languages: torrentFound.languages && torrentFound.languages.trim() || undefined
}; };
return createTorrentEntry(torrent); return createTorrentEntry(torrent);