Skip to content

Commit

Permalink
avoid errors if description is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitxel Moriana committed Aug 31, 2017
1 parent 323072b commit 39e712d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,16 @@ Mgt.scrapeStrategies.tpb = function (url, searchQuery) {
var name = tr.find('.detName > a').text();
var uploadedBy = tr.find('a.detDesc').text();
var description = tr.find('font.detDesc').clone().children().remove().end().text().split(',');
var uploaded = typeof description[0] !== 'undefined' ? description[0].replace('Uploaded ', '') : '';
var size = typeof description[1] !== 'undefined' ? description[1].replace('Size ', '') : '';
var uploaded = '';
var size = '';
if (Array.isArray(description) && description.length) {
if (typeof description[0] !== 'undefined') {
uploaded = description[0].replace('Uploaded ', '');
}
if (typeof description[1] !== 'undefined') {
size = description[1].replace('Size ', '');
}
}
var seeders = tr.find('td:nth-last-child(2)').text();
var leechers = tr.find('td:last-child').text();

Expand Down

0 comments on commit 39e712d

Please sign in to comment.