torrent-hound.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:torrent-hound 作者: baddymaster 项目源码 文件源码
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?")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号