Private GIT

Skip to content
Snippets Groups Projects
Commit 5fcc4282 authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

Merge branch 'hotfix-3236' into develop

parents c4639435 fee1a0c3
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ class T411Provider(generic.TorrentProvider):
self.urls = {'base_url': 'http://www.t411.in/',
'search': 'https://api.t411.in/torrents/search/%s?cid=%s&limit=100',
'rss': 'https://api.t411.in/torrents/top/today',
'login_page': 'https://api.t411.in/auth',
'download': 'https://api.t411.in/torrents/download/%s',
}
......@@ -60,6 +61,10 @@ class T411Provider(generic.TorrentProvider):
self.subcategories = [433, 637, 455, 639]
self.minseed = 0
self.minleech = 0
self.confirmed = False
def isEnabled(self):
return self.enabled
......@@ -102,42 +107,49 @@ class T411Provider(generic.TorrentProvider):
if mode != 'RSS':
logger.log(u"Search string: %s " % search_string, logger.DEBUG)
for sc in self.subcategories:
searchURL = self.urls['search'] % (search_string, sc)
searchURLS = ([self.urls['search'] % (search_string, u) for u in self.subcategories], [self.urls['rss']])[mode == 'RSS']
for searchURL in searchURLS:
logger.log(u"Search URL: %s" % searchURL, logger.DEBUG)
data = self.getURL(searchURL, json=True)
if not data:
continue
try:
if 'torrents' not in data:
try:
if 'torrents' not in data and mode != 'RSS':
logger.log(u"Data returned from provider does not contain any torrents", logger.DEBUG)
continue
torrents = data['torrents']
torrents = data['torrents'] if mode != 'RSS' else data
if not torrents:
logger.log(u"Data returned from provider does not contain any torrents", logger.DEBUG)
continue
for torrent in torrents:
if mode == 'RSS' and int(torrent['category']) not in self.subcategories:
continue
try:
title = torrent['name']
torrent_id = torrent['id']
download_url = (self.urls['download'] % torrent_id).encode('utf8')
#FIXME
size = -1
seeders = 1
leechers = 0
if not all([title, download_url]):
continue
size = int(torrent['size'])
seeders = int(torrent['seeders'])
leechers = int(torrent['leechers'])
verified = bool(torrent['isVerified'])
#Filter unseeded torrent
#if seeders < self.minseed or leechers < self.minleech:
# if mode != 'RSS':
# logger.log(u"Discarding torrent because it doesn't meet the minimum seeders or leechers: {0} (S:{1} L:{2})".format(title, seeders, leechers), logger.DEBUG)
# continue
if seeders < self.minseed or leechers < self.minleech:
if mode != 'RSS':
logger.log(u"Discarding torrent because it doesn't meet the minimum seeders or leechers: {0} (S:{1} L:{2})".format(title, seeders, leechers), logger.DEBUG)
continue
if self.confirmed and not verified and mode != 'RSS':
logger.log(u"Found result " + title + " but that doesn't seem like a verified result so I'm ignoring it", logger.DEBUG)
continue
item = title, download_url, size, seeders, leechers
if mode != 'RSS':
......@@ -147,6 +159,7 @@ class T411Provider(generic.TorrentProvider):
except Exception as e:
logger.log(u"Invalid torrent data, skipping result: %s" % torrent, logger.DEBUG)
logger.log(u"Failed parsing provider. Traceback: %s" % traceback.format_exc(), logger.DEBUG)
continue
except Exception, e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment