-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbilisignGroup.py
52 lines (44 loc) · 1.6 KB
/
bilisignGroup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
from functools import wraps
# you need to copy your cookie from your browser and paste it here
cookie = {"cookie": ""}
class Group():
def getGroupList(self): # find member groups you joined in
url = r'https://api.live.bilibili.com/link_group/v1/member/my_groups'
response = requests.get(
url = url,
headers = cookie
).json()
if response["code"] == 0:
self.groupList = response["data"]["list"]
def log_signGroup(func):
@wraps(func)
def wrapper(self, target):
result = func(self, target)
if result["code"] == 0:
print('已在 {0} 签到, {1}'.format(target["group_name"], result["msg"]))
else:
raise RuntimeError('Fail to sign in {0}, group_id={1}, owner_uid={2}'.format(target["group_name"],
target["group_id"], target["owner_uid"]))
return wrapper
@log_signGroup
def signGroup(self, target):
url_0 = r'https://api.live.bilibili.com/link_setting/v1/link_setting/sign_in?group_id='
url_1 = r'&owner_id='
response = requests.get(
url = url_0 + str(target["group_id"]) + url_1 + str(target["owner_uid"]),
headers = cookie
).json()
return response
def __call__(self):
self.getGroupList()
for target in self.groupList:
self.signGroup(target)
print('今日应援团已签到')
def main():
Group()()
if __name__ == '__main__':
main()
input("按Enter键退出")