def getFlashVars(url):
cookie = common.mechanizeLogin()
showpage = common.getURL(url, useCookie=cookie)
if not showpage:
Dialog.notification(common.__plugin__, Error('CDP.InvalidRequest'), xbmcgui.NOTIFICATION_ERROR)
return False
values = {}
search = {'sessionID': "ue_sid='(.*?)'",
'marketplace': "ue_mid='(.*?)'",
'customer': '"customerID":"(.*?)"'}
if 'var config' in showpage:
flashVars = re.compile('var config = (.*?);', re.DOTALL).findall(showpage)
flashVars = json.loads(unicode(flashVars[0], errors='ignore'))
values = flashVars['player']['fl_config']['initParams']
else:
for key, pattern in search.items():
result = re.compile(pattern, re.DOTALL).findall(showpage)
if result:
values[key] = result[0]
for key in values.keys():
if key not in values:
Dialog.notification(common.getString(30200), common.getString(30210), xbmcgui.NOTIFICATION_ERROR)
return False
values['deviceTypeID'] = DEVICETYPE_ID
values['asin'] = common.args.asin
values['userAgent'] = common.UserAgent
values['deviceID'] = common.gen_id()
rand = 'onWebToken_' + str(random.randint(0, 484))
pltoken = common.getURL(common.BASE_URL + "/gp/video/streaming/player-token.json?callback=" + rand, useCookie=cookie)
try:
values['token'] = re.compile('"([^"]*).*"([^"]*)"').findall(pltoken)[0][1]
except Exception:
Dialog.notification(common.getString(30200), common.getString(30201), xbmcgui.NOTIFICATION_ERROR)
return False
return values
评论列表
文章目录