Skip to content

Commit a596e99

Browse files
committed
feat(ticket): 优化获取票务信息的逻辑,增加错误处理和提示
1 parent af5b5fc commit a596e99

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

tab/settings.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,24 @@ def on_submit_data(_date):
837837
global ticket_str_list
838838
global ticket_value
839839
global is_hot_project
840+
global project_id
841+
global project_name
842+
840843
try:
841-
ticket_that_day = util.main_request.get(
844+
res = util.main_request.get(
842845
url=f"https://show.bilibili.com/api/ticket/project/infoByDate?id={project_id}&date={_date}"
843-
).json()["data"]
846+
)
847+
payload = res.json()
848+
ticket_that_day = payload.get("data")
849+
850+
if not ticket_that_day or "screen_list" not in ticket_that_day:
851+
gr.Warning("该日期暂无票务信息。")
852+
return [
853+
gr.update(value=_date, visible=True),
854+
gr.update(choices=[]),
855+
gr.update(value="", visible=False),
856+
]
857+
844858
ticket_str_list = []
845859
ticket_value = []
846860

0 commit comments

Comments
 (0)