Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | """ |
||
3 | cron: 20 8 * * * |
||
4 | new Env('网易云游戏'); |
||
5 | """ |
||
6 | |||
7 | import requests |
||
8 | |||
9 | from notify_mtr import send |
||
10 | from utils import get_data |
||
11 | |||
12 | |||
13 | class Game163: |
||
14 | def __init__(self, check_items): |
||
15 | self.check_items = check_items |
||
16 | |||
17 | @staticmethod |
||
18 | def checkin(authorization): |
||
19 | url = "http://n.cg.163.com/api/v2/sign-today" |
||
20 | headers = { |
||
21 | "user-agent": "Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) " |
||
22 | "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 " |
||
23 | "Chrome/85.0.4183.127 Mobile Safari/537.36", |
||
24 | "authorization": authorization, |
||
25 | } |
||
26 | res = requests.post(url, headers=headers).text |
||
27 | return "cookie 已失效" if res[0] == "{" else "签到成功" |
||
28 | |||
29 | def main(self): |
||
30 | msg_all = "" |
||
31 | for check_item in self.check_items: |
||
32 | authorization = str(check_item.get("authorization")) |
||
33 | msg = self.checkin(authorization) |
||
34 | msg_all += msg + "\n\n" |
||
35 | return msg_all |
||
36 | |||
37 | |||
38 | if __name__ == "__main__": |
||
39 | _data = get_data() |
||
40 | _check_items = _data.get("GAME163", []) |
||
41 | result = Game163(check_items=_check_items).main() |
||
42 | send("网易云游戏", result) |
||
43 |