mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 优化未设置百度OCR文字识别API时的提醒信息,并打印日志
2. 优化天空签到返回信息
This commit is contained in:
@@ -190,6 +190,7 @@ class PtSpider:
|
|||||||
# 获取百度识别结果
|
# 获取百度识别结果
|
||||||
ocr = OCR.objects.filter(enable=True).first()
|
ocr = OCR.objects.filter(enable=True).first()
|
||||||
if not ocr:
|
if not ocr:
|
||||||
|
logging.error('未设置百度OCR文本识别API,无法使用本功能!')
|
||||||
return CommonResponse.error(
|
return CommonResponse.error(
|
||||||
status=StatusCodeEnum.OCR_NO_CONFIG,
|
status=StatusCodeEnum.OCR_NO_CONFIG,
|
||||||
)
|
)
|
||||||
@@ -416,11 +417,6 @@ class PtSpider:
|
|||||||
status=StatusCodeEnum.OK,
|
status=StatusCodeEnum.OK,
|
||||||
msg=message
|
msg=message
|
||||||
)
|
)
|
||||||
elif res_json.get('message') == 'invalid_imagehash':
|
|
||||||
# 验证码错误
|
|
||||||
return CommonResponse.error(
|
|
||||||
status=StatusCodeEnum.IMAGE_CODE_ERR,
|
|
||||||
)
|
|
||||||
elif res_json.get('message') == 'date_unmatch':
|
elif res_json.get('message') == 'date_unmatch':
|
||||||
# 重复签到
|
# 重复签到
|
||||||
message = '您今天已经在其他地方签到了哦!'
|
message = '您今天已经在其他地方签到了哦!'
|
||||||
@@ -430,11 +426,19 @@ class PtSpider:
|
|||||||
return CommonResponse.success(
|
return CommonResponse.success(
|
||||||
msg=message
|
msg=message
|
||||||
)
|
)
|
||||||
|
elif res_json.get('message') == 'invalid_imagehash':
|
||||||
|
# 验证码错误
|
||||||
|
return CommonResponse.error(
|
||||||
|
status=StatusCodeEnum.IMAGE_CODE_ERR,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# 签到失败
|
# 签到失败
|
||||||
return CommonResponse.error(
|
return CommonResponse.error(
|
||||||
status=StatusCodeEnum.FAILED_SIGN_IN,
|
status=StatusCodeEnum.FAILED_SIGN_IN,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
# 签到失败
|
||||||
|
return result
|
||||||
if 'hdarea.co' in site.url:
|
if 'hdarea.co' in site.url:
|
||||||
res = self.send_request(my_site=my_site,
|
res = self.send_request(my_site=my_site,
|
||||||
method=site.sign_in_method,
|
method=site.sign_in_method,
|
||||||
|
|||||||
Reference in New Issue
Block a user