优化输出信息
This commit is contained in:
@@ -12,8 +12,10 @@
|
|||||||
- [x] 电话语音通知
|
- [x] 电话语音通知
|
||||||
- [x] 多账号、多任务、多线程支持
|
- [x] 多账号、多任务、多线程支持
|
||||||
- [x] 单个任务多站点查询
|
- [x] 单个任务多站点查询
|
||||||
|
- [ ] 分布式运行
|
||||||
- [ ] Docker 支持
|
- [ ] Docker 支持
|
||||||
- [ ] 邮件通知
|
- [ ] 邮件通知
|
||||||
|
- [ ] Web 管理页面
|
||||||
|
|
||||||
## 使用
|
## 使用
|
||||||
py12306 需要运行在 python 3.6 以上版本(其它版本暂未测试)
|
py12306 需要运行在 python 3.6 以上版本(其它版本暂未测试)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import math
|
||||||
|
import random
|
||||||
|
|
||||||
from py12306 import config
|
from py12306 import config
|
||||||
from py12306.log.common_log import CommonLog
|
from py12306.log.common_log import CommonLog
|
||||||
from py12306.vender.ruokuai.main import RKClient
|
from py12306.vender.ruokuai.main import RKClient
|
||||||
@@ -32,39 +35,18 @@ class OCR:
|
|||||||
|
|
||||||
def get_image_position_by_offset(self, offsets):
|
def get_image_position_by_offset(self, offsets):
|
||||||
positions = []
|
positions = []
|
||||||
|
width = 70
|
||||||
|
height = 70
|
||||||
|
random_num = random.randint(0, 10)
|
||||||
for offset in offsets:
|
for offset in offsets:
|
||||||
if offset == '1':
|
offset = int(offset)
|
||||||
y = 46
|
x = width * (offset % 5) - width / 2 + random_num
|
||||||
x = 42
|
y = height * math.ceil(offset / 4) - height / 2 - random_num
|
||||||
elif offset == '2':
|
positions.append(int(x))
|
||||||
y = 46
|
positions.append(int(y))
|
||||||
x = 105
|
|
||||||
elif offset == '3':
|
|
||||||
y = 45
|
|
||||||
x = 184
|
|
||||||
elif offset == '4':
|
|
||||||
y = 48
|
|
||||||
x = 256
|
|
||||||
elif offset == '5':
|
|
||||||
y = 36
|
|
||||||
x = 117
|
|
||||||
elif offset == '6':
|
|
||||||
y = 112
|
|
||||||
x = 115
|
|
||||||
elif offset == '7':
|
|
||||||
y = 114
|
|
||||||
x = 181
|
|
||||||
elif offset == '8':
|
|
||||||
y = 111
|
|
||||||
x = 252
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
positions.append(x)
|
|
||||||
positions.append(y)
|
|
||||||
return positions
|
return positions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pass
|
pass
|
||||||
# code_result = AuthCode.get_auth_code()
|
# code_result = AuthCode.get_auth_code()
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ class UserJob:
|
|||||||
elif result.get('result_code') == 2: # 账号之内错误
|
elif result.get('result_code') == 2: # 账号之内错误
|
||||||
# 登录失败,用户名或密码为空
|
# 登录失败,用户名或密码为空
|
||||||
# 密码输入错误
|
# 密码输入错误
|
||||||
UserLog.add_quick_log(UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message')))
|
UserLog.add_quick_log(UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message'))).flush()
|
||||||
else:
|
else:
|
||||||
UserLog.add_quick_log(
|
UserLog.add_quick_log(
|
||||||
UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message', result.get('message', '-'))))
|
UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message', result.get('message', '-')))).flush()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -117,6 +117,9 @@ class UserJob:
|
|||||||
is_login = response.json().get('data').get('flag', False)
|
is_login = response.json().get('data').get('flag', False)
|
||||||
if is_login:
|
if is_login:
|
||||||
self.save_user()
|
self.save_user()
|
||||||
|
self.get_user_info() # 检测应该是不会维持状态,这里再请求下个人中心看有没有有
|
||||||
|
|
||||||
|
|
||||||
return is_login
|
return is_login
|
||||||
|
|
||||||
def auth_uamtk(self):
|
def auth_uamtk(self):
|
||||||
@@ -168,12 +171,11 @@ class UserJob:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER.format(self.user_name))
|
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER.format(self.user_name))
|
||||||
if self.check_user_is_login():
|
if self.check_user_is_login() and self.get_user_info():
|
||||||
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER_SUCCESS.format(self.user_name))
|
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER_SUCCESS.format(self.user_name)).flush()
|
||||||
self.get_user_info()
|
|
||||||
UserLog.print_welcome_user(self)
|
UserLog.print_welcome_user(self)
|
||||||
else:
|
else:
|
||||||
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER_BUT_EXPIRED)
|
UserLog.add_quick_log(UserLog.MESSAGE_LOADED_USER_BUT_EXPIRED).flush()
|
||||||
|
|
||||||
def get_user_info(self):
|
def get_user_info(self):
|
||||||
response = self.session.get(API_USER_INFO.get('url'))
|
response = self.session.get(API_USER_INFO.get('url'))
|
||||||
@@ -205,7 +207,7 @@ class UserJob:
|
|||||||
return self.passengers
|
return self.passengers
|
||||||
else:
|
else:
|
||||||
UserLog.add_quick_log(
|
UserLog.add_quick_log(
|
||||||
UserLog.MESSAGE_GET_USER_PASSENGERS_FAIL.format(result.get('messages', '-'), self.retry_time))
|
UserLog.MESSAGE_GET_USER_PASSENGERS_FAIL.format(result.get('messages', '-'), self.retry_time)).flush()
|
||||||
stay_second(self.retry_time)
|
stay_second(self.retry_time)
|
||||||
return self.get_user_passengers()
|
return self.get_user_passengers()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user