|
|
@ -10,6 +10,8 @@ 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 |
|
|
@ -138,7 +140,7 @@ class BiliBili(): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def space_arc_search( |
|
|
|
def space_arc_search( |
|
|
|
session, uid: int, pn: int = 1, ps: int = 30, tid: int = 0, order: str = "pubdate", keyword: str = "" |
|
|
|
session, uid: int, pn: int = 1, ps: int = 100, tid: int = 0, order: str = "pubdate", keyword: str = "" |
|
|
|
) -> dict: |
|
|
|
) -> dict: |
|
|
|
""" |
|
|
|
""" |
|
|
|
获取指定up主空间视频投稿信息 |
|
|
|
获取指定up主空间视频投稿信息 |
|
|
@ -152,19 +154,18 @@ 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", [])[:count] |
|
|
|
for one in ret.get("data", {}).get("list", {}).get("vlist", []) |
|
|
|
] |
|
|
|
] |
|
|
|
return data_list, count |
|
|
|
return data_list |
|
|
|
|
|
|
|
|
|
|
|
@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: |
|
|
@ -234,20 +235,11 @@ 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( |
|
|
@ -263,27 +255,17 @@ 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) if coin_type == 0 else [] |
|
|
|
aid_list = self.get_region(session=session) |
|
|
|
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: |
|
|
|
if coin_type == 1 and coin_num: |
|
|
|
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: |
|
|
|
tmplist, tmpcount = self.space_arc_search(session=session, uid=mid) |
|
|
|
aid_list += 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) |
|
|
@ -318,11 +300,6 @@ 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) |
|
|
@ -340,7 +317,6 @@ 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}, |
|
|
|