Commit 4956499a authored by echel0n's avatar echel0n

Refactored TorrentBytes provider.

parent 8a0fd2b6
# Changelog
- * 31a7f64 - 2018-11-18: Release v9.4.40
- * e29a2d2 - 2018-11-18: Refactored TorrentBytes provider.
- * 735245c - 2018-11-18: Release v9.4.40
- * b538435 - 2018-11-18: Refactored network timezone functions.
- * 79d9ea1 - 2018-11-18: Fixed issue with database integrity checks.
- * b005c24 - 2018-11-18: Refactored app to use pip2 instead of pip. Fixed issues with source upgrading.
......
......@@ -63,9 +63,8 @@ class TorrentBytesProvider(TorrentProvider):
sickrage.app.log.warning("Unable to connect to provider")
return False
if re.search('Username or password incorrect', response):
sickrage.app.log.warning(
"Invalid username or password. Check your settings")
if 'username or password incorrect' in response.lower():
sickrage.app.log.warning("Invalid username or password. Check your settings")
return False
return True
......@@ -76,7 +75,13 @@ class TorrentBytesProvider(TorrentProvider):
if not self.login():
return results
search_params = {"c33": 1, "c38": 1, "c32": 1, "c37": 1, "c41": 1}
search_params = {
"c33": 1,
"c38": 1,
"c32": 1,
"c37": 1,
"c41": 1
}
for mode in search_strings:
sickrage.app.log.debug("Search Mode: %s" % mode)
......@@ -114,11 +119,13 @@ class TorrentBytesProvider(TorrentProvider):
return results
# "Type", "Name", Files", "Comm.", "Added", "TTL", "Size", "Snatched", "Seeders", "Leechers"
labels = [label.get_text(strip=True) for label in torrent_rows[0]("td")]
labels = [label.get_text(strip=True) for label in torrent_rows[0]('td')]
for result in torrent_rows[1:]:
try:
cells = result("td")
cells = result('td')
if len(cells) < len(labels):
continue
link = cells[labels.index("Name")].find("a", href=re.compile(r"download.php\?id="))["href"]
download_url = urljoin(self.urls['base_url'], link)
......@@ -136,12 +143,17 @@ class TorrentBytesProvider(TorrentProvider):
seeders = try_int(cells[labels.index("Seeders")].get_text(strip=True))
leechers = try_int(cells[labels.index("Leechers")].get_text(strip=True))
torrent_size = cells[labels.index("Size")].get_text(strip=True)
size = convert_size(torrent_size, -1)
results += [
{'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers}
]
results += [{
'title': title,
'link': download_url,
'size': size,
'seeders': seeders,
'leechers': leechers
}]
if mode != "RSS":
sickrage.app.log.debug("Found result: {}".format(title))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment