2020-12-06 14:10:01 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
|
|
import os
|
2020-12-07 13:29:36 +08:00
|
|
|
import re
|
2020-12-06 14:10:01 +08:00
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
class KGQQCheckIn:
|
2020-12-07 13:29:36 +08:00
|
|
|
def __init__(self, kgqq_cookie_list):
|
2020-12-06 14:10:01 +08:00
|
|
|
self.kgqq_cookie_list = kgqq_cookie_list
|
|
|
|
|
2020-12-07 13:29:36 +08:00
|
|
|
@staticmethod
|
|
|
|
def sign(kgqq_cookie):
|
2020-12-06 14:10:01 +08:00
|
|
|
headers = {"Cookie": kgqq_cookie}
|
|
|
|
uid = kgqq_cookie.split("; ")
|
|
|
|
t_uuid = ""
|
|
|
|
for i in uid:
|
|
|
|
if i.find("uid=") >= 0:
|
|
|
|
t_uuid = i.split("=")[1]
|
|
|
|
proto_profile_url = "https://node.kg.qq.com/webapp/proxy?ns=proto_profile&cmd=profile.getProfile&mapExt=JTdCJTIyZmlsZSUyMiUzQSUyMnByb2ZpbGVfd2ViYXBwSmNlJTIyJTJDJTIyY21kTmFtZSUyMiUzQSUyMlByb2ZpbGVHZXQlMjIlMkMlMjJhcHBpZCUyMiUzQTEwMDA2MjYlMkMlMjJkY2FwaSUyMiUzQSU3QiUyMmludGVyZmFjZUlkJTIyJTNBMjA1MzU5NTk3JTdEJTJDJTIybDVhcGklMjIlM0ElN0IlMjJtb2RpZCUyMiUzQTI5NDAxNyUyQyUyMmNtZCUyMiUzQTI2MjE0NCU3RCUyQyUyMmlwJTIyJTNBJTIyMTAwLjExMy4xNjIuMTc4JTIyJTJDJTIycG9ydCUyMiUzQSUyMjEyNDA2JTIyJTdE&t_uUid={0}".format(
|
2020-12-07 13:29:36 +08:00
|
|
|
t_uuid
|
|
|
|
)
|
2020-12-06 14:10:01 +08:00
|
|
|
|
|
|
|
url_list = (
|
|
|
|
[
|
|
|
|
"https://node.kg.qq.com/webapp/proxy?ns=KG_TASK&cmd=task.getLottery&ns_inbuf=&mapExt=JTdCJTIyZmlsZSUyMiUzQSUyMnRhc2tKY2UlMjIlMkMlMjJjbWROYW1lJTIyJTNBJTIyTG90dGVyeVJlcSUyMiUyQyUyMnduc0NvbmZpZyUyMiUzQSU3QiUyMmFwcGlkJTIyJTNBMTAwMDU1NyU3RCUyQyUyMmw1YXBpJTIyJTNBJTdCJTIybW9kaWQlMjIlM0E1MDM5MzclMkMlMjJjbWQlMjIlM0E1ODk4MjQlN0QlN0Q%3D&t_uid={0}&t_iShowEntry=1&t_type={1}".format(
|
|
|
|
t_uuid, one
|
|
|
|
)
|
|
|
|
for one in ["1", "2"]
|
|
|
|
]
|
|
|
|
+ [
|
|
|
|
"https://node.kg.qq.com/webapp/proxy?ns=KG_TASK&cmd=task.signinGetAward&mapExt=JTdCJTIyZmlsZSUyMiUzQSUyMnRhc2tKY2UlMjIlMkMlMjJjbWROYW1lJTIyJTNBJTIyR2V0U2lnbkluQXdhcmRSZXElMjIlMkMlMjJ3bnNDb25maWclMjIlM0ElN0IlMjJhcHBpZCUyMiUzQTEwMDA2MjYlN0QlMkMlMjJsNWFwaSUyMiUzQSU3QiUyMm1vZGlkJTIyJTNBNTAzOTM3JTJDJTIyY21kJTIyJTNBNTg5ODI0JTdEJTdE&t_uid={0}&t_iShowEntry={1}".format(
|
|
|
|
t_uuid, one
|
|
|
|
)
|
|
|
|
for one in ["1", "2", "4", "16", "128", "512"]
|
|
|
|
]
|
|
|
|
+ [
|
|
|
|
"https://node.kg.qq.com/webapp/proxy?ns=KG_TASK&cmd=task.getLottery&mapExt=JTdCJTIyZmlsZSUyMiUzQSUyMnRhc2tKY2UlMjIlMkMlMjJjbWROYW1lJTIyJTNBJTIyTG90dGVyeVJlcSUyMiUyQyUyMnduc0NvbmZpZyUyMiUzQSU3QiUyMmFwcGlkJTIyJTNBMTAwMDU1NyU3RCUyQyUyMmw1YXBpJTIyJTNBJTdCJTIybW9kaWQlMjIlM0E1MDM5MzclMkMlMjJjbWQlMjIlM0E1ODk4MjQlN0QlN0Q&t_uid={0}&t_iShowEntry=4&t_type=104".format(
|
|
|
|
t_uuid
|
|
|
|
),
|
|
|
|
"https://node.kg.qq.com/webapp/proxy?ns=KG_TASK&cmd=task.getLottery&mapExt=JTdCJTIyZmlsZSUyMiUzQSUyMnRhc2tKY2UlMjIlMkMlMjJjbWROYW1lJTIyJTNBJTIyTG90dGVyeVJlcSUyMiUyQyUyMmw1YXBpJTIyJTNBJTdCJTIybW9kaWQlMjIlM0E1MDM5MzclMkMlMjJjbWQlMjIlM0E1ODk4MjQlN0QlMkMlMjJsNWFwaV9leHAxJTIyJTNBJTdCJTIybW9kaWQlMjIlM0E4MTcwODklMkMlMjJjbWQlMjIlM0EzODAxMDg4JTdEJTdE&t_uid={0}&t_type=103".format(
|
|
|
|
t_uuid
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
proto_music_station_url = "https://node.kg.qq.com/webapp/proxy?ns=proto_music_station&cmd=message.batch_get_music_cards&mapExt=JTdCJTIyY21kTmFtZSUyMiUzQSUyMkdldEJhdGNoTXVzaWNDYXJkc1JlcSUyMiUyQyUyMmZpbGUlMjIlM0ElMjJwcm90b19tdXNpY19zdGF0aW9uSmNlJTIyJTJDJTIyd25zRGlzcGF0Y2hlciUyMiUzQXRydWUlN0Q&t_uUid={0}&g_tk_openkey=".format(
|
|
|
|
t_uuid
|
|
|
|
)
|
|
|
|
|
|
|
|
url_10 = "https://node.kg.qq.com/webapp/proxy?t_stReward%3Aobject=%7B%22uInteractiveType%22%3A1%2C%22uRewardType%22%3A0%2C%22uFlowerNum%22%3A15%7D&ns=proto_music_station&cmd=message.get_reward&mapExt=JTdCJTIyY21kTmFtZSUyMiUzQSUyMkdldFJld2FyZFJlcSUyMiUyQyUyMmZpbGUlMjIlM0ElMjJwcm90b19tdXNpY19zdGF0aW9uSmNlJTIyJTJDJTIyd25zRGlzcGF0Y2hlciUyMiUzQXRydWUlN0Q&t_uUid={0}&t_strUgcId=".format(
|
|
|
|
t_uuid
|
|
|
|
)
|
|
|
|
|
|
|
|
url_15 = "https://node.kg.qq.com/webapp/proxy?t_stReward%3Aobject=%7B%22uInteractiveType%22%3A0%2C%22uRewardType%22%3A0%2C%22uFlowerNum%22%3A10%7D&ns=proto_music_station&cmd=message.get_reward&mapExt=JTdCJTIyY21kTmFtZSUyMiUzQSUyMkdldFJld2FyZFJlcSUyMiUyQyUyMmZpbGUlMjIlM0ElMjJwcm90b19tdXNpY19zdGF0aW9uSmNlJTIyJTJDJTIyd25zRGlzcGF0Y2hlciUyMiUzQXRydWUlN0Q&t_uUid={0}&t_strUgcId=".format(
|
|
|
|
t_uuid
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
old_proto_profile_response = requests.get(url=proto_profile_url, headers=headers)
|
|
|
|
old_num = old_proto_profile_response.json()["data"]["profile.getProfile"]["uFlowerNum"]
|
|
|
|
|
|
|
|
for url in url_list:
|
2020-12-08 13:31:25 +08:00
|
|
|
try:
|
|
|
|
requests.get(url=url, headers=headers)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2020-12-06 14:10:01 +08:00
|
|
|
for g_tk_openkey in range(16):
|
2020-12-08 13:31:25 +08:00
|
|
|
try:
|
|
|
|
proto_music_station_resp = requests.get(
|
|
|
|
url=proto_music_station_url + str(g_tk_openkey), headers=headers
|
|
|
|
)
|
2021-02-07 17:10:57 +08:00
|
|
|
if proto_music_station_resp.json().get("code") in [1000]:
|
|
|
|
return proto_music_station_resp.json().get("msg")
|
2020-12-08 13:31:25 +08:00
|
|
|
vct_music_cards = proto_music_station_resp.json()["data"]["message.batch_get_music_cards"][
|
|
|
|
"vctMusicCards"
|
|
|
|
]
|
|
|
|
vct_music_cards_list = sorted(
|
|
|
|
vct_music_cards, key=lambda x: x["stReward"]["uFlowerNum"], reverse=True
|
|
|
|
)[0]
|
|
|
|
str_ugc_id = vct_music_cards_list["strUgcId"]
|
|
|
|
str_key = vct_music_cards_list["strKey"]
|
|
|
|
url = str_ugc_id + "&t_strKey=" + str_key
|
|
|
|
u_flower_num = vct_music_cards_list["stReward"]["uFlowerNum"]
|
|
|
|
if u_flower_num > 10:
|
|
|
|
requests.get(url=url_10 + url, headers=headers)
|
|
|
|
elif 1 < u_flower_num < 10:
|
|
|
|
requests.get(url=url_15 + url, headers=headers)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2020-12-06 14:10:01 +08:00
|
|
|
new_proto_profile_response = requests.get(proto_profile_url, headers=headers)
|
|
|
|
new_num = new_proto_profile_response.json()["data"]["profile.getProfile"]["uFlowerNum"]
|
|
|
|
get_num = int(new_num) - int(old_num)
|
|
|
|
if get_num == 0:
|
2020-12-15 12:48:50 +08:00
|
|
|
kg_message = f"今日鲜花已领取\n当前鲜花: {new_num}朵"
|
2020-12-06 14:10:01 +08:00
|
|
|
else:
|
2020-12-15 12:48:50 +08:00
|
|
|
kg_message = f"+{get_num}朵\n当前鲜花: {new_num}朵"
|
2020-12-06 14:10:01 +08:00
|
|
|
except Exception as e:
|
|
|
|
kg_message = str(e)
|
|
|
|
return kg_message
|
|
|
|
|
|
|
|
def main(self):
|
2020-12-07 13:29:36 +08:00
|
|
|
msg_list = []
|
2020-12-06 14:10:01 +08:00
|
|
|
for kgqq_cookie in self.kgqq_cookie_list:
|
|
|
|
kgqq_cookie = kgqq_cookie.get("kgqq_cookie")
|
|
|
|
msg = self.sign(kgqq_cookie=kgqq_cookie)
|
2020-12-23 10:20:13 +08:00
|
|
|
o_cookie = (
|
|
|
|
re.findall(r"o_cookie=(.*?);", kgqq_cookie)[0]
|
|
|
|
if re.findall(r"o_cookie=(.*?);", kgqq_cookie)
|
|
|
|
else "未获取到用户信息"
|
|
|
|
)
|
2020-12-07 13:29:36 +08:00
|
|
|
msg = f"【全民K歌签到】\n帐号信息: {o_cookie}\n获取鲜花: {msg}"
|
|
|
|
msg_list.append(msg)
|
|
|
|
return msg_list
|
2020-12-06 14:10:01 +08:00
|
|
|
|
|
|
|
|
2020-12-07 13:29:36 +08:00
|
|
|
if __name__ == "__main__":
|
2020-12-06 14:10:01 +08:00
|
|
|
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json"), "r", encoding="utf-8") as f:
|
2020-12-15 12:48:50 +08:00
|
|
|
datas = json.loads(f.read())
|
|
|
|
_kgqq_cookie_list = datas.get("KGQQ_COOKIE_LIST", [])
|
2020-12-07 13:29:36 +08:00
|
|
|
KGQQCheckIn(kgqq_cookie_list=_kgqq_cookie_list).main()
|