Skip to content

Commit

Permalink
流程优化
Browse files Browse the repository at this point in the history
create 项目不可售 等待开票

验证加载try

token获取后查询票数&输出增加

"程序正在准备退出..."提示增加

token获取成功后查询票数
  • Loading branch information
Hobr committed Jun 28, 2024
1 parent 84a002c commit 762ca46
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.
11 changes: 9 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import threading
from time import sleep

from bili_ticket_gt_python import ClickPy
from loguru import logger
Expand Down Expand Up @@ -52,8 +53,14 @@
productData = Config(dir="product")
settingData = Config(dir="setting")
# 验证
gtPy = ClickPy()
cap = Captcha(gtPy=gtPy)
try:
gtPy = ClickPy()
cap = Captcha(gtPy=gtPy)
except Exception:
logger.error("【自动过验证】初始化失败!")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

# 检测配置文件情况
userList = userData.List()
Expand Down
9 changes: 4 additions & 5 deletions util/Bilibili/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,12 @@ def CreateOrder(self) -> int:
sleep(5)
exit()

# TODO 项目不可售 等待开票
# 项目不可售 等待开票
elif code == 100016:
logger.error("【创建订单】该项目目前不可售!")
# logger.warning("程序正在准备退出...")
# sleep(5)
# exit()
return 3
logger.warning("程序正在准备退出...")
sleep(5)
exit()

# 失败
else:
Expand Down
2 changes: 2 additions & 0 deletions util/Captcha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def Manual(self, challenge) -> str:

if not browser_list:
logger.error("【登录】未找到可用浏览器/WebDriver! 建议选择其他方式登录")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand All @@ -91,6 +92,7 @@ def Manual(self, challenge) -> str:

if not driver:
logger.error("【登录】所有浏览器/WebDriver尝试登录均失败")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand Down
1 change: 1 addition & 0 deletions util/Config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def List(self) -> list:

except Exception as e:
logger.exception(f"【配置】读取配置列表错误! {e}")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand Down
3 changes: 3 additions & 0 deletions util/Data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def QRGenerate(self, url: str) -> None:
parent_name = parent_process.name()
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
logger.error("获取父进程信息失败!")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand Down Expand Up @@ -197,6 +198,7 @@ def AESDecrypt(self, data: str) -> str:
return decrypted_text.decode("utf-8")
except Exception:
logger.error("【解密】这是你的配置吗?")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand Down Expand Up @@ -263,5 +265,6 @@ def Inquire(
return res["res"]
else:
logger.error("【交互】未知错误!")
logger.warning("程序正在准备退出...")
sleep(5)
exit()
1 change: 1 addition & 0 deletions util/Login/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def Status(self) -> dict:
return self.cookie
else:
logger.error("【登录状态检测】登录失败")
logger.warning("程序正在准备退出...")
sleep(5)
exit()

Expand Down
1 change: 1 addition & 0 deletions util/Request/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,6 @@ def ResponseHook(self, response: httpx.Response) -> None:
logger.error(f"【Request响应】请求错误, 状态码: {response.status_code}")
else:
logger.error("【Request响应】IP被412风控!!!!!请更换IP后再次使用(重启路由器/使用手机流量热点/梯子...)")
logger.warning("程序正在准备退出...")
sleep(5)
exit()
10 changes: 9 additions & 1 deletion util/Task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ def QueryTokenAction(self) -> None:
返回值: 0-成功, 1-验证码, 2-失败
"""
self.queryTokenResult = self.api.QueryToken()

# 顺路
self.api.QueryAmount()
if self.queryTokenResult == 0:
self.api.QueryAmount()

# 防风控
sleep(self.sleep)

@logger.catch
Expand All @@ -190,6 +194,8 @@ def QueryTicketAction(self) -> None:
返回值: True-成功, False-失败
"""
self.queryTicketResult = self.api.QueryAmount()

# 防风控
sleep(self.sleep)

@logger.catch
Expand All @@ -200,6 +206,8 @@ def CreateOrderAction(self) -> None:
返回值: 0-成功, 1-刷新, 2-等待, 3-失败
"""
self.createOrderResult = self.api.CreateOrder()

# 防风控
sleep(self.sleep)

@logger.catch
Expand Down

0 comments on commit 762ca46

Please sign in to comment.