async def sliver2coin(self): if self.task_control['silver2coin']: # 403 done json_response1 = await self.webhub.silver2coin_app() # -403 done json_response = await self.webhub.silver2coin_web() self.printer_with_id([f'# {json_response["msg"]}']) self.printer_with_id([f'# {json_response1["msg"]}']) if json_response['code'] == -403 and '只' in json_response['msg']: finish_web = True else: finish_web = False if json_response1['code'] == 403 and '最多' in json_response1['msg']: finish_app = True else: finish_app = False if finish_app and finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) await Task().put2queue('sliver2coin', sleeptime, self.user_id) return else: await Task().put2queue('sliver2coin', 350, self.user_id) return await Task().put2queue('sliver2coin', 21600, self.user_id)
async def open_silver_box(user): while True: user.infos(["检查宝箱状态"]) temp = await user.req_s(OpenSilverBoxReq.check_time, user) # print (temp['code']) #宝箱领完返回的code为-10017 if temp['code'] == -10017: user.infos(["今日宝箱领取完毕"]) json_rsp = None else: time_start = temp['data']['time_start'] time_end = temp['data']['time_end'] json_rsp = await user.req_s(OpenSilverBoxReq.open_silver_box, user, time_start, time_end) if json_rsp is None or json_rsp['code'] == -10017 or json_rsp[ 'code'] == -800: sleeptime = utils.seconds_until_tomorrow() + 300 return (0, (sleeptime, sleeptime + 30), user.id), elif not json_rsp['code']: user.infos(["打开了宝箱"]) elif json_rsp['code'] == 400: user.infos(["宝箱开启中返回了小黑屋提示"]) user.fall_in_jail() # 马上继续调用,由下一次的user去supend这个task return (0, (0, 0), user.id), else: user.infos(["继续等待宝箱冷却..."]) sleeptime = (json_rsp['data'].get('surplus', 3)) * 60 + 5 return (0, (sleeptime, sleeptime + 30), user.id),
async def sliver2coin(): if ConfigLoader().dic_user['task_control']['silver2coin']: # 403 done json_response1 = await bilibili.silver2coin_app() # -403 done json_response = await bilibili.silver2coin_web() Printer().printlist_append( ['join_lottery', '', 'user', "# ", json_response['msg']]) Printer().printlist_append( ['join_lottery', '', 'user', "# ", json_response1['msg']]) if json_response['code'] == -403 and '只' in json_response['msg']: finish_web = True else: finish_web = False if json_response1['code'] == 403 and '最多' in json_response1['msg']: finish_app = True else: finish_app = False if finish_app and finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) await BiliTimer.append2list_jobs(sliver2coin, sleeptime) return else: await BiliTimer.append2list_jobs(sliver2coin, 350) return await BiliTimer.append2list_jobs(sliver2coin, 21600)
async def open_silver_box(self): while True: self.printer_with_id(["检查宝箱状态"], True) temp = await self.webhub.get_time_about_silver() # print (temp['code']) #宝箱领完返回的code为-10017 if temp['code'] == -10017: self.printer_with_id(["# 今日宝箱领取完毕"]) json_rsp = None else: time_start = temp['data']['time_start'] time_end = temp['data']['time_end'] json_rsp = await self.webhub.get_silver(time_start, time_end) if json_rsp is None or json_rsp['code'] == -10017: sleeptime = (utils.seconds_until_tomorrow() + 300) await Task().put2queue('open_silver_box', sleeptime, self.user_id) break # await asyncio.sleep(sleeptime) elif not json_rsp['code']: self.printer_with_id(["# 打开了宝箱"]) elif json_rsp['code'] == 400: self.printer_with_id(["# 宝箱开启中返回了小黑屋提示"]) self.fall_in_jail() break else: self.printer_with_id(["# 继续等待宝箱冷却..."]) # 未来如果取消了这个东西就睡眠185s,否则精确睡眠 # surplus里面是min,float格式 try: sleeptime = (json_rsp['data'].get('surplus', 3)) * 60 + 5 except : sleeptime = 180 print(json_rsp) await Task().put2queue('open_silver_box', sleeptime, self.user_id) break
async def run(): while True: printer.info(["检查宝箱状态"], True) json_rsp = await GetAward() if json_rsp is None or json_rsp['code'] == -10017: sleeptime = (utils.seconds_until_tomorrow() + 300) await asyncio.sleep(sleeptime) elif not json_rsp['code']: printer.info(["# 打开了宝箱"]) elif json_rsp['code'] == 400: print('小黑屋') await asyncio.sleep(3600) continue print('小黑屋, 暴力测试中') tasklist = [] for i in range(60): task = asyncio.ensure_future(GetAward_black()) tasklist.append(task) await asyncio.wait(tasklist, return_when=asyncio.FIRST_COMPLETED) json_rsp = await GetAward() sleeptime = 3 * 60 + 5 await asyncio.sleep(sleeptime) else: printer.info(["# 继续等待宝箱冷却..."]) # 未来如果取消了这个东西就睡眠185s,否则精确睡眠 # surplus里面是min,float格式 sleeptime = (json_rsp['data'].get('surplus', 3)) * 60 + 5 await asyncio.sleep(sleeptime)
async def sliver2coin(): if ConfigLoader().dic_user['task_control']['silver2coin']: # 403 done json_response1 = await bilibili.silver2coin_app() # -403 done json_response = await bilibili.silver2coin_web() printer.info([f'# {json_response["msg"]}']) printer.info([f'# {json_response1["msg"]}']) if json_response['code'] == -403 and '只' in json_response['msg']: finish_web = True else: finish_web = False if json_response1['code'] == 403 and '最多' in json_response1['msg']: finish_app = True else: finish_app = False if finish_app and finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) BiliTimer.call_after(sliver2coin, sleeptime) return else: BiliTimer.call_after(sliver2coin, 350) return BiliTimer.call_after(sliver2coin, 21600)
async def finish_bilimain_tasks(user): login, watch_av, num, share_av = await BiliMainTask.fetch_bilimain_tasks( user) if user.task_ctrl['fetchrule'] == 'bilitop': aids = await BiliMainTask.fetch_top_videos(user) # print(list_topvideo) else: aids = await BiliMainTask.fetch_uper_videos( user, user.task_ctrl['mid']) while True: aid = random.choice(aids) cid = await BiliMainTask.aid2cid(user, aid) if cid is not None: break if (not login) or not watch_av: await BiliMainTask.heartbeat(user, aid, cid) if not share_av: await BiliMainTask.share_video(user, aid) coin_set = min(user.task_ctrl['givecoin'], 5) num_coin = coin_set - num / 10 if num_coin: await BiliMainTask.send_coin(user, num_coin, aids) # b站傻逼有记录延迟,3点左右成功率高一点 sleeptime = utils.seconds_until_tomorrow() + 10800 return (0, (sleeptime, sleeptime + 30), user.id),
async def sign(user): json_rsp = await user.req_s(SignReq.sign, user) user.infos([f'签到状态: {json_rsp["msg"]}']) if json_rsp['code'] == -500 and '已' in json_rsp['msg']: sleeptime = utils.seconds_until_tomorrow() + 300 else: sleeptime = 350 return (0, (sleeptime, sleeptime + 30), user.id),
async def watch_tv(user): # -400 done/not yet json_rsp = await user.req_s(WatchTvReq.watch_tv, user) user.infos([f'双端观看直播: {json_rsp["msg"]}']) if json_rsp['code'] == -400 and '已' in json_rsp['msg']: sleeptime = utils.seconds_until_tomorrow() + 300 else: sleeptime = 350 return (0, (sleeptime, sleeptime + 30), user.id),
async def DoSign(): # -500 done temp = await OnlineNet().req('get_dosign') printer.info([f'# 签到状态: {temp["msg"]}']) if temp['code'] == -500 and '已' in temp['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 BiliTimer.call_after(DoSign, sleeptime)
async def Daily_Task(self): # -400 done/not yet json_response2 = await self.online_request(self.webhub.get_dailytask) self.printer_with_id([f'# 双端观看直播: {json_response2["msg"]}']) if json_response2['code'] == -400 and '已' in json_response2['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 return sleeptime
async def DoSign(self): # -500 done temp = await self.online_request(self.webhub.get_dosign) self.printer_with_id([f'# 签到状态: {temp["msg"]}']) if temp['code'] == -500 and '已' in temp['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 return sleeptime
async def DoSign(self): # -500 done temp = await self.webhub.get_dosign() self.printer_with_id([f'# 签到状态: {temp["msg"]}']) if temp['code'] == -500 and '已' in temp['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 await Task().put2queue('DoSign', sleeptime, self.user_id)
async def Daily_Task(): # -400 done/not yet json_response2 = await OnlineNet().req('get_dailytask') printer.info([f'# 双端观看直播: {json_response2["msg"]}']) if json_response2['code'] == -400 and '已' in json_response2['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 BiliTimer.call_after(Daily_Task, sleeptime)
async def Daily_Task(self): # -400 done/not yet json_response2 = await self.webhub.get_dailytask() self.printer_with_id([f'# 双端观看直播: {json_response2["msg"]}']) if json_response2['code'] == -400 and '已' in json_response2['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 await Task().put2queue('Daily_Task', sleeptime, self.user_id)
async def DoSign(): # -500 done temp = await bilibili.get_dosign() printer.warn(temp) printer.info([f'# 签到状态: {temp["msg"]}']) if temp['code'] == -500 and '已' in temp['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 await BiliTimer.append2list_jobs(DoSign, sleeptime)
async def Daily_Task(): # -400 done/not yet json_response2 = await bilibili.get_dailytask() printer.warn(json_response2) printer.info([f'# 双端观看直播: {json_response2["msg"]}']) if json_response2['code'] == -400 and '已' in json_response2['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) else: sleeptime = 350 await BiliTimer.append2list_jobs(Daily_Task, sleeptime)
async def DoSign(): # -500 done temp = await bilibili.get_dosign() # print('DoSign', temp) Printer().printlist_append( ['join_lottery', '', 'user', "# 签到状态:", temp['msg']]) if temp['code'] == -500 and '已' in temp['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) await BiliTimer.append2list_jobs(DoSign, sleeptime) else: await BiliTimer.append2list_jobs(DoSign, 350)
async def initiate_send_gift(): # 每天结束前两分钟左右刷礼物,如果调用时间在最后两分钟内,立刻送礼物 # - 随即范围:3分钟 - 1分30秒 # - 通常情况下,本机时间和破站服务器时间不会相差太大 # - 保险起见应该 1000 秒 (16分种) ->(NTP允许的最大正常情况下的时间偏移) # - 但是这段时间很可能会手动刷金瓜子礼物,为了避免浪费亲密度,选择更少的提前量 time_to_end_of_day = max( 0, utils.seconds_until_tomorrow() - random.randint(90, 180)) printer.info([f'辣条机:{time_to_end_of_day} 秒后 - 倒辣条']) BiliTimer.call_after(send_gift, time_to_end_of_day)
async def Daily_Task(): # -400 done/not yet json_response2 = await bilibili.get_dailytask() Printer().printlist_append( ['join_lottery', '', 'user', "# 双端观看直播:", json_response2["msg"]]) # print('Daily_Task', json_response2) if json_response2['code'] == -400 and '已' in json_response2['msg']: sleeptime = (utils.seconds_until_tomorrow() + 300) await BiliTimer.append2list_jobs(Daily_Task, sleeptime) else: await BiliTimer.append2list_jobs(Daily_Task, 350)
async def run(self): while 1: Printer().printlist_append(['join_lottery', '', 'user', "检查宝箱状态"], True) temp = self.GetAward() if temp == None or temp == -10017: await asyncio.sleep(utils.seconds_until_tomorrow() + 300) elif temp == 0: Printer().printlist_append(['join_lottery', '', 'user', "# 打开了宝箱"]) self.GetAward() else: Printer().printlist_append(['join_lottery', '', 'user',"# 继续等待宝箱冷却..."]) await asyncio.sleep(181)
async def run(self): while 1: Printer().printer(f"检查宝箱状态", "Info", "green") temp = await self.GetAward() if temp == None or temp == -10017: await asyncio.sleep(utils.seconds_until_tomorrow() + 300) elif temp == 0: Printer().printer(f"打开了宝箱", "Info", "green") await self.GetAward() else: Printer().printer(f"继续等待宝箱冷却...", "Info", "green") await asyncio.sleep(180 + random.uniform(0, 60))
async def BiliMainTask(): login, watch_av, num, share_av = await utils.GetRewardInfo() if ConfigLoader().dic_user['task_control']['fetchrule'] == 'bilitop': list_topvideo = await utils.GetTopVideoList() else: list_topvideo = await utils.fetch_uper_video(ConfigLoader().dic_user['task_control']['mid']) if (not login) or not watch_av: await GetVideoExp(list_topvideo) coin_sent = (num) / 10 coin_set = min((ConfigLoader().dic_user['task_control']['givecoin']), 5) coin_remain = coin_set - coin_sent await GiveCoinTask(coin_remain, list_topvideo) if not share_av: await GetVideoShareExp(list_topvideo) # b站傻逼有记录延迟,3点左右成功率高一点 await BiliTimer.append2list_jobs(BiliMainTask, utils.seconds_until_tomorrow() + 10800)
async def silver2coin(user): if not user.task_ctrl['silver2coin']: sleeptime = 21600 return (0, (sleeptime, sleeptime + 30), user.id), json_rsp = await user.req_s(ExchangeSilverCoinReq.silver2coin_web, user) user.infos([f'{json_rsp["msg"]}']) if json_rsp['code'] == 403 and '最多' in json_rsp['msg']: finish_web = True else: finish_web = False if finish_web: sleeptime = utils.seconds_until_tomorrow() + 300 else: sleeptime = 350 return (0, (sleeptime, sleeptime + 30), user.id),
async def BiliMainTask(self): login, watch_av, num, share_av = await self.GetRewardInfo() if self.task_control['fetchrule'] == 'bilitop': list_topvideo = await self.GetTopVideoList() # print(list_topvideo) else: list_topvideo = await self.fetch_uper_video(self.task_control['mid']) if (not login) or not watch_av: await self.GetVideoExp(list_topvideo) coin_sent = (num) / 10 coin_set = min((self.task_control['givecoin']), 5) coin_remain = coin_set - coin_sent await self.GiveCoinTask(coin_remain, list_topvideo) if not share_av: await self.GetVideoShareExp(list_topvideo) # b站傻逼有记录延迟,3点左右成功率高一点 await Task().put2queue('BiliMainTask', utils.seconds_until_tomorrow() + 10800)
def init(): BiliTimer.call_after(sliver2coin, 0) BiliTimer.call_after(doublegain_coin2silver, 0) BiliTimer.call_after(DoSign, 0) BiliTimer.call_after(Daily_bag, 0) BiliTimer.call_after(Daily_Task, 0) BiliTimer.call_after(link_sign, 0) BiliTimer.call_after(initiate_send_gift, 0) BiliTimer.call_after(BiliMainTask, 0) BiliTimer.call_after(judge, 0) # 每天 20:30 - 22:30 之间开始 (黄金时段?)看视频 # 如果正在黄金时段,立刻开始看。 假设 HEADLESS 并且定时重启(crontab) seconds_to_gold_time = max( 0, utils.seconds_until_tomorrow() - random.randint(5400, 12600)) printer.info([f'黄金时段:{seconds_to_gold_time} 秒后 - 看视频']) BiliTimer.call_after(watch_av, seconds_to_gold_time)
async def run(): while True: printer.info(["检查宝箱状态"], True) json_rsp = await GetAward() if json_rsp is None or json_rsp['code'] == -10017: sleeptime = (utils.seconds_until_tomorrow() + 300) await asyncio.sleep(sleeptime) elif not json_rsp['code']: printer.info(["# 打开了宝箱"]) elif json_rsp['code'] == 400: print('小黑屋, 6小时后重试') await asyncio.sleep(21600) else: printer.info(["# 继续等待宝箱冷却..."]) # 未来如果取消了这个东西就睡眠185s,否则精确睡眠 # surplus里面是min,float格式 sleeptime = (json_rsp['data'].get('surplus', 3)) * 60 + 5 await asyncio.sleep(sleeptime)
async def BiliMainTask(): try: login, watch_av, num, share_av = await utils.GetRewardInfo() except: # print('当前网络不好,正在重试,请反馈开发者!!!!') print(sys.exc_info()[0], sys.exc_info()[1]) return list_topvideo = await utils.GetTopVideoList() if (not login) or not watch_av: await GetVideoExp(list_topvideo) coin_sent = (num) / 10 coin_set = min((ConfigLoader().dic_user['task_control']['givecoin']), 5) coin_remain = coin_set - coin_sent await GiveCoinTask(coin_remain, list_topvideo) if not share_av: await GetVideoShareExp(list_topvideo) # b站傻逼有记录延迟,3点左右成功率高一点 await BiliTimer.append2list_jobs(BiliMainTask, utils.seconds_until_tomorrow() + 10800)
async def sliver2coin(self): if self.task_control['silver2coin']: # 403 done # json_response1 = await self.online_request(self.webhub.silver2coin_app) # -403 done json_response = await self.online_request( self.webhub.silver2coin_web) self.printer_with_id([f'# {json_response["msg"]}']) # self.printer_with_id([f'# {json_response1["msg"]}']) if json_response['code'] == 403 and '最多' in json_response['msg']: finish_web = True else: finish_web = False if finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) return sleeptime else: return 350 return 21600
async def vip_priviledge_b_coin(): resp = await OnlineNet().req('recv_vip_privilege', 1) BiliTimer.call_after(vip_priviledge_b_coin, utils.seconds_until_tomorrow()) printer.info([f'大会员返B币:{resp["message"]}'])