本文整理汇总了Python中API.API.post_watching_history方法的典型用法代码示例。如果您正苦于以下问题:Python API.post_watching_history方法的具体用法?Python API.post_watching_history怎么用?Python API.post_watching_history使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API.API
的用法示例。
在下文中一共展示了API.post_watching_history方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseDanMu
# 需要导入模块: from API import API [as 别名]
# 或者: from API.API import post_watching_history [as 别名]
async def parseDanMu(self, messages):
try:
dic = json.loads(messages)
except:
return
cmd = dic['cmd']
if cmd == 'DANMU_MSG':
# print(dic)
self.print_danmu_msg(dic)
pass
if cmd == 'SYS_GIFT':
try:
headers = {
'Accept': 'application/json, text/plain, */*',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'Accept-Language': 'zh-CN,zh;q=0.9',
'accept-encoding': 'gzip, deflate',
'Host': 'api.live.bilibili.com',
'cookie': self.cookie,
}
text1 = dic['real_roomid']
text2 = dic['url']
await asyncio.sleep(random.uniform(3, 5))
API.post_watching_history(bilibili.csrf,text1)
url = 'http://api.live.bilibili.com/activity/v1/Raffle/check?roomid=' + str(text1)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), "检测到房间", str(text1).center(9), "的活动抽奖")
response = requests.get(url, headers=headers)
checklen = response.json()['data']
num = len(checklen)
while num != 0:
for j in range(0,num):
await asyncio.sleep(random.uniform(0.5, 1))
resttime = response.json()['data'][j]['time']
raffleid = response.json()['data'][j]['raffleId']
if raffleid not in bilibili.activity_raffleid_list:
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), "参与了房间", str(text1).center(9), "的活动抽奖")
bilibili.activity_raffleid_list.append(raffleid)
bilibili.activity_roomid_list.append(text1)
bilibili.activity_time_list.append(resttime)
headers = {
'Accept': 'application/json, text/plain, */*',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'cookie': self.cookie,
'referer': text2
}
temp_params = 'access_key='+self.access_key+'&actionKey='+self.actionKey+'&appkey='+self.appkey+'&build='+self.build+'&device='+self.device+'&event_type=flower_rain-' + str(
raffleid) + '&mobi_app='+self.mobi_app+'&platform='+self.platform+'&room_id=' + str(
text1) + '&ts=' + CurrentTime()
params = temp_params + self.app_secret
hash = hashlib.md5()
hash.update(params.encode('utf-8'))
true_url = 'http://api.live.bilibili.com/YunYing/roomEvent?' + temp_params + '&sign=' + str(
hash.hexdigest())
pc_url = 'http://api.live.bilibili.com/activity/v1/Raffle/join?roomid=' + str(
text1) + '&raffleId=' + str(raffleid)
response1 = requests.get(true_url,params=params, headers=headers)
pc_response = requests.get(pc_url, headers=headers)
try:
print("# 移动端活动抽奖结果:", response1.json()['data']['gift_desc'])
except:
pass
try:
print("# 网页端活动抽奖状态:", pc_response.json()['message'])
except:
pass
break
except:
pass
return
if cmd == 'SYS_MSG':
try:
TV_url = dic['url']
real_roomid = dic['real_roomid']
#url = "https://api.live.bilibili.com/AppSmallTV/index?access_key=&actionKey=appkey&appkey=1d8b6e7d45233436&build=5230003&device=android&mobi_app=android&platform=android&roomid=939654&ts=1521734039&sign=4f85e1d3ce0e1a3acd46fcf9ca3cbeed"
temp_params = 'access_key=' + self.access_key + '&actionKey=' + self.actionKey + '&appkey=' + self.appkey + '&build=' + self.build + '&device=' + self.device +\
'&mobi_app=' + self.mobi_app + '&platform=' + self.platform + '&roomid=' + str(
real_roomid) + '&ts=' + CurrentTime()
params = temp_params + self.app_secret
hash = hashlib.md5()
hash.update(params.encode('utf-8'))
await asyncio.sleep(random.uniform(3, 5))
API.post_watching_history(bilibili.csrf,real_roomid)
check_url = 'https://api.live.bilibili.com/AppSmallTV/index?' + temp_params + '&sign=' + str(
hash.hexdigest())
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), "监测到房间", str(real_roomid).center(9), "的小电视抽奖")
# headers = {
# 'Accept': 'application/json, text/plain, */*',
# 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
# 'Accept-Language': 'zh-CN,zh;q=0.9',
# 'accept-encoding': 'gzip, deflate',
# 'Host': 'api.live.bilibili.com',
# 'cookie': self.cookie,
# }
response = requests.get(check_url, headers=self.appheaders)
checklen = response.json()['data']['unjoin']
#.........这里部分代码省略.........