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

Commit

Permalink
代码调整,添加查询可用礼物api
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Mar 25, 2018
1 parent 1a21bc8 commit ea6fdc5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions API.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from bilibili import bilibili
import requests
import datetime
import time


class API(bilibili):
Expand All @@ -11,7 +13,20 @@ def post_watching_history(csrf_token, room_id):
"room_id": room_id,
"csrf_token": csrf_token
}
ulr = "https://api.live.bilibili.com/room/v1/Room/room_entry_action"
response = requests.post(ulr, data=data, headers=bilibili.pcheaders)
url = "https://api.live.bilibili.com/room/v1/Room/room_entry_action"
requests.post(url, data=data, headers=bilibili.pcheaders)
# print(response.json())
return 0

def CurrentTime():
currenttime = str(int(time.mktime(datetime.datetime.now().timetuple())))
return currenttime

def get_bag_list():
url = "https://api.live.bilibili.com/gift/v2/gift/m_bag_list?" + 'access_key='+bilibili.access_key+'&actionKey='+bilibili.actionKey+'&appkey='+bilibili.appkey+'&build='+bilibili.build+'&device='+bilibili.device + '&mobi_app='+bilibili.mobi_app+'&platform='+bilibili.platform + '&ts=' + API.CurrentTime()
response = requests.get(url, headers=bilibili.pcheaders)
for i in range(len(response.json()['data'])):
gift_name = response.json()['data'][i]['gift_name']
gift_num = str(response.json()['data'][i]['gift_num']).center(4)
expireat = str(round(int(response.json()['data'][i]['expireat']) / 86400, 1)).center(6)
print(gift_name, 'X', gift_num, '(在', expireat, '天后过期)')

0 comments on commit ea6fdc5

Please sign in to comment.