Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
紧急修复,换成APP接口参与小电视抽奖
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawnnnnnn committed Mar 22, 2018
1 parent 043f56d commit 63569dc
Showing 1 changed file with 46 additions and 29 deletions.
75 changes: 46 additions & 29 deletions bilibiliCilent.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def parseDanMu(self, messages):
num = len(checklen)
while num != 0:
for j in range(0,num):
time.sleep(1)
time.sleep(0.5)
resttime = response.json()['data'][j]['time']
raffleid = response.json()['data'][j]['raffleId']
bilibili.activity_raffleid_list.append(raffleid)
Expand Down Expand Up @@ -158,43 +158,60 @@ def parseDanMu(self, messages):
try:
TV_url = dic['url']
real_roomid = dic['real_roomid']

url = 'http://api.live.bilibili.com/gift/v2/smalltv/check?roomid=' + str(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'))
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())))
print("检测到房间", str(real_roomid), "的小电视抽奖")
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(url, headers=headers)
checklen = response.json()['data']
# 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']
num = len(checklen)
while num != 0:
for j in range(0,num):
time.sleep(1)
resttime = response.json()['data'][j]['time']
raffleid = response.json()['data'][j]['raffleId']
time.sleep(0.5)
resttime = response.json()['data']['unjoin'][j]['dtime']
raffleid = response.json()['data']['unjoin'][j]['id']
self.TV_raffleid_list.append(raffleid)
bilibili.TV_raffleid_list.append(raffleid)
bilibili.TV_roomid_list.append(real_roomid)
bilibili.TV_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',
'Accept-Language': 'zh-CN,zh;q=0.9',
'accept-encoding': 'gzip, deflate',
'Host': 'api.live.bilibili.com',
'cookie': self.cookie,
'referer': TV_url
}
url1 = 'http://api.live.bilibili.com/gift/v2/smalltv/join?roomid=' + str(
real_roomid) + '&raffleId=' + str(raffleid)
response1 = requests.get(url1, headers=headers)
print("小电视抽奖状态:",response1.json()['msg'])
#url = "https://api.live.bilibili.com/AppSmallTV/join?access_key=&actionKey=appkey&appkey=1d8b6e7d45233436&build=5230003&device=android&id=41581&mobi_app=android&platform=android&roomid=3566261&ts=1521731305&sign=ae3d61f496c66069bcfd299fe7ce1792"
temp_params = 'access_key='+self.access_key+'&actionKey='+self.actionKey+'&appkey='+self.appkey+'&build='+self.build+'&device='+self.device+'&id=' + str(
raffleid) + '&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'))
true_url = 'http://api.live.bilibili.com/AppSmallTV/join?' + temp_params + '&sign=' + str(
hash.hexdigest())
# 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,
# 'referer': TV_url
# }
# url1 = 'http://api.live.bilibili.com/gift/v2/smalltv/join?roomid=' + str(
# real_roomid) + '&raffleId=' + str(raffleid)
# #response1 = requests.get(url1, headers=headers)
response2 = requests.get(true_url,headers=self.appheaders)
print("小电视抽奖状态:",response2.json()['msg'])
break

except:
Expand Down

0 comments on commit 63569dc

Please sign in to comment.