citeget 0.2.24__tar.gz → 0.2.26__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/fetch-resources/SKILL.md +19 -5
  2. {citeget-0.2.24 → citeget-0.2.26}/CLAUDE.md +2 -0
  3. {citeget-0.2.24 → citeget-0.2.26}/PKG-INFO +1 -1
  4. {citeget-0.2.24 → citeget-0.2.26}/citeget/acquire_references.py +16 -1
  5. {citeget-0.2.24 → citeget-0.2.26}/citeget/cli.py +4 -0
  6. citeget-0.2.26/citeget/content.py +772 -0
  7. {citeget-0.2.24 → citeget-0.2.26}/citeget/extract.py +49 -4
  8. {citeget-0.2.24 → citeget-0.2.26}/citeget/fetch.py +243 -88
  9. {citeget-0.2.24 → citeget-0.2.26}/pyproject.toml +1 -1
  10. {citeget-0.2.24 → citeget-0.2.26}/tests/cli_goldens/citeget.json +2 -2
  11. citeget-0.2.26/tests/fixtures/pages/danluu_wat.full.md +155 -0
  12. citeget-0.2.26/tests/fixtures/pages/danluu_wat.html +2 -0
  13. citeget-0.2.26/tests/fixtures/pages/idlewords_haunted_by_data.full.md +60 -0
  14. citeget-0.2.26/tests/fixtures/pages/idlewords_haunted_by_data.html +485 -0
  15. citeget-0.2.26/tests/fixtures/pages/joelonsoftware_talmud.full.md +71 -0
  16. citeget-0.2.26/tests/fixtures/pages/joelonsoftware_talmud.html +252 -0
  17. citeget-0.2.26/tests/fixtures/pages/make_fixtures.py +95 -0
  18. citeget-0.2.26/tests/fixtures/pages/paulgraham_avg.full.md +5 -0
  19. citeget-0.2.26/tests/fixtures/pages/paulgraham_avg.html +396 -0
  20. citeget-0.2.26/tests/fixtures/pages/wayback_nytimes_federer.full.md +358 -0
  21. citeget-0.2.26/tests/fixtures/pages/wayback_nytimes_federer.html +174 -0
  22. {citeget-0.2.24 → citeget-0.2.26}/tests/test_extract.py +58 -0
  23. citeget-0.2.26/tests/test_fetch_ownership_and_extraction.py +432 -0
  24. citeget-0.2.26/tests/test_main_content_pages.py +181 -0
  25. citeget-0.2.24/citeget/content.py +0 -229
  26. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/acquire-references/SKILL.md +0 -0
  27. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/SKILL.md +0 -0
  28. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/add-references.skill +0 -0
  29. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/TEMPLATE.md +0 -0
  30. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/ai-ml.md +0 -0
  31. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/math-combinatorics.md +0 -0
  32. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/parameters.md +0 -0
  33. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/social-sciences.md +0 -0
  34. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/add-references/references/tech-blog.md +0 -0
  35. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/check-submission-fit/SKILL.md +0 -0
  36. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/format-for-journal/SKILL.md +0 -0
  37. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/get-books/SKILL.md +0 -0
  38. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/prepare-submission/SKILL.md +0 -0
  39. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/research-topic/SKILL.md +0 -0
  40. {citeget-0.2.24 → citeget-0.2.26}/.claude/skills/review-article/SKILL.md +0 -0
  41. {citeget-0.2.24 → citeget-0.2.26}/.editorconfig +0 -0
  42. {citeget-0.2.24 → citeget-0.2.26}/.gitattributes +0 -0
  43. {citeget-0.2.24 → citeget-0.2.26}/.github/workflows/ci.yml +0 -0
  44. {citeget-0.2.24 → citeget-0.2.26}/.gitignore +0 -0
  45. {citeget-0.2.24 → citeget-0.2.26}/CHANGELOG.md +0 -0
  46. {citeget-0.2.24 → citeget-0.2.26}/LICENSE +0 -0
  47. {citeget-0.2.24 → citeget-0.2.26}/README.md +0 -0
  48. {citeget-0.2.24 → citeget-0.2.26}/citeget/__init__.py +0 -0
  49. {citeget-0.2.24 → citeget-0.2.26}/citeget/__main__.py +0 -0
  50. {citeget-0.2.24 → citeget-0.2.26}/citeget/article_pub/__init__.py +0 -0
  51. {citeget-0.2.24 → citeget-0.2.26}/citeget/article_pub/data/journal_profiles.json +0 -0
  52. {citeget-0.2.24 → citeget-0.2.26}/citeget/article_pub/scripts/check_article.py +0 -0
  53. {citeget-0.2.24 → citeget-0.2.26}/citeget/article_pub/scripts/extract_references.py +0 -0
  54. {citeget-0.2.24 → citeget-0.2.26}/citeget/article_pub/scripts/word_count.py +0 -0
  55. {citeget-0.2.24 → citeget-0.2.26}/citeget/core.py +0 -0
  56. {citeget-0.2.24 → citeget-0.2.26}/citeget/data/libgen_vg_report.md +0 -0
  57. {citeget-0.2.24 → citeget-0.2.26}/citeget/joblimit.py +0 -0
  58. {citeget-0.2.24 → citeget-0.2.26}/citeget/merge_keyed.py +0 -0
  59. {citeget-0.2.24 → citeget-0.2.26}/citeget/names.py +0 -0
  60. {citeget-0.2.24 → citeget-0.2.26}/citeget/netguard.py +0 -0
  61. {citeget-0.2.24 → citeget-0.2.26}/citeget/rank.py +0 -0
  62. {citeget-0.2.24 → citeget-0.2.26}/citeget/resolve.py +0 -0
  63. {citeget-0.2.24 → citeget-0.2.26}/citeget/validate.py +0 -0
  64. {citeget-0.2.24 → citeget-0.2.26}/cookies.txt +0 -0
  65. {citeget-0.2.24 → citeget-0.2.26}/tests/__init__.py +0 -0
  66. {citeget-0.2.24 → citeget-0.2.26}/tests/cli_goldens/citeget_module.json +0 -0
  67. {citeget-0.2.24 → citeget-0.2.26}/tests/conftest.py +0 -0
  68. {citeget-0.2.24 → citeget-0.2.26}/tests/test_browser_session.py +0 -0
  69. {citeget-0.2.24 → citeget-0.2.26}/tests/test_browserguard.py +0 -0
  70. {citeget-0.2.24 → citeget-0.2.26}/tests/test_cli_surface.py +0 -0
  71. {citeget-0.2.24 → citeget-0.2.26}/tests/test_core_mirrors.py +0 -0
  72. {citeget-0.2.24 → citeget-0.2.26}/tests/test_download_paths.py +0 -0
  73. {citeget-0.2.24 → citeget-0.2.26}/tests/test_fetch_query_collision.py +0 -0
  74. {citeget-0.2.24 → citeget-0.2.26}/tests/test_fetch_retry_titles.py +0 -0
  75. {citeget-0.2.24 → citeget-0.2.26}/tests/test_finalize.py +0 -0
  76. {citeget-0.2.24 → citeget-0.2.26}/tests/test_html_to_markdown.py +0 -0
  77. {citeget-0.2.24 → citeget-0.2.26}/tests/test_job_budget.py +0 -0
  78. {citeget-0.2.24 → citeget-0.2.26}/tests/test_joblimit.py +0 -0
  79. {citeget-0.2.24 → citeget-0.2.26}/tests/test_main_content.py +0 -0
  80. {citeget-0.2.24 → citeget-0.2.26}/tests/test_merge_keyed.py +0 -0
  81. {citeget-0.2.24 → citeget-0.2.26}/tests/test_names.py +0 -0
  82. {citeget-0.2.24 → citeget-0.2.26}/tests/test_netguard.py +0 -0
  83. {citeget-0.2.24 → citeget-0.2.26}/tests/test_rank.py +0 -0
  84. {citeget-0.2.24 → citeget-0.2.26}/tests/test_resolve.py +0 -0
  85. {citeget-0.2.24 → citeget-0.2.26}/tests/test_search_retries.py +0 -0
  86. {citeget-0.2.24 → citeget-0.2.26}/tests/test_validate.py +0 -0
@@ -92,17 +92,28 @@ URLs are extracted in three forms (deduped, first match wins):
92
92
  Otherwise try HTML→PDF via `pdfkit`/`wkhtmltopdf`. With the network
93
93
  guard on (the default) the page is rendered offline, as text: no images
94
94
  or styles in the PDF.
95
- 4. Otherwise convert HTML→Markdown via `markdownify` (clean, link-preserving).
95
+ 4. Otherwise convert HTML→Markdown via `markdownify` (clean, link-preserving). By default only the **main article** is kept (`content="main"`): navigation, sidebars, comments, share bars, breadcrumbs, ad slots and layout tables are dropped, and the document leads with the page title. `--content full` keeps the whole page. `--content-extractor trafilatura` swaps in a stronger extractor (`pip install trafilatura`); any `html -> html` callable works from Python. Web Archive copies are cleaned in both modes (toolbar gone, links pointing back at the original site).
96
96
  5. If a PDF route fails, fall back to Markdown automatically.
97
97
 
98
+ Connection resets, 429 and 5xx are retried (`--retries`, default 2), with doubling backoff or the server's `Retry-After`, capped at 60 s. A 404 or a refused URL is never retried.
99
+
98
100
  ### Filename inference
99
101
 
100
102
  Files are named in this priority order:
101
103
  1. Anchor / citation title → slug
102
- 2. URL's last path segment
103
- 3. `{domain}-{hash}`
104
+ 2. The page's own title (`og:title`, `<title>`, `<h1>`), with the site name removed: `Title – Site` and `Site – Title` are told apart using `og:site_name`, the `<h1>` and the URL's path; with no such evidence the first segment is kept
105
+ 3. URL's last path segment, with its query folded in (`?currentPage=2` → `-currentpage-2`)
106
+ 4. `{domain}-{hash}`
107
+
108
+ Reference numbers become a prefix: `ref_03_some-title.md`. The manifest's `title` is the anchor text if there was one, else the page title.
109
+
110
+ ### Skipping, and which file belongs to which URL
111
+
112
+ Every Markdown file starts with a `<!-- Source: URL -->` line, and that line, not the filename, says which URL the file belongs to. So:
104
113
 
105
- Reference numbers become a prefix: `ref_03_some-title.md`.
114
+ - `skip_existing` (the default) skips a URL only when a file of the same format already belongs to it, so a `SKIP` really means "already have this page". A folder saved by an older citeget, under older names, is matched by those headers too: the page is skipped, not saved twice.
115
+ - Two different URLs never share a file. When the preferred name is taken by another URL, the query is folded in, else a short hash of the URL.
116
+ - PDFs and other non-Markdown files carry no source record. Within one run they are still kept apart. Across runs, an existing PDF of the same name is taken to be the same document and skipped: [thorwhalen/citeget#32](https://github.com/thorwhalen/citeget/issues/32) tracks that case.
106
117
 
107
118
  ## Format choice (`--prefer` / `prefer=`)
108
119
 
@@ -163,7 +174,10 @@ results = fetch(
163
174
  ## Failure handling
164
175
 
165
176
  - Network/HTTP errors are logged and the URL is marked `failed` in the
166
- result; other URLs still proceed.
177
+ result; other URLs still proceed. Transient ones were already retried
178
+ (see above), so re-running at once rarely helps.
179
+ - If main-content extraction cut something the user wanted (a comment
180
+ thread, a sidebar table), re-run that URL with `--content full`.
167
181
  - For JS-heavy pages where markdownify gives poor output, suggest re-running
168
182
  with `--prefer pdf` (renders the page) or use the `WebFetch` tool as a
169
183
  second opinion.
@@ -79,6 +79,8 @@ Install playwright browsers: `python -m playwright install chromium`
79
79
  attempt (`page.goto` raising "Download is starting" is success, not failure)
80
80
  - Validation policy is injected, not hardcoded: `DEFAULT_POLICY` (integrity)
81
81
  vs `BOOK_POLICY` (adds page-count/markup depth checks — wrong for articles)
82
+ - `fetch` keeps the **main content** by default (`content="full"` for the whole page); the extractor is a strategy (`"readability-lite"`, `"trafilatura"`, or any `html -> html` callable). Its real-page fixtures are pages with the prose replaced by same-length filler: regenerate with `tests/fixtures/pages/make_fixtures.py`, never commit whole articles.
83
+ - `fetch` output files are owned by a URL: the `<!-- Source: -->` header (not the filename) is what `skip_existing` and collision handling check, so keep it the first line of every `.md`. Non-Markdown files carry no such record (#32).
82
84
  - **Libgen returns spurious empty result sets** (~1 run in 4 for a query with
83
85
  real matches). Defended in three layers — retry per mirror, require two
84
86
  mirrors to agree, then `get_book` re-runs the whole search. Never treat one
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: citeget
3
- Version: 0.2.24
3
+ Version: 0.2.26
4
4
  Summary: Find, acquire, and manage academic references — for AI agents and humans.
5
5
  Project-URL: Homepage, https://github.com/thorwhalen/citeget
6
6
  Project-URL: Repository, https://github.com/thorwhalen/citeget
@@ -162,6 +162,12 @@ class AcquisitionResult:
162
162
  notes: str = ""
163
163
 
164
164
 
165
+ #: A single-quoted title: the quote opens a word and closes one (no apostrophes).
166
+ _SINGLE_QUOTED_TITLE = re.compile(r"(?<!\w)['\u2018](.+?)['\u2019](?!\w)")
167
+ #: The author after a title, in ``"Title," by Author, 2019``.
168
+ _BY_AUTHOR = re.compile(r"[\s,.]*\bby\s+(.+?)\s*(?:,\s*(?:19|20)\d{2})?\s*\.?\s*$")
169
+
170
+
165
171
  def parse_reference(text: str, number: int = 0) -> Reference:
166
172
  """Parse a reference string into a Reference object.
167
173
 
@@ -172,7 +178,7 @@ def parse_reference(text: str, number: int = 0) -> Reference:
172
178
  raw = text.strip()
173
179
 
174
180
  # Extract number if present
175
- num_match = re.match(r"\[(\d+)\]\s*", raw)
181
+ num_match = re.match(r"\[(\d+)\.?\]\s*", raw)
176
182
  if num_match:
177
183
  number = int(num_match.group(1))
178
184
  raw_body = raw[num_match.end() :]
@@ -189,6 +195,10 @@ def parse_reference(text: str, number: int = 0) -> Reference:
189
195
  title = ""
190
196
  # Try quoted title first: "Title" or "Title,"
191
197
  title_match = re.search(r'["\u201c](.+?)["\u201d]', raw_body)
198
+ if title_match is None:
199
+ # Short citations often single-quote the title: ron chernow 'hamilton'.
200
+ # The quote must open a word and close one, so apostrophes don't match.
201
+ title_match = _SINGLE_QUOTED_TITLE.search(raw_body)
192
202
  if title_match:
193
203
  title = title_match.group(1).rstrip(",").strip()
194
204
 
@@ -202,6 +212,11 @@ def parse_reference(text: str, number: int = 0) -> Reference:
202
212
  authors = ""
203
213
  if title_match:
204
214
  authors = raw_body[: title_match.start()].strip().rstrip(",").strip()
215
+ if not authors:
216
+ # "Title," by Author, 2019
217
+ by_match = _BY_AUTHOR.match(raw_body[title_match.end() :])
218
+ if by_match:
219
+ authors = by_match.group(1).strip()
205
220
  else:
206
221
  # Fallback: take everything before first comma-separated chunk with year
207
222
  parts = raw_body.split(",")
@@ -224,6 +224,7 @@ def fetch(
224
224
  content: str = "main",
225
225
  content_extractor: str = "readability-lite",
226
226
  include_links: bool = True,
227
+ retries: int = 2,
227
228
  ):
228
229
  """Fetch URLs and save them as Markdown (default), PDF, or original.
229
230
 
@@ -245,6 +246,8 @@ def fetch(
245
246
  content_extractor: "readability-lite" (default, no extra dependency)
246
247
  or "trafilatura" (needs `pip install trafilatura`).
247
248
  include_links: If false, links are reduced to their text.
249
+ retries: Extra attempts on connection resets, 429 and 5xx (default 2;
250
+ 0 for one attempt). A server's Retry-After is honoured, up to 60s.
248
251
  """
249
252
  import json
250
253
  from pathlib import Path
@@ -276,6 +279,7 @@ def fetch(
276
279
  content=content,
277
280
  content_extractor=content_extractor,
278
281
  include_links=include_links,
282
+ retries=retries,
279
283
  )
280
284
 
281
285
  ok = sum(1 for r in results if r.status == "ok")