Fixed issue retrieving seeders and leechers which caused searching to fail on IPT

This commit is contained in:
Dean Gardiner
2014-01-15 20:52:27 +13:00
parent 37d4755aae
commit 4147c5b870

View File

@@ -1,5 +1,5 @@
from bs4 import BeautifulSoup
from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.encoding import tryUrlencode, toSafeString
from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.torrent.base import TorrentProvider
@@ -57,21 +57,27 @@ class IPTorrents(TorrentProvider):
entries = result_table.find_all('tr')
columns = self.getColumns(entries)
if 'seeders' not in columns or 'leechers' not in columns:
log.warning('Unrecognized table format returned')
return
for result in entries[1:]:
torrent = result.find_all('td')
if len(torrent) <= 1:
cells = result.find_all('td')
if len(cells) <= 1:
break
torrent = torrent[1].find('a')
torrent = cells[1].find('a')
torrent_id = torrent['href'].replace('/details.php?id=', '')
torrent_name = torrent.string
torrent_download_url = self.urls['base_url'] + (result.find_all('td')[3].find('a'))['href'].replace(' ', '.')
torrent_details_url = self.urls['base_url'] + torrent['href']
torrent_size = self.parseSize(result.find_all('td')[5].string)
torrent_seeders = tryInt(result.find('td', attrs = {'class' : 'ac t_seeders'}).string)
torrent_leechers = tryInt(result.find('td', attrs = {'class' : 'ac t_leechers'}).string)
torrent_seeders = tryInt(cells[columns['seeders']].string)
torrent_leechers = tryInt(cells[columns['leechers']].string)
results.append({
'id': torrent_id,
@@ -89,6 +95,19 @@ class IPTorrents(TorrentProvider):
current_page += 1
def getColumns(self, entries):
result = {}
for x, col in enumerate(entries[0].find_all('th')):
key = toSafeString(col.text).strip().lower()
if not key:
continue
result[key] = x
return result
def getLoginParams(self):
return {
'username': self.conf('username'),