def generateNewTorrentAPIToken(error=False):
global auth_token
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'}
refresh_url = 'https://torrentapi.org/pubapi_v2.php?get_token=get_token'
try:
auth_token = json.loads(requests.get(refresh_url, headers=headers).text)['token'].encode('utf-8')
if error != False:
success_string = '[RARBG] Success : Generated new token! '
print colored.blue(success_string)
except requests.exceptions.ConnectionError, e:
err_string = str(e).split(',')[0]
if 'Connection aborted' in err_string:
print colored.red("Server cannot be reached. Check Internet connectivity!")
sys.exit(1)
except SysCallError, e:
print colored.red("SysCallError for RARBG search. Fix?")
评论列表
文章目录