Repository navigation
Releases
Releases · openzim/python-scraperlib
5.6.0
Added
VideoWebmMediumpreset: VP9 at 240k with the height capped at 720, a middle ground betweenVideoWebmLowandVideoWebmHigh(#271)ArticleUrlRewriter.denormalize/defuzzify(and their JS ports inwombatSetup.js), the best-effort reverse ofnormalize/the fuzzy rules, reconstructing a plausible (not guaranteed exact) original URL from a ZIM path (#396, #409)- Patch vendored
wombat.jssoextractOriginalURLdefers to a newwb_info.extract_original_url_functionhook (the same wayrewriteUrlalready defers towb_info.rewrite_function), letting it calldenormalize/defuzzifyfor cases its own pywb-oriented heuristic can never handle: CSSurl()reads,document.referrer, dynamically created elements, andlocation.replace()/.assign()/updateLocation(#396, #409) - Host-gated
SITE_JS_PATCHESmechanism inJsRewriter, to patch specific sites' JS content at rewrite time (#394) - Polyfill
crypto.randomUUID()when missing in a non-secure context (plain HTTP, non-localhost) (#391) - Polyfill
crypto.subtle.digest()(SHA-1/SHA-256) when missing in a non-secure context (#393)
Changed
VideoMp4Highnow encodes at CRF 28 instead of 20, which regularly produced a file larger than its input, and adds-movflags +faststart(#271)- All Webm presets (
VideoWebmLow,VideoWebmMedium,VideoWebmHigh) now use-row-mt 1for faster VP9 encoding (#271) - Bumped
VideoWebmLowto v4 andVideoWebmHighto v3 following the-row-mtaddition (#271) import zimscraperlib.zimno longer imports yt-dlp, beautifulsoup4 or lxml, andimport zimscraperlib.inputsno longer imports yt-dlp:stream_file,get_retry_adapterandfind_title_in_fileare now imported where they are used (#403)
Fixed
- Fix JS rewriting of
this.<prop>so it reliably detects a leading newline (and prepends the needed;) regardless of the amount of whitespace, and no longer wrongly rewritesthiswhen preceded by./$and several spaces (#381) - Align JS rewriting of
this.<prop>with the cleaner implementation wabac.js landed instead of ours (webrecorder/wabac.js#398, superseding our own webrecorder/wabac.js#395): a leadingthis.<prop>at the very start of a script is now rewritten too, and a preceding$only blocks the rewrite when directly adjacent (a.still blocks it regardless of the amount of whitespace in between) (#404) - Keep escaped Unicode characters in CSS strings instead of turning them into literal characters when rewriting (#376)
- Patch vendored
wombat.jsso element properties (img.src,script.src,link.href,a.hrefand its derived.pathname/.search/...,Attr.value) return and forget a server-side-rewriter-recorded original the same waygetAttributealready does (#386, webrecorder/wombat#240) - Detect
export const/let/var/function/async function/*as module code (EXPORT_RXonly recognizedexport {...},export defaultandexport class), fixing JS rewriting wrongly injecting a non-modulelet arguments;wrapper into ES modules using these common export forms, which is a syntax error in strict/module code (#387) - Fix JS URL rewriter confusing a percent-encoded
%2Bwith a raw+in query strings (#389) - Patch vendored
wombat.jssoretrieveWBOSRCAsURL(the helper behind the above element-property fix) resolves a recorded original against the frame's true original URL (wb_info.url) instead of its replay-timeownerDocument, fixing it returning/using a URL under the wrong host for a page whose own URL was changed by a fuzzy rule (e.g. YouTube embeds), which broke playback (#398) - Patch vendored
wombat.jssoCSSStyleSheet.prototype.replaceSync/.replace()(the Constructable Stylesheets API used by Shadow DOM web components) run their CSS text through the existingrewriteStyle()helper, fixingurl()references left unrewritten and 404ing on replay (#410, webrecorder/wombat#249) ArticleUrlRewriter.normalize()no longer decodes a percent-encoded/(%2F) in the path into a literal/, fixing a content collision between e.g./foo%2Fbar(one segment, containing a literal/) and/foo/bar(two segments), which used to normalize to the same ZIM path (#396, #406)ArticleUrlRewriter.escape_dot_segments()now also escapes a literal_./_..(and further escaped forms like__./__..) segment with one more leading_, fixing a content collision with the escaped form of an actual./..dot-segment, which used to normalize to the same ZIM path (#396, #406)ArticleUrlRewriter.normalize()now prefixes every ZIM path with a constantreplay://marker, andwombatSetup.js'surlRewriteFunction/head_insert.htmldo the same, fixing wombat.js computing an empty or single-/replay prefix ("wb_rel_prefix") for a ZIM served with no extra "collection" path segment (e.g. a barekiwix.app/<path>), which corrupted anyinnerHTML/outerHTMLread on the page by deleting arbitrary/text/spans, and caused related, quieter bugs inrewriteUrl/rewriteCookie(#396, #408, openzim/zimit#589)- developer.mozilla.org's
<interactive-example>widget always 404ing on replay due to a missing deterministicpermalinkattribute (#394) - Include values that violate metadata length restriction and names that violate custom metadata name conventions in
ValueErrormessages (#405)
5.5.2
Fixed
- Patch vendored
wombat.jssofetch()converts POST to GET likeXMLHttpRequestalready does, fixing YouTube embedded player video playback (#379, webrecorder/wombat#242) - Stop a
zim.Creatorabandoned before finishing (e.g. after an item path duplication) from hanging forever at garbage collection or interpreter exit: its libzim worker threads are now drained with the GIL released and the partially written ZIM is removed (#300)
5.5.1
Fixed
- Depend on
pymupdf-liteinstead ofpymupdf: samepymupdfmodule, without pymupdf 2.0 layout engine and the heavy dependencies (onnxruntime, numpy, ...) it pulled into every scraper; a scraper also depending on the fullpymupdfmust keep both at the same version (#372)
5.5.0
Added
- Index ePub documents for full-text search, with a new
get_epub_index_datahelper and automatic indexing of ePub items, like PDFs already are (#333) - Send a Wikimedia-compliant default
User-Agentinstream_filewhen downloading fromupload.wikimedia.org(#214) save_large_fileaccepts arbitrary HTTP headers and sends the default Wikimedia-compliantUser-Agentforupload.wikimedia.org, likestream_file(#360)- Add fuzzy rule to rewrite URLs of lesbases.anct.gouv.fr (#334)
- Report progress from
save_large_filethrough a newon_progresscallback and periodic logging, and stream the download to a.partfile that is only moved into place once complete (#348) - New
get_pdf_titleandget_epub_titlehelpers to get a document's title from its own metadata without extracting its full text content, cheaper thanget_pdf_index_data/get_epub_index_datawhen only the title is needed (openzim/warc2zim#462, #359)
Changed
- Upgrade to wombat 3.11.0 (#338)
- Upgrade Python dependencies, allowing pymupdf 2, pillow 13, beartype 0.23, urllib3 2.8 and xxhash 4, and Node.JS dependencies (#366, #369)
Fixed
- Rewrite
save_large_fileto stream and resume the download itself instead of runningwgetonce, whose-tcounter is a budget for the whole download: a flaky connection now keeps resuming and the retry budget only counts attempts that make no progress, so long downloads are no longer abandoned mid-way (#348) - Carry a script's top-level
const,let,classandfunctiondeclarations across the wombat block, so other scripts on the page can still see them, re-declaring classes withletso they can be reassigned (#329, #370, webrecorder/wabac.js#380) - Keep a rewritten
<script>'s originalsrcin__wb_orig_src, so wombat can return it fromgetAttribute("src")and bundlers that identify chunks by it (Next.js/Turbopack, Vite) still work (openzim/warc2zim#473, #337) - Keep the original of every rewritten
src,hrefandxlink:hrefin__wb_orig_<attr>, not just a script'ssrc, so wombat can return it instead of a broken URL (openzim/warc2zim#413, #338) - Keep URL-encoded
#characters of the path or querystring when rewriting document URIs, instead of dropping everything after them (#341) - Find the language of an HTML page in a
content-language<meta>that is not the first<meta>of the page (#356) - Rewrite the
posterattribute (e.g. of<video>) when rewriting HTML, likesrcandhref(#339) - Do not collapse consecutive slashes
//into a single/when normalizing URLs into ZIM paths, in both Python and JS rewriting (#340) - Resolve relative links against a page URL containing consecutive slashes
//the way browsers do, instead of collapsing them likeurllib.parse.urljoindoes (#346) Creator.finish()no longer silently discards errors raised by libzim while finalizing the ZIM, so a failure during finalization is no longer reported as a successful run (openzim/warc2zim#462, #354)- Escape
.and..path segments (e.g. folded into the path from a querystring) with a leading_when normalizing URLs into ZIM paths, so they are kept as literal entry names instead of being resolved away as navigation, in both Python and JS rewriting (#321)
5.4.1
5.4.0
Added
- Add support for custom number of retries and user-agent in save_large_file (#278)
- Enhance save_large_file log level (#279)
- Extend image optimization to support in-memory streams(BytesIO/bytes) and dst_format param (#289)
- Automatically add _ftindex:<yes/no> tag at creator start based on indexing configuration (#295)
- BEHAVIOR CHANGE: it is not possible anymore to add "Tags" metadata with Creator.add_metadata method after creator has started ; this is anyway not recommended anymore since 5.x (one should prefer Creator.config_metadata)
Fixed
- Add proper typing @overload to
zimscraperlib.image.optimize_xxxmethods (#273) - Backport wabac.JS change around rewriting: detect when JS is in 'strict' mode and avoid using 'arguments' (#286)
- Fix installation from source, which missed wombatSetup.js (#287)
- Fix outdated system dependencies in README: remove Pillow build-time deps (bundled in wheels), add missing
libcairoacross all platforms (#152) - Improve contribution setup instructions: use
hatch shell, clarify commands must be run from local clone root (#153) - Bring coverage back to 100% (#293)
- Fix
Creator.config_indexingdocstring to reflect that only the full-text index is toggled; title indexing is always performed by libzim (#294) - Fix
format_forto not modify input BytesIO position (#296)
### Changed
5.3.0
5.2.0
Added
- Add utility to fetch and prepare ZIM illustration (#254)
- New
zim.dedup.Deduplicatorclass to handle automatic deduplication of content before adding to the ZIM (#33)
Changed
- Upgrade dependencies, especially wombat 3.9.1 (#262, #263)
- Backport changes in wabac.js around JS rewriting rules (#259, #265)