Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bili/bilibili.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ def req_get(headers, url):
resp = requests.get(url, headers=headers)
# 检查响应体是否为空
if resp.text.strip(): # 使用strip()函数移除可能的空白字符
return json.loads(resp.text)
try:
return json.loads(resp.text)
except json.JSONDecodeError as e:
print("JSONDecodeError:", e)
print("Response text:", resp.text)
return None
else:
print("Empty response from url:", url)
return None # 返回None表示响应体为空
8 changes: 4 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_all_bili_history(cookie_file):

# 检查结果是否有效
if result is None or 'data' not in result or result['data'] is None:
if result.get('code') == 0:
if result and result['code'] == 0:
print("正常结束,没记录了哦(= ̄ω ̄=)\n\n")
else:
print("不正常结束,检查下有啥问题(´・_・`)")
Expand Down Expand Up @@ -111,9 +111,9 @@ def get_all_bili_history(cookie_file):


# 如果需要合并历史记录,取消下面三行的注释
old_history = load(OLD_HISTORY_FILE) # 确保这里加载的是列表
history = merge_histories(old_history, history)
history, first_time, last_time, count = process_history(history)
# old_history = load(OLD_HISTORY_FILE) # 确保这里加载的是列表
# history = merge_histories(old_history, history)
# history, first_time, last_time, count = process_history(history)


# 将时间戳转换为日期时间字符串
Expand Down