1 Star 0 Fork 0

Discovery/AutoReader

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.py 3.45 KB
一键复制 编辑 原始数据 按行查看 历史
Discovery 提交于 2021-12-01 16:11 +08:00 . eat slep
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
@todo
@Author : sunp
@Date :2021/11/21
'''
from com.dtmilano.android.viewclient import ViewClient
from com.dtmilano.android.viewclient import ViewNotFoundException
from com.dtmilano.android.adb.adbclient import AdbClient
from src.reader.welfare.welfare import Welfare
from datetime import datetime
from src.reader.bookshelf.bookshelf import Bookself
import time
class App:
def __init__(self):
device, serialno = ViewClient.connectToDeviceOrExit()
viewClient = ViewClient(device=device, serialno=serialno)
self.device = device
self.serialno = serialno
self.vc = viewClient
def openApp(self):
# 不管在何时 间隔点击两次home 保证 home 处于 第一页 (app在第二页)
self.device.press('KEYCODE_HOME')
time.sleep(2)
self.device.press('KEYCODE_HOME')
adb = AdbClient(serialno = self.serialno)
# db.shell(_cmd = 'pm list packages')
_cmd = 'input swipe %d %d %d %d' % (1000, 1800, 200, 1800)
adb.shell(_cmd=_cmd)
self.vc.dump()
# not found with ViewNotFoundException
adb.shell(' am force-stop com.dragon.read ') # kill 番茄小说 进程
self.vc.findViewWithTextOrRaise(u'番茄免费小说').touch()
print(u'正在打开番茄免费小说App,请稍等...')
time.sleep(10) # 等待app开启时广告
'''签到'''
def signIN(self):
try:
self.openApp()
self.vc.dump(5)
# 关闭签到弹出框
self.vc.touch(540, 1600)
except ViewNotFoundException:
# 如果出错,继续向下执行
print(u'立即签到 not found, current time is {0}'.format(datetime.now()))
def openHome(self):
# viewClient = ConnectDevice.openViewClient()
pass
def openPage(self):
pass
'''福利'''
def openWelfare(self) :
self.vc.dump(5)
self.vc.findViewWithText(u'福利').touch()
print(u'正在打开福利...')
# 休眠5s,等待页面加载
time.sleep(5)
self.vc.dump(5)
'''早晚9点睡觉'''
def sleep(self):
print(f'番茄免费阅读小说->python自动化睡觉 was started at %s ' % datetime.now())
self.openApp()
self.openWelfare()
self.vc.swipe(startX=500, startY=2000, endX=500, endY=1000)
welfare = Welfare(self.vc)
welfare.openSleep()
self.vc.swipe(startX=500, startY=2000, endX=500, endY=-1)
time.sleep(5)
welfare.openBox()
'''8:00/12:00/18:00吃饭'''
def eat(self):
print(f'番茄免费阅读小说->python自动化吃饭 was started at %s ' % datetime.now())
self.openApp()
self.openWelfare()
# 滑动到底部
self.vc.swipe(startX=500, startY=2000, endX=500, endY=-1)
time.sleep(5)
welfare = Welfare(self.vc)
welfare.openBox()
welfare.openEat()
'''书架'''
def openBoolshelf(self):
time.sleep(3)
self.vc.dump()
self.vc.findViewWithText(u'书架').touch()
print(u'正在打开书架...')
time.sleep(10)
'''我的'''
def openMine(self):
pass
'''阅读'''
def read(self):
print(f'番茄免费阅读小说->python自动化阅读 was started at %s '% datetime.now())
self.openApp()
self.openBoolshelf()
book = Bookself(self.vc)
book.openBookself()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/git_discovery/AutoReader.git
git@gitee.com:git_discovery/AutoReader.git
git_discovery
AutoReader
AutoReader
master

搜索帮助