Browse Source

更新上游代码

pull/15/head
yuxian 3 years ago
parent
commit
f9f02e50a5
  1. 44
      dailycheckin_scripts/ck_bilibili.py
  2. 44
      dailycheckin_scripts/ck_duokan.py
  3. 104
      dailycheckin_scripts/ck_iqiyi.py

44
dailycheckin_scripts/ck_bilibili.py

@ -10,8 +10,6 @@ from utils import check
class BiliBili(): class BiliBili():
name = "Bilibili"
# TODO 待测试,需要大会员账号测试领取福利 # TODO 待测试,需要大会员账号测试领取福利
def __init__(self, check_item: dict): def __init__(self, check_item: dict):
self.check_item = check_item self.check_item = check_item
@ -117,7 +115,7 @@ class BiliBili():
@staticmethod @staticmethod
def get_followings( 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: ) -> dict:
""" """
获取指定用户关注的up主 获取指定用户关注的up主
@ -140,7 +138,7 @@ class BiliBili():
@staticmethod @staticmethod
def space_arc_search( 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: ) -> dict:
""" """
获取指定up主空间视频投稿信息 获取指定up主空间视频投稿信息
@ -154,18 +152,19 @@ class BiliBili():
params = { params = {
"mid": uid, "mid": uid,
"pn": pn, "pn": pn,
"ps": ps, "Ps": ps,
"tid": tid, "tid": tid,
"order": order, "order": order,
"keyword": keyword, "keyword": keyword,
} }
url = f"https://api.bilibili.com/x/space/arc/search" url = f"https://api.bilibili.com/x/space/arc/search"
ret = session.get(url=url, params=params).json() ret = session.get(url=url, params=params).json()
count = 2
data_list = [ data_list = [
{"aid": one.get("aid"), "cid": 0, "title": one.get("title"), "owner": one.get("author")} {"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 @staticmethod
def elec_pay(session, bili_jct, uid: int, num: int = 50) -> dict: def elec_pay(session, bili_jct, uid: int, num: int = 50) -> dict:
@ -235,11 +234,20 @@ class BiliBili():
] ]
return data_list 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): def main(self):
bilibili_cookie = {item.split("=")[0]: item.split("=")[1] for item in self.check_item.get("cookie").split("; ")} bilibili_cookie = {item.split("=")[0]: item.split("=")[1] for item in self.check_item.get("cookie").split("; ")}
bili_jct = bilibili_cookie.get("bili_jct") bili_jct = bilibili_cookie.get("bili_jct")
coin_num = self.check_item.get("coin_num", 0) coin_num = self.check_item.get("coin_num", 0)
coin_type = self.check_item.get("coin_type", 1) coin_type = self.check_item.get("coin_type", 1)
silver2coin = self.check_item.get("silver2coin", False)
session = requests.session() session = requests.session()
requests.utils.add_dict_to_cookiejar(session.cookies, bilibili_cookie) requests.utils.add_dict_to_cookiejar(session.cookies, bilibili_cookie)
session.headers.update( session.headers.update(
@ -255,17 +263,27 @@ class BiliBili():
if is_login: if is_login:
manhua_msg = self.manga_sign(session=session) manhua_msg = self.manga_sign(session=session)
live_msg = self.live_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) reward_ret = self.reward(session=session)
coins_av_count = reward_ret.get("data", {}).get("coins_av") // 10 coins_av_count = reward_ret.get("data", {}).get("coins_av") // 10
coin_num = coin_num - coins_av_count coin_num = coin_num - coins_av_count
coin_num = coin_num if coin_num < coin else coin 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) following_list = self.get_followings(session=session, uid=uid)
count = 0
for following in following_list.get("data", {}).get("list"): for following in following_list.get("data", {}).get("list"):
mid = following.get("mid") mid = following.get("mid")
if 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: if coin_num > 0:
for aid in aid_list[::-1]: for aid in aid_list[::-1]:
ret = self.coin_add(session=session, aid=aid.get("aid"), bili_jct=bili_jct) ret = self.coin_add(session=session, aid=aid.get("aid"), bili_jct=bili_jct)
@ -300,6 +318,11 @@ class BiliBili():
else: else:
share_msg = f"分享失败" share_msg = f"分享失败"
print(share_msg) 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) live_stats = self.live_status(session=session)
uname, uid, is_login, new_coin, vip_type, new_current_exp = self.get_nav(session=session) uname, uid, is_login, new_coin, vip_type, new_current_exp = self.get_nav(session=session)
reward_ret = self.reward(session=session) reward_ret = self.reward(session=session)
@ -317,6 +340,7 @@ class BiliBili():
{"name": "登陆任务", "value": "今日已登陆"}, {"name": "登陆任务", "value": "今日已登陆"},
{"name": "观看视频", "value": report_msg}, {"name": "观看视频", "value": report_msg},
{"name": "分享任务", "value": share_msg}, {"name": "分享任务", "value": share_msg},
{"name": "瓜子兑换", "value": s2c_msg},
{"name": "投币任务", "value": coin_msg}, {"name": "投币任务", "value": coin_msg},
{"name": "今日经验", "value": today_exp}, {"name": "今日经验", "value": today_exp},
{"name": "当前经验", "value": new_current_exp}, {"name": "当前经验", "value": new_current_exp},

44
dailycheckin_scripts/ck_duokan.py

@ -245,6 +245,12 @@ class DuoKan:
msg = {"name": "每日签到", "value": result.get("msg")} msg = {"name": "每日签到", "value": result.get("msg")}
return 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): def info(self, cookies):
url = "https://www.duokan.com/store/v0/award/coin/list" url = "https://www.duokan.com/store/v0/award/coin/list"
data = f"sandbox=0&{self.get_data(cookies=cookies)}&withid=1" data = f"sandbox=0&{self.get_data(cookies=cookies)}&withid=1"
@ -254,10 +260,14 @@ class DuoKan:
if "尚未登录" not in result.get("msg"): if "尚未登录" not in result.get("msg"):
coin = sum([one.get("coin") for one in result.get("data", {}).get("award")]) coin = sum([one.get("coin") for one in result.get("data", {}).get("award")])
msg.append({"name": "当前书豆", "value": coin}) msg.append({"name": "当前书豆", "value": coin})
msg += [ for one in result.get("data", {}).get("award"):
{"name": f"{one.get('expire')} 到期", "value": f"{one.get('coin')} 书豆"} if one.get("delay") == 1:
for one in result.get("data", {}).get("award") 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 return msg
else: else:
return [{"name": "账号异常", "value": "Cookie 失效"}] return [{"name": "账号异常", "value": "Cookie 失效"}]
@ -296,7 +306,7 @@ class DuoKan:
num += 30 num += 30
print("体验任务完成啦!豆子 +30") print("体验任务完成啦!豆子 +30")
else: else:
print(result.get("data")) continue
msg = {"name": "体验任务", "value": f"获得 {num} 豆子"} msg = {"name": "体验任务", "value": f"获得 {num} 豆子"}
else: else:
msg = {"name": "体验任务", "value": f"{response.text}"} msg = {"name": "体验任务", "value": f"{response.text}"}
@ -329,20 +339,26 @@ class DuoKan:
def download(self, cookies): def download(self, cookies):
url = "https://www.duokan.com/events/common_task_gift" url = "https://www.duokan.com/events/common_task_gift"
data = f"code=J18UK6YYAY&chances=17&{self.get_data(cookies=cookies)}&withid=1" 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) count = 0
result = response.json() while True:
msg = {"name": "下载任务", "value": result.get("msg")} 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 return msg
def task(self, cookies): def task(self, cookies):
success_count = 0 success_count = 0
url = "https://www.duokan.com/events/tasks_gift" url = "https://www.duokan.com/events/tasks_gift"
for code in self.code_list: for i in range(3):
data = f"code={code}&chances=3&{self.get_data(cookies=cookies)}&withid=1" for code in self.code_list:
response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers) data = f"code={code}&chances=3&{self.get_data(cookies=cookies)}&withid=1"
result = response.json() response = requests.post(url=url, data=data, cookies=cookies, headers=self.headers)
if result.get("result") == 0: result = response.json()
success_count += 1 if result.get("result") == 0:
success_count += 1
msg = {"name": "其他任务", "value": f"完成 {success_count}"} msg = {"name": "其他任务", "value": f"完成 {success_count}"}
return msg return msg

104
dailycheckin_scripts/ck_iqiyi.py

@ -6,6 +6,7 @@ import json
import re import re
import time import time
from urllib.parse import unquote from urllib.parse import unquote
import hashlib
import requests import requests
@ -23,7 +24,21 @@ class IQIYI:
p00001 = re.findall(r"P00001=(.*?);", cookie)[0] if re.findall(r"P00001=(.*?);", cookie) else "" 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 "" 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 "" 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 @staticmethod
def user_information(p00001): def user_information(p00001):
@ -70,17 +85,86 @@ class IQIYI:
res = requests.get(url=url, params=params).json() res = requests.get(url=url, params=params).json()
if res["code"] == "A00000": if res["code"] == "A00000":
try: try:
growth = res["data"]["signInfo"]["data"]["rewardMap"]["growth"] cumulate_sign_days_sum = res["data"]["monthlyGrowthReward"]
cumulate_sign_days_sum = res["data"]["signInfo"]["data"]["cumulateSignDaysSum"]
msg = [ msg = [
{"name": "签到奖励", "value": f"{growth}成长值"}, {"name": "当月成长", "value": f"{cumulate_sign_days_sum}成长值"},
{"name": "当月签到", "value": f"{cumulate_sign_days_sum}"},
] ]
except Exception as e: except Exception as e:
print(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: else:
msg = [{"name": "签到奖励", "value": res.get("msg")}] msg = [{"name": "WEB 签到", "value": f"网页端签到失败:{res['message']}"}]
return msg return msg
@staticmethod @staticmethod
@ -180,8 +264,10 @@ class IQIYI:
return {"status": False, "msg": msg, "chance": 0} return {"status": False, "msg": msg, "chance": 0}
def main(self): 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) 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"] chance = self.draw(0, p00001=p00001, p00003=p00003)["chance"]
if chance: if chance:
draw_msg = "" draw_msg = ""
@ -214,6 +300,8 @@ class IQIYI:
] ]
+ user_msg + user_msg
+ sign_msg + sign_msg
+ web_sign_msg
+ sign2_msg
+ [ + [
task_msg, task_msg,
{"name": "抽奖奖励", "value": draw_msg}, {"name": "抽奖奖励", "value": draw_msg},

Loading…
Cancel
Save