def schedule_apps(device, w, h): """ 做两次程序的定时任务 第1次半个小时,其余时间用来看视频 第2次做重要的任务 """ if datetime.now().minute < info.SCHEDULE_TIME: print('第1次定时任务 ' + datetime.now().time().__str__()) for a in info.apps: try: getattr(schedule, a)(device, w, h) except NotImplementedError as e: print(a + ' schedule not implemented') continue if (datetime.now().hour % 4) == 1: # 手机休息180s phone.sleep_to_weak(device, w, h, gap=180) # [x] 看快手视频 if datetime.now().minute < info.SCHEDULE_TIME: checkin.kuaishou(device) while datetime.now().minute < info.SCHEDULE_TIME: phone.swipe_down_to_up(device, w / 2, h, randrange(5, 16)) phone.stop_app(device, info.packages['kuaishou']) print('第2次定时任务 ' + datetime.now().time().__str__()) for a in info.apps: try: getattr(schedule, a)(device, w, h) except NotImplementedError as e: print(a + ' schedule not implemented') continue
def diantao(device, w, h): if datetime.now().hour > 8: checkin.diantao(device) # [x] 点击进入直播页面 phone.tap(device, w / 3, h / 3, gap=5) app.watch_video(device, w, h, num=10) phone.stop_app(device, info.packages['diantao'])
def touda(device, w, h): checkin.touda(device) # [x] 开宝箱 phone.tap(device, 850, 2290) phone.tap(device, 890, 2010, gap=3) phone.stop_app(device, info.packages['touda'])
def close_top_app(): print('关闭当前程序 ' + datetime.now().time().__str__()) for pid in devices: top_activities = phone.get_top_activities(pid) if top_activities is None: return for a in info.apps: if top_activities.__contains__(info.packages[a]): phone.stop_app(pid, info.packages[a], 0)
def signal_handler(sig, frame): # 结束前关闭所有程序 for d in devices: ats = phone.get_top_activities(d) if ats is None: sys.exit(0) for a in info.apps: if ats.__contains__(info.packages[a]): print('关闭运行程序 ' + info.packages[a]) phone.stop_app(d, info.packages[a], 0.1) sys.exit(0)
def douyin(device, w, h): def open_treasure(): print('抖音极速版开宝箱 ' + datetime.now().time().__str__()) phone.tap(device, w / 2, h - 100) # modify phone.tap(device, w - 160, h - 200) # modify checkin.douyin(device) # [x] 看抖音视频 app.watch_video(device, w, h, num=10) # [x] 开宝箱 open_treasure() phone.stop_app(device, info.packages['douyin'])
def shuqi(device, w, h): def watch_advert(): print('书旗看广告赚金币 ' + datetime.now().time().__str__()) phone.tap(device, 900, 2150, gap=10) time.sleep(30) if datetime.now().minute < info.SCHEDULE_TIME: checkin.shuqi(device, w, h) phone.tap(device, w / 2, 2300) # [x] 看广告赚金币 watch_advert() phone.stop_app(device, info.packages['shuqi'])
def toutiao(device, w, h): def open_treasure(): print('今日头条开宝箱 ' + datetime.now().time().__str__()) checkin.toutiao(device) # [x] 阅读头条文章 app.read_article(device, w, h, num=1) # [x] 开宝箱 phone.tap(device, w / 2, 2330) phone.tap(device, 930, 2120, gap=3) phone.stop_app(device, info.packages['toutiao'])
def shuabao(device, w, h): checkin.shuabao(device) app.watch_video(device, w, h, num=10) phone.stop_app(device, info.packages['shuabao'])
def douhuo(device, w, h): checkin.douhuo(device) app.watch_video(device, w, h, num=10) phone.stop_app(device, info.packages['douhuo'])
def fanqie(device, w, h): checkin.fanqie(device, w, h) # [x] 阅读番茄小说 phone.tap(device, w / 3, h / 3) app.read_novel(device, w, h, num=1) phone.stop_app(device, info.packages['fanqie'])
def kuaiyin(device, w, h): # [x] 播放 if datetime.now().hour == 1: checkin.kuaiyin(device, w, h) if datetime.now().hour == 4: phone.stop_app(device, info.packages['kuaiyin'])
def qutoutiao(device, w, h): if datetime.now().hour > 8: checkin.qutoutiao(device) # [x] 阅读趣头条文章 app.read_article(device, w, h, num=1) phone.stop_app(device, info.packages['qutoutiao'])
def kuaishou(device, w, h): checkin.kuaishou(device) # [x] 看快手视频 app.watch_video(device, w, h, num=20) phone.stop_app(device, info.packages['kuaishou'])
def run(device): # 获取手机的大小 (w, h) = phone.get_size(device) # 滑动手机打开屏幕 phone.swipe_down_to_up(device, w / 2, h) # 回到手机主页 phone.go_home(device) # 代码测试位置 schedule.test(device, w, h) while True: if datetime.now().hour != 0: utils.schedule_apps(device, w, h) while datetime.now().hour.__eq__(0): print('所有程序的签到工作 ' + datetime.now().time().__str__()) for a in info.apps: if utils.is_coordinate_checkin(a): try: getattr(checkin, a)(device, w, h) except NotImplementedError as e: print(a + ' checkin not implemented') continue else: try: getattr(checkin, a)(device) except NotImplementedError as e: print(a + ' checkin not implemented') continue # 所有程序的签到工作 try: getattr(sign, a)(device, w, h) except NotImplementedError as e: print(a + ' sign not implemented') continue phone.stop_app(device, info.packages[a]) utils.tail_work(device, w, h, 0) while datetime.now().hour == 1: utils.tail_work(device, w, h, hour=1) while datetime.now().hour == 2: utils.tail_work(device, w, h, hour=2) while datetime.now().hour == 3: utils.tail_work(device, w, h, hour=3) while datetime.now().hour == 4: utils.tail_work(device, w, h, hour=4) while datetime.now().hour == 5: utils.tail_work(device, w, h, hour=5) while datetime.now().hour == 6: utils.tail_work(device, w, h, hour=6) while datetime.now().hour == 7: utils.tail_work(device, w, h, hour=7) while datetime.now().hour == 8: utils.tail_work(device, w, h, hour=8) while datetime.now().hour == 9: utils.tail_work(device, w, h, hour=9) while datetime.now().hour == 10: utils.tail_work(device, w, h, hour=10) while datetime.now().hour == 11: utils.tail_work(device, w, h, hour=11) while datetime.now().hour == 12: utils.tail_work(device, w, h, hour=12) while datetime.now().hour == 13: utils.tail_work(device, w, h, hour=13) while datetime.now().hour == 14: utils.tail_work(device, w, h, hour=14) while datetime.now().hour == 15: utils.tail_work(device, w, h, hour=15) while datetime.now().hour == 16: utils.tail_work(device, w, h, hour=16) while datetime.now().hour == 17: utils.tail_work(device, w, h, hour=17) while datetime.now().hour == 18: utils.tail_work(device, w, h, hour=18) while datetime.now().hour == 19: utils.tail_work(device, w, h, hour=19) while datetime.now().hour == 20: utils.tail_work(device, w, h, hour=20) while datetime.now().hour == 21: utils.tail_work(device, w, h, hour=21) while datetime.now().hour == 22: utils.tail_work(device, w, h, hour=22) while datetime.now().hour == 23: utils.tail_work(device, w, h, hour=23)
def zhongqing(device, w, h): checkin.zhongqing(device, w, h) # [x] 阅读中青看点文章 app.read_article(device, w, h, num=1) phone.stop_app(device, info.packages['zhongqing'])
def baidu(device, w, h): checkin.baidu(device) # [x] 阅读百度文章 app.read_article(device, w, h, num=1) phone.stop_app(device, info.packages['baidu'])
def kuaikandian(device, w, h): checkin.kuaikandian(device, w, h) # [x] 阅读快看点文章 app.read_article(device, w, h, num=1) phone.stop_app(device, info.packages['kuaikandian'])
def weishi(device, w, h): checkin.weishi(device) # [x] 看微视视频 app.watch_video(device, w, h, num=10) phone.stop_app(device, info.packages['weishi'])