dlxj commited on
Commit ·
fdee9a4
1
Parent(s): d4ff54a
成功下载序 目录树
Browse files- ocr/getdata.py +12 -8
- ocr/loader_pretty.json +0 -0
ocr/getdata.py
CHANGED
|
@@ -20,6 +20,7 @@ TARGET_PATTERNS = {
|
|
| 20 |
"pages": re.compile(r"/api/ancientlib/read/book/pages/v3/(?:\?|$)"),
|
| 21 |
"word_box": re.compile(r"/api/ancientlib/read/word-box-page-content/m-get/(?:\?|$)"),
|
| 22 |
"loader": re.compile(r"__loader=__session"),
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
IMAGE_URL_RE = re.compile(r"https?://[^ ]+(?:\.webp|\.image|\.png|\.jpe?g|\.bmp)(?:\?.*)?$", re.IGNORECASE)
|
|
@@ -374,8 +375,8 @@ def _enter_image_mode(driver: webdriver.Chrome) -> None:
|
|
| 374 |
|
| 375 |
def main() -> int:
|
| 376 |
ap = argparse.ArgumentParser()
|
| 377 |
-
ap.add_argument("--book-id", default="
|
| 378 |
-
ap.add_argument("--chapter", default="
|
| 379 |
ap.add_argument("--out", default="out")
|
| 380 |
ap.add_argument("--headless", action="store_true")
|
| 381 |
ap.add_argument("--timeout", type=int, default=20000)
|
|
@@ -500,12 +501,15 @@ def main() -> int:
|
|
| 500 |
img_saved.extend(initial_img_saved)
|
| 501 |
image_urls.extend(initial_image_urls)
|
| 502 |
else:
|
| 503 |
-
print(f"[DEBUG] Successfully loaded new chapter {args.chapter}.
|
| 504 |
-
for
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
|
|
|
|
|
|
|
|
|
| 509 |
|
| 510 |
time.sleep(0.8)
|
| 511 |
_enter_image_mode(driver)
|
|
|
|
| 20 |
"pages": re.compile(r"/api/ancientlib/read/book/pages/v3/(?:\?|$)"),
|
| 21 |
"word_box": re.compile(r"/api/ancientlib/read/word-box-page-content/m-get/(?:\?|$)"),
|
| 22 |
"loader": re.compile(r"__loader=__session"),
|
| 23 |
+
"volume": re.compile(r"/api/ancientlib/read/get/volume/(?:\?|$)"),
|
| 24 |
}
|
| 25 |
|
| 26 |
IMAGE_URL_RE = re.compile(r"https?://[^ ]+(?:\.webp|\.image|\.png|\.jpe?g|\.bmp)(?:\?.*)?$", re.IGNORECASE)
|
|
|
|
| 375 |
|
| 376 |
def main() -> int:
|
| 377 |
ap = argparse.ArgumentParser()
|
| 378 |
+
ap.add_argument("--book-id", default="TPM0001")
|
| 379 |
+
ap.add_argument("--chapter", default="金瓶梅詞話序")
|
| 380 |
ap.add_argument("--out", default="out")
|
| 381 |
ap.add_argument("--headless", action="store_true")
|
| 382 |
ap.add_argument("--timeout", type=int, default=20000)
|
|
|
|
| 501 |
img_saved.extend(initial_img_saved)
|
| 502 |
image_urls.extend(initial_image_urls)
|
| 503 |
else:
|
| 504 |
+
print(f"[DEBUG] Successfully loaded new chapter {args.chapter}. Merging missing data types from initial chapter data.")
|
| 505 |
+
for kind in ("pages", "word_box", "volume", "paragraphs"):
|
| 506 |
+
if not any(c.kind == kind for c in captured):
|
| 507 |
+
print(f"[DEBUG] Inheriting {kind} from initial capture.")
|
| 508 |
+
captured.extend([c for c in initial_captured if c.kind == kind])
|
| 509 |
+
|
| 510 |
+
# Keep initial images as they might be part of the same volume
|
| 511 |
+
img_saved.extend(initial_img_saved)
|
| 512 |
+
image_urls.extend(initial_image_urls)
|
| 513 |
|
| 514 |
time.sleep(0.8)
|
| 515 |
_enter_image_mode(driver)
|
ocr/loader_pretty.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|