Skip to content

Add get_pdf_title/get_epub_title, cheaper than get_*_index_data - #359

Merged
benoit74 merged 1 commit into
mainfrom
add-pdf-epub-title-only-helper
Oct 22, 2026
Merged

benoit74 merged 1 commit into
mainfrom
add-pdf-epub-title-only-helper

Conversation

@benoit74

Copy link
Copy Markdown
Collaborator

Summary

get_pdf_index_data/get_epub_index_data extract a document's full text content (page by page) in addition to its title, even when a caller only needs the title. This is unnecessary work when the content/full-text indexing isn't used.

Add get_pdf_title/get_epub_title: same title extraction logic (from the document's own title/author/subject metadata), without the page-by-page text extraction.

Internally, _get_document_index_data and the new _get_document_title now share _open_document/_get_metadata_title/_log_mupdf_warnings helpers instead of duplicating the logic.

This came up while fixing openzim/warc2zim#462: warc2zim only needs a PDF's title to decide whether to mark it as a front article, not its full text content.

benoit74 added a commit to openzim/warc2zim that referenced this pull request Oct 22, 2026
get_pdf_index_data also extracts the PDF's full text content, which
we don't use here (only the title, to decide front-article status).
Requires openzim/python-scraperlib#359.
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b5c0581) to head (9b5a78c).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #359   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         2801      2817   +16     
  Branches       416       416           
=========================================
+ Hits          2801      2817   +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit74 benoit74 self-assigned this Oct 22, 2026
get_pdf_index_data/get_epub_index_data extract a document's full text
content in addition to its title, even when only the title is needed.
Add get_pdf_title/get_epub_title to get just the title from a
document's own metadata, without the costly page-by-page text
extraction.
@benoit74
benoit74 force-pushed the add-pdf-epub-title-only-helper branch from 2b7e7db to 9b5a78c Compare October 22, 2026 08:00
@benoit74
benoit74 merged commit 2a661fe into main Oct 22, 2026
10 checks passed
@benoit74
benoit74 deleted the add-pdf-epub-title-only-helper branch October 22, 2026 08:03
benoit74 added a commit to openzim/warc2zim that referenced this pull request Oct 22, 2026
get_pdf_index_data also extracts the PDF's full text content, which
we don't use here (only the title, to decide front-article status).
Requires openzim/python-scraperlib#359.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant