mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-06 20:42:52 +08:00
14 lines
494 B
Python
14 lines
494 B
Python
import re
|
|
from typing import List, Tuple
|
|
|
|
|
|
def extract_screenshot_timestamps(markdown: str) -> List[Tuple[str, int]]:
|
|
pattern = r"(\*?Screenshot-(?:\[(\d{2}):(\d{2})\]|(\d{2}):(\d{2})))"
|
|
results: List[Tuple[str, int]] = []
|
|
for match in re.finditer(pattern, markdown):
|
|
mm = match.group(2) or match.group(4)
|
|
ss = match.group(3) or match.group(5)
|
|
total_seconds = int(mm) * 60 + int(ss)
|
|
results.append((match.group(1), total_seconds))
|
|
return results
|