forked from yuxian158/check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ck_mgtv.py
68 lines (62 loc) · 2.3 KB
/
ck_mgtv.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
"""
建议cron: 23 14 * * *
new Env('芒果TV');
"""
import json
import os
import time
from urllib import parse
from getENV import getENv
from checksendNotify import send
import requests
class MgtvCheckIn:
def __init__(self, check_item):
self.check_item = check_item
@staticmethod
def sign(params):
url = "https://credits.bz.mgtv.com/user/creditsTake"
user_params = {
"abroad": params.get("abroad"),
"ageMode": "0",
"appVersion": params.get("appVersion"),
"artistId": params.get("uuid"),
"device": params.get("device"),
"did": params.get("did"),
"mac": params.get("did"),
"osType": params.get("osType"),
"src": "mgtv",
"testversion": "",
"ticket": params.get("ticket"),
"uuid": params.get("uuid"),
}
try:
user_info = requests.get(url="https://homepage.bz.mgtv.com/v2/user/userInfo", params=user_params).json()
username = user_info.get("data", {}).get("nickName")
except Exception as e:
print("获取用户信息失败", e)
username = params.get("uuid")
res = requests.get(url=url, params=params)
res_json = json.loads(res.text.replace(f"{params.get('callback')}(", "").replace(");", ""))
if res_json["code"] == 200:
cur_day = res_json["data"]["curDay"]
_credits = res_json["data"]["credits"]
msg = f"帐号信息: {username}\n签到积分: +{_credits}积分\n已经签到: {cur_day}天/21天"
else:
msg = f"帐号信息: {username}\n签到状态: 已完成签到 or 签到失败"
return msg
def main(self):
mgtv_params = self.check_item.get("mgtv_params")
params = parse.parse_qs(mgtv_params)
params["timestamp"] = [round(time.time())]
params = {key: value[0] for key, value in params.items()}
msg = self.sign(params=params)
return msg
if __name__ == "__main__":
getENv()
with open("/ql/config/check.json", "r", encoding="utf-8") as f:
datas = json.loads(f.read())
_check_item = datas.get("MGTV_PARAMS_LIST", [])[0]
res = MgtvCheckIn(check_item=_check_item).main()
print(res)
send("芒果 TV",res)