diff --git a/dailycheckin_scripts/ck_bilibili.py b/dailycheckin_scripts/ck_bilibili.py index 924f522..ba20685 100644 --- a/dailycheckin_scripts/ck_bilibili.py +++ b/dailycheckin_scripts/ck_bilibili.py @@ -10,8 +10,6 @@ from utils import check class BiliBili(): - name = "Bilibili" - # TODO 待测试,需要大会员账号测试领取福利 def __init__(self, check_item: dict): self.check_item = check_item @@ -117,7 +115,7 @@ class BiliBili(): @staticmethod def get_followings( - session, uid: int, pn: int = 1, ps: int = 50, order: str = "desc", order_type: str = "attention" + session, uid: int, pn: int = 1, ps: int = 50, order: str = "desc", order_type: str = "attention" ) -> dict: """ 获取指定用户关注的up主 @@ -140,7 +138,7 @@ class BiliBili(): @staticmethod def space_arc_search( - session, uid: int, pn: int = 1, ps: int = 100, tid: int = 0, order: str = "pubdate", keyword: str = "" + session, uid: int, pn: int = 1, ps: int = 30, tid: int = 0, order: str = "pubdate", keyword: str = "" ) -> dict: """ 获取指定up主空间视频投稿信息 @@ -154,18 +152,19 @@ class BiliBili(): params = { "mid": uid, "pn": pn, - "ps": ps, + "Ps": ps, "tid": tid, "order": order, "keyword": keyword, } url = f"https://api.bilibili.com/x/space/arc/search" ret = session.get(url=url, params=params).json() + count = 2 data_list = [ {"aid": one.get("aid"), "cid": 0, "title": one.get("title"), "owner": one.get("author")} - for one in ret.get("data", {}).get("list", {}).get("vlist", []) + for one in ret.get("data", {}).get("list", {}).get("vlist", [])[:count] ] - return data_list + return data_list, count @staticmethod def elec_pay(session, bili_jct, uid: int, num: int = 50) -> dict: @@ -235,11 +234,20 @@ class BiliBili(): ] return data_list + @staticmethod + def silver2coin(session, bili_jct) -> dict: + """B站银瓜子换硬币""" + url = "https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin" + post_data = {"csrf": bili_jct} + ret = session.post(url=url, data=post_data).json() + return ret + def main(self): bilibili_cookie = {item.split("=")[0]: item.split("=")[1] for item in self.check_item.get("cookie").split("; ")} bili_jct = bilibili_cookie.get("bili_jct") coin_num = self.check_item.get("coin_num", 0) coin_type = self.check_item.get("coin_type", 1) + silver2coin = self.check_item.get("silver2coin", False) session = requests.session() requests.utils.add_dict_to_cookiejar(session.cookies, bilibili_cookie) session.headers.update( @@ -255,17 +263,27 @@ class BiliBili(): if is_login: manhua_msg = self.manga_sign(session=session) live_msg = self.live_sign(session=session) - aid_list = self.get_region(session=session) + aid_list = self.get_region(session=session) if coin_type == 0 else [] reward_ret = self.reward(session=session) coins_av_count = reward_ret.get("data", {}).get("coins_av") // 10 coin_num = coin_num - coins_av_count coin_num = coin_num if coin_num < coin else coin - if coin_type == 1 and coin_num: + if coin_type == 1: following_list = self.get_followings(session=session, uid=uid) + count = 0 for following in following_list.get("data", {}).get("list"): mid = following.get("mid") if mid: - aid_list += self.space_arc_search(session=session, uid=mid) + tmplist, tmpcount = self.space_arc_search(session=session, uid=mid) + aid_list += tmplist + count += tmpcount + if count > coin_num: + print("已获取足够关注用户的视频") + break + else: + aid_list += self.get_region(session=session) + for one in aid_list[::-1]: + print(one) if coin_num > 0: for aid in aid_list[::-1]: ret = self.coin_add(session=session, aid=aid.get("aid"), bili_jct=bili_jct) @@ -300,6 +318,11 @@ class BiliBili(): else: share_msg = f"分享失败" print(share_msg) + if silver2coin: + silver2coin_ret = self.silver2coin(session=session, bili_jct=bili_jct) + s2c_msg = silver2coin_ret["message"] + if silver2coin_ret["code"] != 0: + print(s2c_msg) live_stats = self.live_status(session=session) uname, uid, is_login, new_coin, vip_type, new_current_exp = self.get_nav(session=session) reward_ret = self.reward(session=session) @@ -317,6 +340,7 @@ class BiliBili(): {"name": "登陆任务", "value": "今日已登陆"}, {"name": "观看视频", "value": report_msg}, {"name": "分享任务", "value": share_msg}, + {"name": "瓜子兑换", "value": s2c_msg}, {"name": "投币任务", "value": coin_msg}, {"name": "今日经验", "value": today_exp}, {"name": "当前经验", "value": new_current_exp}, diff --git a/dailycheckin_scripts/ck_duokan.py b/dailycheckin_scripts/ck_duokan.py index 09780f8..d6b7baf 100644 --- a/dailycheckin_scripts/ck_duokan.py +++ b/dailycheckin_scripts/ck_duokan.py @@ -245,6 +245,12 @@ class DuoKan: msg = {"name": "每日签到", "value": result.get("msg")} return msg + def delay(self, cookies, date): + url = "https://www.duokan.com/store/v0/award/coin/delay" + data = f"date={date}&{self.get_data(cookies=cookies)}&withid=1" + ret = requests.post(url=url, data=data, cookies=cookies, headers=self.headers).json() + return ret + def info(self, cookies): url = "https://www.duokan.com/store/v0/award/coin/list" data = f"sandbox=0&{self.get_data(cookies=cookies)}&withid=1" @@ -254,10 +260,14 @@ class DuoKan: if "尚未登录" not in result.get("msg"): coin = sum([one.get("coin") for one in result.get("data", {}).get("award")]) msg.append({"name": "当前书豆", "value": coin}) - msg += [ - {"name": f"{one.get('expire')} 到期", "value": f"{one.get('coin')} 书豆"} - for one in result.get("data", {}).get("award") - ] + for one in result.get("data", {}).get("award"): + if one.get("delay") == 1: + ret = self.delay(cookies, one.get("expire")) + msg.append( + {"name": f"{one.get('expire')} 到期", "value": f"{one.get('coin')} 书豆 | 延期:{ret.get('msg')}"} + ) + else: + msg.append({"name": f"{one.get('expire')} 到期", "value": f"{one.get('coin')} 书豆"}) return msg else: return [{"name": "账号异常", "value": "Cookie 失效"}] @@ -296,7 +306,7 @@ class DuoKan: num += 30 print("体验任务完成啦!豆子 +30") else: - print(result.get("data")) + continue msg = {"name": "体验任务", "value": f"获得 {num} 豆子"} else: msg = {"name": "体验任务", "value": f"{response.text}"} @@ -329,20 +339,26 @@ class DuoKan: def download(self, cookies): url = "https://www.duokan.com/events/common_task_gift" data = f"code=J18UK6YYAY&chances=17&{self.get_data(cookies=cookies)}&withid=1" - response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers) - result = response.json() - msg = {"name": "下载任务", "value": result.get("msg")} + count = 0 + while True: + response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers) + result = response.json() + if result.get("result") == 130014: + break + count += 1 + msg = {"name": "下载任务", "value": f"完成 {count} 次"} return msg def task(self, cookies): success_count = 0 url = "https://www.duokan.com/events/tasks_gift" - for code in self.code_list: - data = f"code={code}&chances=3&{self.get_data(cookies=cookies)}&withid=1" - response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers) - result = response.json() - if result.get("result") == 0: - success_count += 1 + for i in range(3): + for code in self.code_list: + data = f"code={code}&chances=3&{self.get_data(cookies=cookies)}&withid=1" + response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers) + result = response.json() + if result.get("result") == 0: + success_count += 1 msg = {"name": "其他任务", "value": f"完成 {success_count} 个"} return msg diff --git a/dailycheckin_scripts/ck_iqiyi.py b/dailycheckin_scripts/ck_iqiyi.py index 90dbf6d..ab7598d 100644 --- a/dailycheckin_scripts/ck_iqiyi.py +++ b/dailycheckin_scripts/ck_iqiyi.py @@ -6,6 +6,7 @@ import json import re import time from urllib.parse import unquote +import hashlib import requests @@ -23,7 +24,21 @@ class IQIYI: p00001 = re.findall(r"P00001=(.*?);", cookie)[0] if re.findall(r"P00001=(.*?);", cookie) else "" p00002 = re.findall(r"P00002=(.*?);", cookie)[0] if re.findall(r"P00002=(.*?);", cookie) else "" p00003 = re.findall(r"P00003=(.*?);", cookie)[0] if re.findall(r"P00003=(.*?);", cookie) else "" - return p00001, p00002, p00003 + dfp = re.findall(r"dfp=(.*?);", cookie)[0] if re.findall(r"dfp=(.*?);", cookie) else "" + return p00001, p00002, p00003, dfp + + @staticmethod + def md5(data): + return hashlib.md5(bytes(data, encoding="utf-8")).hexdigest() + + def get_sign(self, c, t, e=None): + buf = [] + for key, value in t.items(): + buf.append("=".join([key, str(value)])) + if e is not None: + buf.append(e) + return self.md5(c.join(buf)) + return c.join(buf) @staticmethod def user_information(p00001): @@ -70,17 +85,86 @@ class IQIYI: res = requests.get(url=url, params=params).json() if res["code"] == "A00000": try: - growth = res["data"]["signInfo"]["data"]["rewardMap"]["growth"] - cumulate_sign_days_sum = res["data"]["signInfo"]["data"]["cumulateSignDaysSum"] + cumulate_sign_days_sum = res["data"]["monthlyGrowthReward"] msg = [ - {"name": "签到奖励", "value": f"{growth}成长值"}, - {"name": "当月签到", "value": f"{cumulate_sign_days_sum}天"}, + {"name": "当月成长", "value": f"{cumulate_sign_days_sum}成长值"}, ] except Exception as e: print(e) - msg = [{"name": "签到奖励", "value": res["data"]["signInfo"].get("msg")}] + msg = [{"name": "当月成长", "value": str(e)}] + else: + msg = [{"name": "当月成长", "value": res.get("msg")}] + return msg + + def sign2(self, p00001, p00003): + sign_date = { + "agentType": "1", + "agentversion": "1.0", + "appKey": "basic_pcw", + "authCookie": p00001, + "qyid": self.md5("".join(random.sample(string.ascii_letters + string.digits, 16))), + "task_code": "natural_month_sign", + "timestamp": round(time.time() * 1000), + "typeCode": "point", + "userId": p00003, + } + post_date = { + "natural_month_sign": { + "agentType": "1", + "agentversion": "1", + "authCookie": p00001, + "qyid": self.md5("".join(random.sample(string.ascii_letters + string.digits, 16))), + "taskCode": "iQIYI_mofhr", + "verticalCode": "iQIYI", + } + } + sign = self.get_sign("|", sign_date, "UKobMjDMsDoScuWOfp6F") + url = f"https://community.iqiyi.com/openApi/task/execute?{self.get_sign('&', sign_date)}&sign={sign}" + header = {"Content-Type": "application/json"} + res = requests.post(url, headers=header, data=json.dumps(post_date)).json() + if res["code"] == "A00000": + if res["data"]["code"] == "A0000": + # quantity = res["data"]["data"]["rewards"][0]["rewardCount"] # 积分 + # addgrowthvalue = res["data"]["data"]["rewards"][0]["rewardCount"] # 新增成长值 + # continued = res["data"]["data"]["signDays"] # 签到天数 + msg = [{"name": "APP 签到", "value": "签到成功"}] + else: + msg = [{"name": "APP 签到", "value": f"签到失败:{res['data']['msg']}"}] + else: + msg = [{"name": "APP 签到", "value": f"签到失败:{res['message']}"}] + return msg + + def web_sign(self, p00001, p00003, dfp): + dfp = dfp.split("@")[0] + web_sign_date = { + "agenttype": "1", + "agentversion": "0", + "appKey": "basic_pca", + "appver": "0", + "authCookie": p00001, + "channelCode": "sign_pcw", + "dfp": dfp, + "scoreType": "1", + "srcplatform": "1", + "typeCode": "point", + "userId": p00003, + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36", + "verticalCode": "iQIYI", + } + + sign = self.get_sign("|", web_sign_date, "DO58SzN6ip9nbJ4QkM8H") + url = f"https://community.iqiyi.com/openApi/score/add?{self.get_sign('&', web_sign_date)}&sign={sign}" + res = requests.get(url).json() + if res["code"] == "A00000": + if res["data"][0]["code"] == "A0000": + quantity = res["data"][0]["score"] + continued = res["data"][0]["continuousValue"] + msg = [{"name": "WEB 签到", "value": f"积分+{quantity} 累计签到{continued}天"}] + + else: + msg = [{"name": "WEB 签到", "value": f"网页端签到失败:{res['data'][0]['message']}"}] else: - msg = [{"name": "签到奖励", "value": res.get("msg")}] + msg = [{"name": "WEB 签到", "value": f"网页端签到失败:{res['message']}"}] return msg @staticmethod @@ -180,8 +264,10 @@ class IQIYI: return {"status": False, "msg": msg, "chance": 0} def main(self): - p00001, p00002, p00003 = self.parse_cookie(self.check_item.get("cookie")) + p00001, p00002, p00003, dfp = self.parse_cookie(self.check_item.get("cookie")) sign_msg = self.sign(p00001=p00001) + web_sign_msg = self.web_sign(p00001=p00001, p00003=p00003, dfp=dfp) + sign2_msg = self.sign2(p00001=p00001, p00003=p00003) chance = self.draw(0, p00001=p00001, p00003=p00003)["chance"] if chance: draw_msg = "" @@ -214,6 +300,8 @@ class IQIYI: ] + user_msg + sign_msg + + web_sign_msg + + sign2_msg + [ task_msg, {"name": "抽奖奖励", "value": draw_msg},