fix: address Copilot review suggestions

- Remove unused Tuple import
- Validate /pN suffix p >= 1
- Reuse resolve_bilibili_short_url in fetch_subtitles
- Deduplicate short URL resolution
This commit is contained in:
wmsdsb137
2026-06-16 21:01:27 +08:00
parent 2ba409880e
commit ab9ca6a026
2 changed files with 9 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import re
from typing import Optional, Tuple
from typing import Optional
import requests
@@ -76,6 +76,8 @@ def extract_bilibili_p_number(url: str) -> Optional[int]:
# 匹配 /pN 尾缀形式(较少见)
match = re.search(r'/p(\d+)(?:/?$|\?|&)', url)
if match:
return int(match.group(1))
p_val = int(match.group(1))
if p_val >= 1:
return p_val
return None