def jd_cookie(): # 读取 jd_cookie 配置 config_latest, config_current = read() try: jd_config = config_current['jobs']['jd'] except: print(traceback.format_exc()) print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本比较 jd_cookie_config = jd.check_jd_scripts_version(config_latest, config_current, 'jd_cookie') if jd_cookie_config['enable']: accounts = jd_config['parameters']['ACCOUNTS'] valid_cookies = [] for account in accounts: utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【京东-ck有效性检测】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n' ) start_time = time.time() title = f'☆【京东-ck有效性检测】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' try: # 使用正则找 pt_pin 和 pt_key pt_pin = re.findall(r'pt_pin=(.*?);', account['COOKIE'])[0] pt_key = re.findall(r'pt_key=(.*?);', account['COOKIE'])[0] cookie = {'pt_pin': pt_pin, 'pt_key': pt_key} # 设置为字典格式 check_result = check_valid(cookie) # 访问 api 检测 ck 有效性 # 有效性判断 if check_result['code'] == '0': valid_cookies.append(account['COOKIE']) content = f"cookie - {pt_pin} 有效!" elif check_result['code'] == '3': content = f"cookie - {pt_pin} 失效!" # ck 失效发送推送 if jd_cookie_config['notify']: notify_mode = jd_config['notify_mode'] try: notify.send(title=title, content=content, notify_mode=notify_mode) except: print('请确保配置文件的对应的脚本任务中,参数 notify_mode 下面有推送方式\n') else: print( '未进行消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数 notify 的值为 true\n' ) else: content = '请前往 https://github.com/TNanko/Scripts/issues 反馈问题!' except: content = 'cookie 错误,请重新抓取!' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(title) print(content) else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数 enable 设置为 true\n')
def create_cron(skip_check_version=False): """ 添加定时任务 :param skip_check_version: :return: """ cron = CronTab(user=True) _, config_current = read(skip_check_version=skip_check_version) # 读取所有配置 jobs = config_current['jobs'] # 得到当前所有任务 multi_script_jobs = [] # 多脚本任务 # 读取每个 job 的 cron 表达式 for key, value in jobs.items(): try: scripts_path = f"{BASE_DIR}/{'scripts'}/{value['scripts_filename']}" # 脚本绝对路径 job = cron.new(command='python3 %s' % scripts_path, comment='TNanko Scripts') # 创建一个c cron 任务 job.setall(value['schedule']['cron']) # 设置脚本运行频率 if job.is_valid: continue else: print(f"定时任务 {key} 设置错误,请仔细检查 cron 表达式和对应的配置信息!") # print(job.is_enabled()) # job.enable(enabled=False) except: multi_script_jobs.append(key) # 单任务多脚本暂时没写 cron.write()
def jd_cookie(): # 读取 jd_cookie 配置 config_latest, config_current = read() try: jd_config = config_current['jobs']['jd'] except: print(traceback.format_exc() + '\n配置文件中没有此任务!请更新您的配置文件') return # 脚本版本比较 jd_cookie_config = jd.check_jd_scripts_version(config_latest, config_current, 'jd_cookie') accounts = jd_config['parameters']['ACCOUNTS'] if jd_cookie_config['allow_to_format_cookie']: format_cookies(accounts) if jd_cookie_config['enable']: # 京东 cookies for account in accounts: utc_datetime, beijing_datetime = get_standard_time() start_time = time.time() account_title = f"\n{'=' * 16}【京东-ck有效性检测】{utc_datetime.strftime('%Y-%m-%d %H:%M:%S')}/{beijing_datetime.strftime('%Y-%m-%d %H:%M:%S')} {'=' * 16}\n☆【京东-ck有效性检测】{beijing_datetime.strftime('%Y-%m-%d %H:%M:%S')} ☆" title = f'☆【京东-ck有效性检测】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' try: # 使用正则找 pt_pin 和 pt_key pt_pin = account['COOKIE']['pt_pin'] check_result = check_valid( account['COOKIE']) # 访问 api 检测 ck 有效性 # 有效性判断 if check_result['code'] == '0': content = f"cookie - {pt_pin} 有效!" elif check_result['code'] == '3': content = f"cookie - {pt_pin} 失效!" # ck 失效发送推送 if jd_cookie_config['notify']: notify_mode = jd_config['notify_mode'] try: notify.send(title=title, content=content, notify_mode=notify_mode) except: print('请确保配置文件的对应的脚本任务中,参数 notify_mode 下面有推送方式\n') else: print( '未进行消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数 notify 的值为 true\n' ) else: content = '\n程序报错,请带着日志前往 https://github.com/TNanko/Scripts/issues 反馈问题!' except: content = '\ncookie 错误,请重新抓取!' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(f'{account_title}\n{content}') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数 enable 设置为 true\n')
def send(title, content, notify_mode): """ 使用 bark, telegram bot, dingding bot, serverJ 发送手机推送 :param title: :param content: :return: """ try: config = read() # 调用utils包中的config.py的read函数 if config['notify']['enable']: for i in notify_mode: if i == 'bark': # bark bark_machine_code = config['notify']['type']['bark']['BARK_MACHINE_CODE'] if bark_machine_code: bark(bark_machine_code, title, content) else: print('未启用 bark') continue elif i == 'dingding_bot': # dingding dd_bot_accsee_token = config['notify']['type']['dingding_bot']['DD_BOT_ACCESS_TOKEN'] dd_bot_secret = config['notify']['type']['dingding_bot']['DD_BOT_SECRET'] if dd_bot_accsee_token and dd_bot_secret: dingding_bot(access_token=dd_bot_accsee_token, secret=dd_bot_secret, title=title, content=content) else: print('未启用 钉钉机器人') continue elif i == 'telegram_bot': # telegram_bot tg_bot_token = config['notify']['type']['telegram_bot']['TG_BOT_TOKEN'] tg_user_id = config['notify']['type']['telegram_bot']['TG_USER_ID'] if tg_bot_token and tg_user_id: telegram_bot(tg_bot_token=tg_bot_token, tg_user_id=tg_user_id, title=title, content=content) else: print('未启用 telegram机器人') continue elif i == 'server_chan': # serverChan sckey = config['notify']['type']['server_chan']['SCKEY'] if sckey: server_chan(sckey, title, content) else: print('未启用 serverChan') continue else: print('此类推送方式不存在') else: print('未启用消息推送,请在 config.yml 中将 notify - enable 设置为 true') except: symbol = '-' * 50 print(f'\n[⚠ /Scripts/utils/notify.py - send(title, content) 错误]\n{symbol}\n{traceback.format_exc()}{symbol}')
def main(): config_latest, config_current = read() # 读取企鹅读书配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('脚本配置参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config['version']: print(f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}") else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 确定脚本是否开启执行模式 if qq_read_config['enable']: try: # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] process_delay = qq_read_config['process_delay'] process_pool_num = qq_read_config['process_pool_num'] pool_num = lambda x: len(accounts) if len(accounts) > x else x if process_pool_num <= 0: process_pool_num = 10 process_pool = Pool(pool_num(process_pool_num)) print(f'开始执行任务...\n进程池大小:{process_pool_num}\t每次投入任务后延迟:{process_delay}秒') task_start_time = time.time() for account in accounts: process_pool.apply_async(qq_read, args=(qq_read_config, account)) time.sleep(process_delay) process_pool.close() process_pool.join() print(f'🕛执行 {len(accounts)} 个QQ号完成!总耗时:%.2f秒\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' % (time.time() - task_start_time)) except: print(traceback.format_exc()) print('程序报错!请带上你的错误日志去 https://github.com/TNanko/leam/issues 反馈问题!') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def template(): # 需要修改 template qq_reader_config = read()['jobs']['template'] if qq_reader_config['enable']: utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 # 需要修改 template print(f'\n{symbol}【template】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}') start_time = time.time() # 需要修改 template title = f'☆【template】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' print(title) print(f'🕛耗时:{time.time()-start_time}秒') # 发送消息推送 if qq_reader_config['notify']: notify.send(title=title, content=content) else: print('未进行消息推送,如需发送消息推送请在配置文件的对应的任务中,将参数notify设置为true') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true')
def bilibili(): # 读取 bilibili 配置 config_latest, config_current = read() try: bilibili_config = config_current['jobs']['bilibili'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if bilibili_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['bilibili']['version'] > bilibili_config['version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['bilibili']['version']},当前脚本版本号:{bilibili_config['version']}") else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') if bilibili_config['enable']: # 获取config.yml账号信息 accounts = bilibili_config['parameters']['ACCOUNTS'] for account in accounts: headers = { 'Cookie': account['COOKIE'], 'Host': 'api.live.bilibili.com', 'Origin': 'api.live.bilibili.com', 'Referer': 'http://live.bilibili.com/', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15' } utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【bilibili】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n') start_time = time.time() title = f'☆【bilibili】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' sign_result = sign(headers=headers) if sign_result: content += f"【bilibili】签到成功!本月累计({sign_result['hadSignDays']},{sign_result['allDays']})次,说明{sign_result['text']}" else: content += f"【bilibili】签到失败!说明:{sign_result['message']}" content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) print(title) print(content) if bilibili_config['notify']: # 消息推送方式 notify_mode = bilibili_config['notify_mode'] try: # 推送消息 notify.send(title=title, content=content, notify_mode=notify_mode) except: print('请确保配置文件的对应的脚本任务中,参数 notify_mode 下面有推送方式\n') else: print('未进行消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数 notify 的值为 true\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数 enable 设置为 true\n')
def qq_read(): config_latest, config_current = read() # 读取企鹅读书配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config[ 'version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}" ) else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] # 确定脚本是否开启执行模式 if qq_read_config['enable']: for account in accounts: try: book_url = account['BOOK_URL'] headers = account['HEADERS'] body = account['BODY'] withdraw = account['WITHDRAW'] hosting_mode = account['HOSTING_MODE'] utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【企鹅读书】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n' ) start_time = time.time() title = f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 调用 track 接口,为保证输出结果美观,输出信息写在后面 track_result = track(headers=headers, body=body) # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks: content += f'\n【金币余额】剩余{daily_tasks["user"]["amount"]}金币,可提现{daily_tasks["user"]["amount"] // 10000}元' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第1个代码段 ↓ ''' # 查询今日获得金币数量 beijing_datetime_0 = beijing_datetime.strftime( '%Y-%m-%d') + ' 00:00:00' today_coins_total = 0 is_today_red_packet = True for pn in range(1, 15): red_packets = get_red_packets(headers=headers, pn=pn) if red_packets and is_today_red_packet: for red_packet in red_packets['list']: if red_packet['content'] >= beijing_datetime_0: today_coins_total += red_packet['amount'] else: is_today_red_packet = False break elif not red_packets: content += f'\n【今日收益】请求接口错误!' break else: content += f"\n【今日收益】{today_coins_total}金币,约{'{:4.2f}'.format(today_coins_total / 10000)}元" break # 查询本周阅读时长 week_read_time = get_week_read_time(headers=headers) if week_read_time: content += f'\n【本周阅读】{week_read_time["readTime"] // 60}小时{week_read_time["readTime"] % 60}分钟' # 查询今日阅读时长 today_read_time = get_today_read_time(headers=headers) if today_read_time: content += f'\n【今日阅读】{today_read_time["todayReadSeconds"] // 3600}小时{today_read_time["todayReadSeconds"] // 60 % 60}分钟' # 输出任务列表中的信息 if daily_tasks: content += f'\n【{daily_tasks["taskList"][0]["title"]}】{daily_tasks["taskList"][0]["amount"]}金币,{daily_tasks["taskList"][0]["actionText"]}' content += f'\n【{daily_tasks["taskList"][1]["title"]}】{daily_tasks["taskList"][1]["amount"]}金币,{daily_tasks["taskList"][1]["actionText"]}' content += f'\n【{daily_tasks["taskList"][2]["title"]}】{daily_tasks["taskList"][2]["amount"]}金币,{daily_tasks["taskList"][2]["actionText"]}' content += f'\n【{daily_tasks["taskList"][3]["title"]}】{daily_tasks["taskList"][3]["amount"]}金币,{daily_tasks["taskList"][3]["actionText"]}{daily_tasks["taskList"][3]["subTitle"]}' content += f'\n【邀请任务】{daily_tasks["invite"]["month"]}月第{daily_tasks["invite"]["issue"]}期({daily_tasks["invite"]["dayRange"]}),已邀{daily_tasks["invite"]["inviteCount"]}人,再邀请{daily_tasks["invite"]["nextInviteConfig"]["count"]}人可获{daily_tasks["invite"]["nextInviteConfig"]["amount"]}金币' content += f'\n【粉丝分成】已有{daily_tasks["fans"]["fansCount"]}个粉丝,今日获得分成{daily_tasks["fans"]["todayAmount"]}金币' content += f'\n【宝箱任务】已开{daily_tasks["treasureBox"]["count"]}个宝箱,下一个宝箱{daily_tasks["treasureBox"]["tipText"]}' # 每日签到 daily_beans = get_daily_beans(headers=headers) if daily_beans and daily_beans['takeTicket'] > 0: content += f"\n【阅豆签到】获得{daily_beans['takeTicket']}阅豆" # 阅读奖励,好像每个账号只能领一次 if not today_read_time['readTimeRewardTask'][ len(today_read_time['readTimeRewardTask']) - 1]['doneFlag']: seconds = [60, 180, 360, 600, 900, 1200, 1500] for i in seconds: read_time_reward = read_time_reward_tasks( headers=headers, seconds=i) if read_time_reward: content += f"\n【阅读奖励】阅读{i}秒,获得金币{read_time_reward['amount']}" # 立即阅读《xxx》 if daily_tasks['taskList'][0]['enableFlag']: read_now_reward = read_now(headers=headers) if read_now_reward: content += f'\n【{daily_tasks["taskList"][0]["title"]}】获得{read_now_reward["amount"]}金币' # 阅读任务 if daily_tasks['taskList'][1]['enableFlag']: for task in daily_tasks['taskList'][1]['config']: if task['enableFlag'] and not task['doneFlag']: read_reward = read_tasks(headers=headers, seconds=task['seconds']) if read_reward and read_reward['amount'] > 0: content += f"\n【阅读任务】阅读{task['timeStr']},获得{read_reward['amount']}金币" # 今日打卡 if daily_tasks['taskList'][2]['enableFlag']: sign_reward = daily_sign(headers=headers) if sign_reward: content += f"\n【{daily_tasks['taskList'][2]['title']}】获得{sign_reward['todayAmount']}金币,已连续签到{sign_reward['clockInDays']}天" # 打卡翻倍 if sign_reward['videoDoneFlag'] == 0: sign_ads_reward = watch_daily_sign_ads(headers=headers) if sign_ads_reward: content += f"\n【打卡翻倍】获得{sign_ads_reward['amount']}金币" # 看视频 if daily_tasks['taskList'][3]['enableFlag']: finish_count = int( daily_tasks["taskList"][3]["subTitle"][1:2]) total_count = int( daily_tasks["taskList"][3]["subTitle"][3:4]) # for i in range(1, total_count+1): watch_videos_reward = watch_videos(headers=headers) if watch_videos_reward: content += f"\n【视频奖励】获得{watch_videos_reward['amount']}金币({finish_count + 1}/{total_count})" # 周阅读时长奖励查询 week_read_rewards = get_week_read_tasks(headers=headers) # 当周阅读时间 >= 最大奖励所需要的时间(1200分钟),领取奖励 if week_read_time['readTime'] >= week_read_rewards[ len(week_read_rewards) - 1]['readTime']: for week_read_reward in week_read_rewards: if not week_read_reward['isPick']: reward = get_week_read_reward( headers=headers, read_time=week_read_reward['readTime']) if reward: content += f"\n【周时长奖励】领取{week_read_reward['readTime']}时长奖励成功" '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第1个代码段 ↑ ''' # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads( headers=headers) if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第2个代码段 ↓ ''' # 读书刷时长 if max_read_time > today_read_time["todayReadSeconds"] // 60: read_book = read_books(headers=headers, book_url=book_url, upload_time=upload_time) if read_book: content += f'\n【阅读时长】成功增加{read_book}的阅读时长' else: content += f'\n【阅读时长】已达到设置的对大阅读时长,故不增加阅读时长' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第2个代码段 ↑ ''' # track(headers, body)的输出信息 if track_result: content += f'\n【数据跟踪】跟踪成功!' else: content += f'\n【数据跟踪】跟踪失败!请重新抓取你的参数 body ' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第3个代码段 ↓ ''' if withdraw and user_info: # 获取提现信息 withdraw_info = get_withdraw_info(headers=headers) transform_info = [] if withdraw_info: for i in withdraw_info: if i['amount'] == 6000: transform_info.append({ 'amount': i['amount'], 'withdraw_time': 1 }) elif i['amount'] == 10000 or i['amount'] == 20000: withdraw_time = re.findall('\d+', i['tipText']) transform_info.append({ 'amount': i['amount'], 'withdraw_time': int(withdraw_time[0]) }) else: transform_info.append({ 'amount': i['amount'], 'withdraw_time': 999 }) # 提现 if withdraw and beijing_datetime.hour == 23: if hosting_mode: # 先把0.6元提现了 if daily_tasks["user"]["amount"] >= 6000 and transform_info[0]['amount'] == 6000 and \ transform_info[0]['withdraw_time'] > 0: withdraw_result = withdraw_to_wallet( headers=headers, amount=6000) if withdraw_result == True: content += f'\n【托管提现】提现0.6元成功!' # 提现成功后,如果 notify 打开就发推送 if qq_read_config['notify']: notify.send( title=title, content= f"【托管提现】账号{user_info['user']['nickName']}提现0.6元成功!", notify_mode=notify_mode) else: content += f'\n【托管提现】提现失败!原因:{withdraw_result}' elif daily_tasks["user"]["amount"] >= 10000: transform_info.reverse() # 提现尝试 大额度->小额度 for i in transform_info: if daily_tasks["user"]["amount"] >= i[ 'amount'] and i[ 'withdraw_time'] > 0: withdraw_result = withdraw_to_wallet( headers=headers, amount=i['amount']) if withdraw_result == True: content += f"\n【托管提现】提现{i['amount'] // 10000}元成功!" if qq_read_config['notify']: notify.send( title=title, content= f"【托管提现】账号{user_info['user']['nickName']}提现{i['amount'] // 10000}元成功!", notify_mode=notify_mode) else: content += f'\n【托管提现】提现失败!原因:{withdraw_result}' break else: content += f'\n【托管提现】余额不足或低金额提现次数耗尽,无法提现!' else: if daily_tasks["user"]["amount"] >= 100000: withdraw_result = withdraw_to_wallet( headers=headers, amount=100000) if withdraw_result == True: content += f'\n【满额提现】提现10元成功!' if qq_read_config['notify']: notify.send( title=title, content= f"【满额提现】账号{user_info['user']['nickName']}提现10元成功!", notify_mode=notify_mode) else: content += f'\n【满额提现】提现失败!原因:{withdraw_result}' else: content += f'\n【满额提现】余额不足10元,未打开托管模式,不提现!' else: content += f'\n【自动提现】未到23点' else: content += f'\n【自动提现】未启用该功能' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第3个代码段 ↑ ''' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(title) print(content) '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第4个代码段 ↓ ''' # 每天 22:00 - 22:10 发送消息推送 if qq_read_config[ 'notify'] and beijing_datetime.hour == 23 and beijing_datetime.minute > 50: notify.send(title=title, content=content, notify_mode=notify_mode) elif not qq_read_config['notify']: print( '未进行消息推送,原因:未设置消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数notify的值为true\n' ) elif not beijing_datetime.hour == 23: print('未进行消息推送,原因:没到对应的推送时间点\n') else: print('未在规定的时间范围内\n') '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第4个代码段 ↑ ''' except: # 如果headers过期,先获取 QQ 号 headers = account['HEADERS'] utc_datetime, beijing_datetime = get_standard_time() qq_id = re.findall(r'ywguid=(.*?);', str(headers['Cookie']))[0] if qq_id: print( f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆\nQQ账号 {qq_id} headers过期!' ) # 发送推送 if qq_read_config[ 'notify'] and beijing_datetime.hour / 3 == 0 and beijing_datetime.minute < 10: notify.send( title= f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆', content=f'QQ账号 {qq_id[0]} headers过期!', notify_mode=notify_mode) else: print('获取QQ账号失败,请检查headers') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def qq_read(): config_latest, config_current = read() # 读取企鹅阅读配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config[ 'version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}" ) else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] utc_datetime, beijing_datetime = get_standard_time() if beijing_datetime.hour == 0 and beijing_datetime.minute <= 10: notify.send( title=f'☆【企鹅阅读】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆', content='请去QQ企鹅读书小程序中手动开一次宝箱或者看视频!', notify_mode=notify_mode) # 确定脚本是否开启执行模式 if qq_read_config['enable']: for account in accounts: book_url = account['BOOK_URL'] headers = account['HEADERS'] utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【企鹅阅读】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n' ) start_time = time.time() title = f'☆【企鹅阅读】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks: content += f'\n【金币余额】剩余{daily_tasks["user"]["amount"]}金币,可提现{daily_tasks["user"]["amount"] // 10000}元' # 查询本周阅读时长 week_read_time = get_week_read_time(headers=headers) if week_read_time: content += f'\n【本周阅读】{week_read_time["readTime"] // 60}小时{week_read_time["readTime"] % 60}分钟' # 查询今日阅读时长 today_read_time = get_today_read_time(headers=headers) if today_read_time: content += f'\n【今日阅读】{today_read_time["todayReadSeconds"] // 3600}小时{today_read_time["todayReadSeconds"] // 60 % 60}分钟' # 输出任务列表中的信息 if daily_tasks: content += f'\n【{daily_tasks["taskList"][0]["title"]}】{daily_tasks["taskList"][0]["amount"]}金币,{daily_tasks["taskList"][0]["actionText"]}' content += f'\n【{daily_tasks["taskList"][1]["title"]}】{daily_tasks["taskList"][1]["amount"]}金币,{daily_tasks["taskList"][1]["actionText"]}' content += f'\n【{daily_tasks["taskList"][2]["title"]}】{daily_tasks["taskList"][2]["amount"]}金币,{daily_tasks["taskList"][2]["actionText"]}' content += f'\n【{daily_tasks["taskList"][3]["title"]}】{daily_tasks["taskList"][3]["amount"]}金币,{daily_tasks["taskList"][3]["actionText"]}{daily_tasks["taskList"][3]["subTitle"]}' content += f'\n【邀请任务】{daily_tasks["invite"]["month"]}月第{daily_tasks["invite"]["issue"]}期({daily_tasks["invite"]["dayRange"]}),已邀{daily_tasks["invite"]["inviteCount"]}人,再邀请{daily_tasks["invite"]["nextInviteConfig"]["count"]}人可获{daily_tasks["invite"]["nextInviteConfig"]["amount"]}金币' content += f'\n【粉丝分成】已有{daily_tasks["fans"]["fansCount"]}个粉丝,今日获得分成{daily_tasks["fans"]["todayAmount"]}金币' content += f'\n【宝箱任务】已开{daily_tasks["treasureBox"]["count"]}个宝箱,下一个宝箱{daily_tasks["treasureBox"]["tipText"]}' # 每日签到 daily_beans = get_daily_beans(headers=headers) if daily_beans and daily_beans['takeTicket'] > 0: content += f"\n【阅豆签到】获得{daily_beans['takeTicket']}阅豆" # 阅读奖励,好像每个账号只能领一次 if not today_read_time['readTimeRewardTask'][ len(today_read_time['readTimeRewardTask']) - 1]['doneFlag']: seconds = [60, 180, 360, 600, 900, 1200, 1500] for i in seconds: read_time_reward = read_time_reward_tasks(headers=headers, seconds=i) if read_time_reward: content += f"\n【阅读奖励】阅读{i}秒,获得金币{read_time_reward['amount']}" # 立即阅读《xxx》 if daily_tasks['taskList'][0]['enableFlag']: read_now_reward = read_now(headers=headers) if read_now_reward: content += f'\n【{daily_tasks["taskList"][0]["title"]}】获得{read_now_reward["amount"]}金币' # 阅读任务 if daily_tasks['taskList'][1]['enableFlag']: for task in daily_tasks['taskList'][1]['config']: if task['enableFlag'] and not task['doneFlag']: read_reward = read_tasks(headers=headers, seconds=task['seconds']) if read_reward and read_reward['amount'] > 0: content += f"\n【阅读任务】阅读{task['timeStr']},获得{read_reward['amount']}金币" # 今日打卡 if daily_tasks['taskList'][2]['enableFlag']: sign_reward = daily_sign(headers=headers) if sign_reward: content += f"\n【{daily_tasks['taskList'][2]['title']}】获得{sign_reward['todayAmount']}金币,已连续签到{sign_reward['clockInDays']}天" # 打卡翻倍 if sign_reward['videoDoneFlag'] == 0: sign_ads_reward = watch_daily_sign_ads(headers=headers) if sign_ads_reward: content += f"\n【打卡翻倍】获得{sign_ads_reward['amount']}金币" # 看视频 if daily_tasks['taskList'][3]['enableFlag']: finish_count = int(daily_tasks["taskList"][3]["subTitle"][1:2]) total_count = int(daily_tasks["taskList"][3]["subTitle"][3:4]) # for i in range(1, total_count+1): watch_videos_reward = watch_videos(headers=headers) if watch_videos_reward: content += f"\n【视频奖励】获得{watch_videos_reward['amount']}金币({finish_count + 1}/{total_count})" # 周阅读时长奖励查询 week_read_rewards = get_week_read_tasks(headers=headers) # 当周阅读时间 >= 最大奖励所需要的时间(1200分钟),领取奖励 if week_read_time['readTime'] >= week_read_rewards[ len(week_read_rewards) - 1]['readTime']: for week_read_reward in week_read_rewards: if not week_read_reward['isPick']: reward = get_week_read_reward( headers=headers, read_time=week_read_reward['readTime']) if reward: content += f"\n【周时长奖励】领取{week_read_reward['readTime']}时长奖励成功" # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads( headers=headers) # 这边有点问题 if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" # 读书刷时长 if max_read_time > today_read_time["todayReadSeconds"] // 60: read_book = read_books(headers=headers, book_url=book_url, upload_time=upload_time) if read_book: content += f'\n【阅读时长】成功增加{upload_time}分钟阅读时长' else: content += f'\n【阅读时长】已达到设置的对大阅读时长,故不增加阅读时长' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) print(title) print(content) # 每天 22:00 - 22:10 发送消息推送 if qq_read_config[ 'notify'] and beijing_datetime.hour == 22 and beijing_datetime.minute <= 10: notify.send(title=title, content=content, notify_mode=notify_mode) elif not qq_read_config['notify']: print( '未进行消息推送,原因:未设置消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数notify的值为true\n' ) elif not beijing_datetime.hour == 0: print('未进行消息推送,原因:没到对应的推送时间点\n') else: print('未在规定的时间范围内\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def qq_read(): config_latest, config_current = read() # 读取企鹅读书配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config['version']: print(f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}") else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] # 确定脚本是否开启执行模式 if qq_read_config['enable']: for account in accounts: try: book_url = account['BOOK_URL'] headers = account['HEADERS'] body = account['BODY'] withdraw = account['WITHDRAW'] hosting_mode = account['HOSTING_MODE'] utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print(f'\n{symbol}【企鹅读书】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n') start_time = time.time() title = f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 调用 track 接口,为保证输出结果美观,输出信息写在后面 track_result = track(headers=headers, body=body) # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks: content += f'\n【金币余额】剩余{daily_tasks["user"]["amount"]}金币,可提现{daily_tasks["user"]["amount"] // 10000}元' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第1个代码段 ↓ ''' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第1个代码段 ↑ ''' # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads(headers=headers) if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第2个代码段 ↓ ''' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第2个代码段 ↑ ''' # track(headers, body)的输出信息 if track_result: content += f'\n【数据跟踪】跟踪成功!' else: content += f'\n【数据跟踪】跟踪失败!请重新抓取你的参数 body ' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第3个代码段 ↓ ''' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第3个代码段 ↑ ''' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(title) print(content) '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第4个代码段 ↓ ''' '''如果需要一个单独开箱子的脚本,删除↑↓箭头内脚本,一共4个代码段,这是第4个代码段 ↑ ''' except: # 如果headers过期,先获取 QQ 号 headers = account['HEADERS'] utc_datetime, beijing_datetime = get_standard_time() qq_id = re.findall(r'ywguid=(.*?);', str(headers['Cookie']))[0] if qq_id: print(f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆\nQQ账号 {qq_id} headers过期!') # 发送推送 if qq_read_config['notify'] and beijing_datetime.hour / 3 == 0 and beijing_datetime.minute < 10: notify.send(title=f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆', content=f'QQ账号 {qq_id[0]} headers过期!', notify_mode=notify_mode) else: print('获取QQ账号失败,请检查headers') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def qq_read(): config_latest, config_current = read() # 读取企鹅读书配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config['version']: print(f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}") else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] # 确定脚本是否开启执行模式 if qq_read_config['enable']: for account in accounts: book_url = account['BOOK_URL'] headers = account['HEADERS'] body = account['BODY'] withdraw = account['WITHDRAW'] hosting_mode = account['HOSTING_MODE'] utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【企鹅读书】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n') start_time = time.time() title = f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 调用 track 接口,为保证输出结果美观,输出信息写在后面 track_result = track(headers=headers, body=body) # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads(headers=headers) if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(title) print(content) # 每天 22:00 - 22:10 发送消息推送 if qq_read_config['notify'] and beijing_datetime.hour == 22 and beijing_datetime.minute <= 10: notify.send(title=title, content=content, notify_mode=notify_mode) elif not qq_read_config['notify']: print('未进行消息推送,原因:未设置消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数notify的值为true\n') elif not beijing_datetime.hour == 22: print('未进行消息推送,原因:没到对应的推送时间点\n') else: print('未在规定的时间范围内\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def qq_read(): config_latest, config_current = read() # 读取企鹅读书配置 try: qq_read_config = config_current['jobs']['qq_read'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if qq_read_config['skip_check_script_version']: print('参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['qq_read']['version'] > qq_read_config[ 'version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['qq_read']['version']},当前脚本版本号:{qq_read_config['version']}" ) else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] # 确定脚本是否开启执行模式 if qq_read_config['enable']: for account in accounts: book_url = account['BOOK_URL'] headers = account['HEADERS'] body = account['BODY'] withdraw = account['WITHDRAW'] hosting_mode = account['HOSTING_MODE'] utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【企鹅读书】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n' ) start_time = time.time() title = f'☆【企鹅读书】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 调用 track 接口,为保证输出结果美观,输出信息写在后面 track_result = track(headers=headers, body=body) # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks: content += f'\n【金币余额】剩余{daily_tasks["user"]["amount"]}金币,可提现{daily_tasks["user"]["amount"] // 10000}元' # 查询今日获得金币数量 beijing_datetime_0 = beijing_datetime.strftime( '%Y-%m-%d') + ' 00:00:00' today_coins_total = 0 is_today_red_packet = True for pn in range(1, 15): red_packets = get_red_packets(headers=headers, pn=pn) if red_packets and is_today_red_packet: for red_packet in red_packets['list']: if red_packet['content'] >= beijing_datetime_0: today_coins_total += red_packet['amount'] else: is_today_red_packet = False break elif not red_packets: content += f'\n【今日收益】请求接口错误!' break else: content += f"\n【今日收益】{today_coins_total}金币,约{'{:4.2f}'.format(today_coins_total / 10000)}元" break # 查询本周阅读时长 week_read_time = get_week_read_time(headers=headers) if week_read_time: content += f'\n【本周阅读】{week_read_time["readTime"] // 60}小时{week_read_time["readTime"] % 60}分钟' # 查询今日阅读时长 today_read_time = get_today_read_time(headers=headers) if today_read_time: content += f'\n【今日阅读】{today_read_time["todayReadSeconds"] // 3600}小时{today_read_time["todayReadSeconds"] // 60 % 60}分钟' # 输出任务列表中的信息 if daily_tasks: content += f'\n【{daily_tasks["taskList"][0]["title"]}】{daily_tasks["taskList"][0]["amount"]}金币,{daily_tasks["taskList"][0]["actionText"]}' content += f'\n【{daily_tasks["taskList"][1]["title"]}】{daily_tasks["taskList"][1]["amount"]}金币,{daily_tasks["taskList"][1]["actionText"]}' content += f'\n【{daily_tasks["taskList"][2]["title"]}】{daily_tasks["taskList"][2]["amount"]}金币,{daily_tasks["taskList"][2]["actionText"]}' content += f'\n【{daily_tasks["taskList"][3]["title"]}】{daily_tasks["taskList"][3]["amount"]}金币,{daily_tasks["taskList"][3]["actionText"]}{daily_tasks["taskList"][3]["subTitle"]}' content += f'\n【邀请任务】{daily_tasks["invite"]["month"]}月第{daily_tasks["invite"]["issue"]}期({daily_tasks["invite"]["dayRange"]}),已邀{daily_tasks["invite"]["inviteCount"]}人,再邀请{daily_tasks["invite"]["nextInviteConfig"]["count"]}人可获{daily_tasks["invite"]["nextInviteConfig"]["amount"]}金币' content += f'\n【粉丝分成】已有{daily_tasks["fans"]["fansCount"]}个粉丝,今日获得分成{daily_tasks["fans"]["todayAmount"]}金币' content += f'\n【宝箱任务】已开{daily_tasks["treasureBox"]["count"]}个宝箱,下一个宝箱{daily_tasks["treasureBox"]["tipText"]}' # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads( headers=headers) if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" # 提现 if withdraw and beijing_datetime.hour == 23: if hosting_mode: # 先把0.6元提现了 if daily_tasks["user"]["amount"] >= 6000 and transform_info[0]['amount'] == 6000 and \ transform_info[0]['withdraw_time'] > 0: withdraw_result = withdraw_to_wallet( headers=headers, amount=6000) if withdraw_result == True: content += f'\n【托管提现】提现0.6元成功!' # 提现成功后,如果 notify 打开就发推送 if qq_read_config['notify']: notify.send( title=title, content= f"【托管提现】账号{user_info['user']['nickName']}提现0.6元成功!", notify_mode=notify_mode) else: content += f'\n【托管提现】提现失败!原因:{withdraw_result}' elif daily_tasks["user"]["amount"] >= 10000: transform_info.reverse() # 提现尝试 大额度->小额度 for i in transform_info: if daily_tasks["user"]["amount"] >= i[ 'amount'] and i['withdraw_time'] > 0: withdraw_result = withdraw_to_wallet( headers=headers, amount=i['amount']) if withdraw_result == True: content += f"\n【托管提现】提现{i['amount'] // 10000}元成功!" if qq_read_config['notify']: notify.send( title=title, content= f"【托管提现】账号{user_info['user']['nickName']}提现{i['amount'] // 10000}元成功!", notify_mode=notify_mode) else: content += f'\n【托管提现】提现失败!原因:{withdraw_result}' break else: content += f'\n【托管提现】余额不足或低金额提现次数耗尽,无法提现!' else: if daily_tasks["user"]["amount"] >= 100000: withdraw_result = withdraw_to_wallet( headers=headers, amount=100000) if withdraw_result == True: content += f'\n【满额提现】提现10元成功!' if qq_read_config['notify']: notify.send( title=title, content= f"【满额提现】账号{user_info['user']['nickName']}提现10元成功!", notify_mode=notify_mode) else: content += f'\n【满额提现】提现失败!原因:{withdraw_result}' else: content += f'\n【满额提现】余额不足10元,未打开托管模式,不提现!' else: content += f'\n【自动提现】未到23点' else: content += f'\n【自动提现】未启用该功能' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' print(title) print(content) # 每天 22:00 - 22:10 发送消息推送 if qq_read_config[ 'notify'] and beijing_datetime.hour == 22 and beijing_datetime.minute <= 10: notify.send(title=title, content=content, notify_mode=notify_mode) elif not qq_read_config['notify']: print( '未进行消息推送,原因:未设置消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数notify的值为true\n' ) elif not beijing_datetime.hour == 22: print('未进行消息推送,原因:没到对应的推送时间点\n') else: print('未在规定的时间范围内\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def qq_read(): utc_datetime, beijing_datetime = get_standard_time() qq_read_config = read()['jobs']['qq_read'] # 获取config.yml账号信息 accounts = qq_read_config['parameters']['ACCOUNTS'] # 每次上传的时间 upload_time = qq_read_config['parameters']['UPLOAD_TIME'] # 每天最大阅读时长 max_read_time = qq_read_config['parameters']['MAX_READ_TIME'] # 消息推送方式 notify_mode = qq_read_config['notify_mode'] if beijing_datetime.hour == 0 and beijing_datetime.minute <= 10: notify.send( title=f'☆【企鹅阅读】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆', content='请去QQ企鹅读书小程序中手动开一次宝箱或者看视频!', notify_mode=notify_mode) # 开启脚本执行 if qq_read_config['enable']: for account in accounts: book_url = account['BOOK_URL'] headers = { 'Accept': '*/*', 'ywsession': account['YWSESSION'], 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Cookie': account['COOKIE'], 'Host': 'mqqapi.reader.qq.com', 'User-Agent': 'QQ/8.4.17.638 CFNetwork/1197 Darwin/20.0.0', 'Referer': 'https://appservice.qq.com/1110657249/0.30.0/page-frame.html', 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', 'mpversion': '0.30.0' } symbol = '=' * 16 print( f'\n{symbol}【企鹅阅读】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n' ) start_time = time.time() title = f'☆【企鹅阅读】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' # 获取用户信息(昵称) user_info = get_user_info(headers=headers) if user_info: content += f'【用户昵称】{user_info["user"]["nickName"]}' # 获取任务列表,查询金币余额 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks: content += f'\n【金币余额】剩余{daily_tasks["user"]["amount"]}金币,可提现{daily_tasks["user"]["amount"] // 10000}元' # 查询本周阅读时长 week_read_time = get_week_read_time(headers=headers) if week_read_time: content += f'\n【本周阅读】{week_read_time["readTime"] // 60}小时{week_read_time["readTime"] % 60}分钟' # 查询今日阅读时长 today_read_time = get_today_read_time(headers=headers) if today_read_time: content += f'\n【今日阅读】{today_read_time["todayReadSeconds"] // 3600}小时{today_read_time["todayReadSeconds"] // 60 % 60}分钟' # 输出任务列表中的信息 if daily_tasks: content += f'\n【{daily_tasks["taskList"][0]["title"]}】{daily_tasks["taskList"][0]["amount"]}金币,{daily_tasks["taskList"][0]["actionText"]}' content += f'\n【{daily_tasks["taskList"][1]["title"]}】{daily_tasks["taskList"][1]["amount"]}金币,{daily_tasks["taskList"][1]["actionText"]}' content += f'\n【{daily_tasks["taskList"][2]["title"]}】{daily_tasks["taskList"][2]["amount"]}金币,{daily_tasks["taskList"][2]["actionText"]}' content += f'\n【{daily_tasks["taskList"][3]["title"]}】{daily_tasks["taskList"][3]["amount"]}金币,{daily_tasks["taskList"][3]["actionText"]}{daily_tasks["taskList"][3]["subTitle"]}' content += f'\n【邀请任务】{daily_tasks["invite"]["month"]}月第{daily_tasks["invite"]["issue"]}期({daily_tasks["invite"]["dayRange"]}),已邀{daily_tasks["invite"]["inviteCount"]}人,再邀请{daily_tasks["invite"]["nextInviteConfig"]["count"]}人可获{daily_tasks["invite"]["nextInviteConfig"]["amount"]}金币' content += f'\n【粉丝分成】已有{daily_tasks["fans"]["fansCount"]}个粉丝,今日获得分成{daily_tasks["fans"]["todayAmount"]}金币' content += f'\n【宝箱任务】已开{daily_tasks["treasureBox"]["count"]}个宝箱,下一个宝箱{daily_tasks["treasureBox"]["tipText"]}' # 每日签到 daily_beans = get_daily_beans(headers=headers) if daily_beans and daily_beans['takeTicket'] > 0: content += f"\n【阅豆签到】获得{daily_beans['takeTicket']}阅豆" # 阅读奖励,好像每个账号只能领一次 if not today_read_time['readTimeRewardTask'][ len(today_read_time['readTimeRewardTask']) - 1]['doneFlag']: seconds = [60, 180, 360, 600, 900, 1200, 1500] for i in seconds: read_time_reward = read_time_reward_tasks(headers=headers, seconds=i) if read_time_reward: content += f"\n【阅读奖励】阅读{i}秒,获得金币{read_time_reward['amount']}" # 立即阅读《xxx》 if daily_tasks['taskList'][0]['enableFlag']: read_now_reward = read_now(headers=headers) if read_now_reward: content += f'\n【{daily_tasks["taskList"][0]["title"]}】获得{read_now_reward["amount"]}金币' # 阅读任务 if daily_tasks['taskList'][1]['enableFlag']: for task in daily_tasks['taskList'][1]['config']: if task['enableFlag'] and not task['doneFlag']: read_reward = read_tasks(headers=headers, seconds=task['seconds']) if read_reward and read_reward['amount'] > 0: content += f"\n【阅读任务】阅读{task['timeStr']},获得{read_reward['amount']}金币" # 今日打卡 if daily_tasks['taskList'][2]['enableFlag']: sign_reward = daily_sign(headers=headers) if sign_reward: content += f"\n【{daily_tasks['taskList'][2]['title']}】获得{sign_reward['todayAmount']}金币,已连续签到{sign_reward['clockInDays']}天" # 打卡翻倍 if sign_reward['videoDoneFlag'] == 0: sign_ads_reward = watch_daily_sign_ads(headers=headers) if sign_ads_reward: content += f"\n【打卡翻倍】获得{sign_ads_reward['amount']}金币" # 看视频 if daily_tasks['taskList'][3]['enableFlag']: finish_count = int(daily_tasks["taskList"][3]["subTitle"][1:2]) total_count = int(daily_tasks["taskList"][3]["subTitle"][3:4]) # for i in range(1, total_count+1): watch_videos_reward = watch_videos(headers=headers) if watch_videos_reward: content += f"\n【视频奖励】获得{watch_videos_reward['amount']}金币({finish_count + 1}/{total_count})" # 周阅读时长奖励查询 week_read_rewards = get_week_read_tasks(headers=headers) # 当周阅读时间 >= 最大奖励所需要的时间(1200分钟),领取奖励 if week_read_time['readTime'] >= week_read_rewards[ len(week_read_rewards) - 1]['readTime']: for week_read_reward in week_read_rewards: if not week_read_reward['isPick']: reward = get_week_read_reward( headers=headers, read_time=week_read_reward['readTime']) if reward: content += f"\n【周时长奖励】领取{week_read_reward['readTime']}时长奖励成功" # 开宝箱领金币 if daily_tasks['treasureBox']['doneFlag'] == 0: treasure_box_reward = open_treasure_box(headers=headers) if treasure_box_reward: content += f"\n【开启第{treasure_box_reward['count']}个宝箱】获得{treasure_box_reward['amount']}金币" # 宝箱金币奖励翻倍 daily_tasks = get_daily_tasks(headers=headers) if daily_tasks['treasureBox']['videoDoneFlag'] == 0: treasure_box_ads_reward = watch_treasure_box_ads( headers=headers) # 这边有点问题 if treasure_box_ads_reward: content += f"\n【宝箱奖励翻倍】获得{treasure_box_ads_reward['amount']}金币" # 读书刷时长 if max_read_time > today_read_time["todayReadSeconds"] // 60: read_book = read_books(headers=headers, book_url=book_url, upload_time=upload_time) if read_book: content += f'\n【阅读时长】成功增加{upload_time}分钟阅读时长' content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) print(title) print(content) # 每天 20:00 - 20:10 发送消息推送 if qq_read_config[ 'notify'] and beijing_datetime.hour == 20 and beijing_datetime.minute <= 10: notify.send(title=title, content=content, notify_mode=notify_mode) else: print( '消息未推送,原因:没到对应的推送时间点或者未设置消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数notify的值为true\n' ) else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数enable设置为true\n')
def five2pojie(): # 读取 52破解 配置 config_latest, config_current = read() try: five2_config = config_current['jobs']['52pojie'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if five2_config['skip_check_script_version']: print('脚本配置参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['52pojie']['version'] > five2_config[ 'version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['52pojie']['version']},当前脚本版本号:{five2_config['version']}" ) else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') if five2_config['enable']: # 获取config.yml账号信息 accounts = five2_config['parameters']['ACCOUNTS'] # 脚本名字 scripts_filename = five2_config['scripts_filename'] # 日志相关参数 log_parameters = five2_config['log'] for account in accounts: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.60", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Referer": "https://www.52pojie.cn/index.php", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,fr;q=0.5,pl;q=0.4", 'Cookie': account['COOKIE'], } utc_datetime, beijing_datetime = get_standard_time() start_time = time.time() title = f'☆【吾爱破解】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' account_title = f"\n{'=' * 16}【吾爱破解】{utc_datetime.strftime('%Y-%m-%d %H:%M:%S')}/{beijing_datetime.strftime('%Y-%m-%d %H:%M:%S')} {'=' * 16}\n{title}" signin(headers=headers) nickname = get_nickname(headers=headers) time.sleep(10) signin_result = signin(headers=headers) if signin_result: bs_obj = BeautifulSoup(signin_result, 'html.parser') # 获取签到结果所在的 div 标签 div = bs_obj.find_all('div', attrs={ 'class': 'alert_info', 'id': "messagetext" }) # 获取签到结果内容 result = div[0].find_all('p')[0].get_text() if result == '抱歉,本期您已申请过此任务,请下期再来' and nickname: content = '【吾爱破解】%s 签到成功!' % nickname elif result == '您需要先登录才能继续本操作': content = '【吾爱破解】cookie 过期!' else: content = '【吾爱破解】签到失败!请带着日志前往 https://github.com/TNanko/Scripts/issues 反馈问题!' else: content = '【吾爱破解】网络错误!' content += f'\n🕛耗时:%.2f秒\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' % ( time.time() - start_time) if log_parameters['enable']: try: # folder_path = os.path.join(BASE_DIR, 'log') # 可能 windows 系统不适用(未测试) folder_path = BASE_DIR + f'/log/{scripts_filename[:-3]}' if not os.path.isdir(folder_path): print('对应的日志文件夹不存在,创建日志文件夹...') os.makedirs(folder_path) beijing_datetime.strftime("%Y-%m-%d %H:%M:%S") log_path = folder_path + '/%s.log' % beijing_datetime.strftime( '%Y-%m-%d') # 写入日志 log.write_scripts_log(path=log_path, msg='%s\n\n%s' % (account_title, content)) # 删除过期日志 log.delete_scripts_log( path=folder_path, valid_period=log_parameters['valid_period']) except: print('写入日志失败!%s\n%s' % (account_title, content)) else: print(account_title + content) if five2_config['notify']: # 消息推送方式 notify_mode = five2_config['notify_mode'] try: # 推送消息 notify.send(title=title, content=content, notify_mode=notify_mode) except: print('请确保配置文件的对应的脚本任务中,参数 notify_mode 下面有推送方式\n') else: print('未进行消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数 notify 的值为 true\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数 enable 设置为 true\n')
def bilibili(): # 读取 bilibili 配置 config_latest, config_current = read() try: bilibili_config = config_current['jobs']['bilibili'] except: print('配置文件中没有此任务!请更新您的配置文件') return # 脚本版本检测 try: if bilibili_config['skip_check_script_version']: print('脚本配置参数 skip_check_script_version = true ,跳过脚本版本检测...') elif config_latest: if config_latest['jobs']['bilibili']['version'] > bilibili_config['version']: print( f"检测到最新的脚本版本号为{config_latest['jobs']['bilibili']['version']},当前脚本版本号:{bilibili_config['version']}") else: print('当前脚本为最新版本') else: print('未获取到最新脚本的版本号') except: print('程序运行异常,跳过脚本版本检测...') # 脚本名字 scripts_filename = bilibili_config['scripts_filename'] # 日志相关参数 log_parameters = bilibili_config['log'] if bilibili_config['enable']: # 获取config.yml账号信息 accounts = bilibili_config['parameters']['ACCOUNTS'] for account in accounts: headers = { 'Cookie': account['COOKIE'], 'Host': 'api.live.bilibili.com', 'Origin': 'api.live.bilibili.com', 'Referer': 'http://live.bilibili.com/', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15' } utc_datetime, beijing_datetime = get_standard_time() symbol = '=' * 16 print( f'\n{symbol}【bilibili】{utc_datetime.strftime("%Y-%m-%d %H:%M:%S")}/{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} {symbol}\n') start_time = time.time() title = f'☆【bilibili】{beijing_datetime.strftime("%Y-%m-%d %H:%M:%S")} ☆' content = '' sign_result = sign(headers=headers) if sign_result: content += f"【bilibili】签到成功!本月累计({sign_result['hadSignDays']},{sign_result['allDays']})次,说明{sign_result['text']}" else: content += f"【bilibili】签到失败!说明:{sign_result['message']}" content += f'\n🕛耗时:%.2f秒' % (time.time() - start_time) content += f'\n如果帮助到您可以点下🌟STAR鼓励我一下,谢谢~' if log_parameters['enable']: try: # folder_path = os.path.join(BASE_DIR, 'log') # 可能 windows 系统不适用(未测试) folder_path = BASE_DIR + f'/log/{scripts_filename[:-3]}' if not os.path.isdir(folder_path): print('对应的日志文件夹不存在,创建日志文件夹...') os.makedirs(folder_path) beijing_datetime.strftime("%Y-%m-%d %H:%M:%S") log_path = folder_path + '/%s.log' % beijing_datetime.strftime('%Y-%m-%d') # 写入日志 log.write_scripts_log(path=log_path, msg='%s\n\n%s' % (title, content)) # 删除过期日志 log.delete_scripts_log(path=folder_path, valid_period=log_parameters['valid_period']) except: print('写入日志失败!') print(title) print(content) else: print(title) print(content) if bilibili_config['notify']: # 消息推送方式 notify_mode = bilibili_config['notify_mode'] try: # 推送消息 notify.send(title=title, content=content, notify_mode=notify_mode) except: print('请确保配置文件的对应的脚本任务中,参数 notify_mode 下面有推送方式\n') else: print('未进行消息推送。如需发送消息推送,请确保配置文件的对应的脚本任务中,参数 notify 的值为 true\n') else: print('未执行该任务,如需执行请在配置文件的对应的任务中,将参数 enable 设置为 true\n')