Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if len(torrent_rows) < 2:
logger.log(u"Data returned from provider does not contain any torrents", logger.DEBUG)
continue
for result in torrent_rows[1:]:
cells = result('td')
link = cells[1].find('a')
download_url = self.urls['download'] % cells[2].find('a')['href']
try:
title = link.getText()
seeders = int(cells[10].getText().replace(',', ''))
leechers = int(cells[11].getText().replace(',', ''))
torrent_size = cells[8].getText()
size = convert_size(torrent_size) or -1
except (AttributeError, TypeError):
continue
if not all([title, download_url]):
continue
# Filter unseeded torrent
if seeders < min(self.minseed, 1):
if mode != 'RSS':
logger.log(u"Discarding torrent because it doesn't meet the minimum seeders: {0}. Seeders: {1})".format
(title, seeders), logger.DEBUG)
continue
if seeders >= 32768 or leechers >= 32768:
continue
seeders = row.find('seeders')
seeders = try_int(seeders.get_text(strip=True)) if seeders else 1
leechers = row.find('leechers')
leechers = try_int(leechers.get_text(strip=True)) if leechers else 0
# Filter unseeded torrent
if seeders < min(self.minseed, 1):
if mode != 'RSS':
logger.log("Discarding torrent because it doesn't meet the "
"minimum seeders: {0}. Seeders: {1}".format
(title, seeders), logger.DEBUG)
continue
torrent_size = row.find('size')
torrent_size = torrent_size.get_text() if torrent_size else None
size = convert_size(torrent_size) or -1
item = {
'title': title,
'link': download_url,
'size': size,
'seeders': seeders,
'leechers': leechers,
'pubdate': None,
'hash': None,
}
if mode != 'RSS':
logger.log('Found result: {0} with {1} seeders and {2} leechers'.format
(title, seeders, leechers), logger.DEBUG)
items.append(item)
except (AttributeError, TypeError, KeyError, ValueError, IndexError):
search_url = self.url + "api/v2/torrents/search/?category=TV&phrase=" + search_string
jdata = self.get_url(search_url, returns='json')
if not jdata:
logger.log(u"No data returned from provider", logger.DEBUG)
return []
results = []
for item in jdata['torrents']:
seeders = ('seeds' in item and item['seeds']) or 0
leechers = ('leeches' in item and item['leeches']) or 0
title = ('torrent_title' in item and item['torrent_title']) or ''
torrent_size = ('size' in item and item['size'])
size = convert_size(torrent_size) or -1
download_url = ('magnet_uri' in item and item['magnet_uri']) or ''
if not all([title, download_url]):
continue
# Filter unseeded torrent
if seeders < min(self.minseed, 1):
if mode != 'RSS':
logger.log(u"Discarding torrent because it doesn't meet the minimum seeders: {0}. Seeders: {1})".format
(title, seeders), logger.DEBUG)
continue
if mode != 'RSS':
logger.log(u"Found result: %s with %s seeders and %s leechers" % (title, seeders, leechers), logger.DEBUG)
item = {'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers, 'pubdate': None, 'hash': None}
title = cells[labels.index('Nom')].get_text(strip=True)
download_url = cells[labels.index('DL')].find('a')['href']
if not all([title, download_url]):
continue
seeders = try_int(cells[labels.index('Seed')].get_text(strip=True))
leechers = try_int(cells[labels.index('Leech')].get_text(strip=True))
# Filter unseeded torrent
if seeders < min(self.minseed, 1) or leechers < min(self.minleech, 0):
if mode != 'RSS':
logger.log(u"Discarding torrent because it doesn't meet the minimum seeders or leechers: {} (S:{} L:{})".format(title, seeders, leechers), logger.DEBUG)
continue
torrent_size = cells[labels.index('Taille')].get_text(strip=True)
size = convert_size(torrent_size, units=units) or -1
item = {'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers, 'hash': None}
if mode != 'RSS':
logger.log(u"Found result: %s with %s seeders and %s leechers" % (title, seeders, leechers), logger.DEBUG)
items.append(item)
except StandardError:
continue
# For each search mode sort all the items by seeders if available
items.sort(key=lambda d: try_int(d.get('seeders', 0)), reverse=True)
results += items
return results