fix(curator): query Douban only by Chinese title or ISBN, never a Latin title

Douban's English-language book records are sparse and low quality. BookPageProvider now picks a CJK title from the title or aliases for Douban (and still allows a precise ISBN), and skips Douban entirely when only a Latin title is available; Goodreads continues to cover Latin titles. Aliases now reach the page search so a translated book's Chinese title is used. New unit test covers the four cases; ISBN cross-title matching is preserved.
This commit is contained in:
Kai
2026-08-30 21:03:00 -07:00
parent 53ffa2fd7f
commit a337ea978f
3 changed files with 53 additions and 5 deletions
@@ -368,6 +368,35 @@ class CuratorTest(unittest.TestCase):
"非洲运转之道", "乔·斯塔威尔", "978-1-84668-407-9",
))
def test_douban_is_queried_only_with_a_chinese_title(self) -> None:
provider = BookPageProvider()
calls: list[tuple[str, str]] = []
provider._search_site = lambda prov, terms: calls.append((prov, terms)) or [] # type: ignore[method-assign]
# English-only title, no ISBN, no alias: Douban is skipped, Goodreads runs.
calls.clear()
provider.search("Clean Code", "Robert Martin")
self.assertEqual([p for p, _ in calls], ["goodreads"])
# A Chinese alias routes Douban to the Chinese title, not the English one.
calls.clear()
provider.search("Sapiens", "Yuval Noah Harari", aliases=["人类简史"])
douban = [t for p, t in calls if p == "douban"]
self.assertEqual(len(douban), 1)
self.assertIn("人类简史", douban[0])
self.assertNotIn("Sapiens", douban[0])
# A precise ISBN still reaches Douban even without a Chinese title.
calls.clear()
provider.search("How Africa Works", "", isbn="9781846684079")
douban = [t for p, t in calls if p == "douban"]
self.assertEqual(len(douban), 1)
self.assertIn("9781846684079", douban[0])
self.assertNotIn("How Africa Works", douban[0])
# A Chinese title is used directly (no regression).
calls.clear()
provider.search("三体", "刘慈欣")
douban = [t for p, t in calls if p == "douban"]
self.assertEqual(len(douban), 1)
self.assertIn("三体", douban[0])
def test_book_web_review_falls_back_and_caches_attributed_evidence(self) -> None:
provider = BookWebReviewProvider(self.settings, self.database)
calls: list[str] = []