def requestJSON(self, url, headers, body=None, method=None):
addon_profile_path = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('profile'))
cj = cookielib.LWPCookieJar(os.path.join(addon_profile_path, 'cookies.lwp'))
try: cj.load(os.path.join(addon_profile_path, 'cookies.lwp'),ignore_discard=True)
except: pass
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = headers
try:
request = urllib2.Request(url, body)
if method == 'DELETE': request.get_method = lambda: method
response = opener.open(request)
json_source = json.load(response)
response.close()
self.saveCookie(cj)
except HTTPError as e:
if e.code == 403:
msg = 'Your device is not authorized to view the selected stream.\n Would you like to authorize this device now?'
dialog = xbmcgui.Dialog()
answer = dialog.yesno('Account Not Authorized', msg)
if answer: self.registerDevice()
sys.exit(0)
return json_source
adobepass.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录