pads tpb info imdbId with zeros

This commit is contained in:
TheBeastLT
2020-02-24 21:19:55 +01:00
parent 78691c2ae9
commit dc65ac62f4

View File

@@ -187,7 +187,7 @@ 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 torrent = { const torrent = {
name: $('div[id=\'title\']').text().trim(), name: $('div[id=\'title\']').text().trim(),
@@ -198,7 +198,7 @@ function parseTorrentPage(body) {
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()),
imdbId: imdbIdMatch && imdbIdMatch[1] imdbId: imdbIdMatch && `tt${imdbIdMatch[1].padStart(7, '0')}`
}; };
resolve(torrent); resolve(torrent);
}); });