mirror of https://github.com/evilhero/mylar
FIX:(#1091) When trying to retrieve torrents from KAT, would create invalid torrent files
This commit is contained in:
parent
abcc4e88ec
commit
ec31c9ec9d
|
@ -1741,15 +1741,21 @@ def create_https_certificates(ssl_cert, ssl_key):
|
|||
|
||||
return True
|
||||
|
||||
def torrent_create(site, linkid):
|
||||
def torrent_create(site, linkid, alt=None):
|
||||
if site == '32P':
|
||||
pass
|
||||
elif site == 'KAT':
|
||||
if 'http' in linkid:
|
||||
#if it's being passed here with the http alread in, then it's an old rssdb entry and we can take it as is.
|
||||
url = linkid
|
||||
if alt is None:
|
||||
#if it's being passed here with the http alread in, then it's an old rssdb entry and we can take it as is.
|
||||
url = linkid
|
||||
else:
|
||||
url = re.sub('http://torcache.net/','http://torrage.com/', linkid).strip()
|
||||
else:
|
||||
url = 'http://torcache.net/torrent/' + str(linkid) + '.torrent'
|
||||
if alt is None:
|
||||
url = 'http://torcache.net/torrent/' + str(linkid) + '.torrent'
|
||||
else:
|
||||
url = 'http://torrage.com/torrent/' + str(linkid) + '.torrent'
|
||||
|
||||
return url
|
||||
|
||||
|
|
|
@ -738,10 +738,11 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site):
|
|||
else:
|
||||
kat_referrer = linkit[:stfind]
|
||||
|
||||
logger.fdebug('KAT Referer set to :' + kat_referrer)
|
||||
#logger.fdebug('KAT Referer set to :' + kat_referrer)
|
||||
|
||||
headers = {'Accept-encoding': 'gzip',
|
||||
'Referer': kat_referrer}
|
||||
'User-Agent': str(mylar.USER_AGENT)}
|
||||
#'Referer': kat_referrer}
|
||||
|
||||
url = helpers.torrent_create('KAT', linkit)
|
||||
|
||||
|
@ -786,6 +787,19 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site):
|
|||
else:
|
||||
return "fail"
|
||||
|
||||
if str(r.status_code) == '403':
|
||||
#retry with the alternate torrent link.
|
||||
url = helpers.torrent_create('KAT', linkit, True)
|
||||
try:
|
||||
r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)
|
||||
|
||||
except Exception, e:
|
||||
return "fail"
|
||||
|
||||
if str(r.status_code) != '200':
|
||||
logger.warn('Unable to download torrent from ' + site + ' [Status Code returned: ' + str(r.status_code) + ']')
|
||||
return "fail"
|
||||
|
||||
if site == 'KAT':
|
||||
if r.headers.get('Content-Encoding') == 'gzip':
|
||||
buf = StringIO(r.content)
|
||||
|
|
Loading…
Reference in New Issue