From 5f1960d9725412b236abed5c00b9528ba2c9b716 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 18 Oct 2024 14:40:58 +0000 Subject: [PATCH] Use scraperlib content rewriting code --- scraper/pyproject.toml | 3 ++- scraper/src/libretexts2zim/processor.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scraper/pyproject.toml b/scraper/pyproject.toml index 0322b7d..10240b1 100644 --- a/scraper/pyproject.toml +++ b/scraper/pyproject.toml @@ -10,7 +10,8 @@ readme = "../README.md" dependencies = [ "yt-dlp", # youtube-dl should be updated as frequently as possible "jinja2==3.1.4", - "zimscraperlib==4.0.0", + #"zimscraperlib==4.0.0", + "zimscraperlib @ git+https://github.com/openzim/python-scraperlib@content_rewriting", "requests==2.32.3", "types-requests==2.32.0.20240914", "kiwixstorage==0.9.0", diff --git a/scraper/src/libretexts2zim/processor.py b/scraper/src/libretexts2zim/processor.py index fb686fd..928bd01 100644 --- a/scraper/src/libretexts2zim/processor.py +++ b/scraper/src/libretexts2zim/processor.py @@ -10,6 +10,12 @@ stream_file, # pyright: ignore[reportUnknownVariableType] ) from zimscraperlib.image import resize_image +from zimscraperlib.rewriting.css import CssRewriter +from zimscraperlib.rewriting.url_rewriting import ( + ArticleUrlRewriter, + HttpUrl, + ZimPath, +) from zimscraperlib.zim import Creator from zimscraperlib.zim.filesystem import validate_zimfile_creatable from zimscraperlib.zim.indexing import IndexData @@ -22,12 +28,6 @@ LibreTextsMetadata, ) from libretexts2zim.constants import LANGUAGE_ISO_639_3, NAME, ROOT_DIR, VERSION, logger -from libretexts2zim.content_rewriting.css import CssRewriter -from libretexts2zim.content_rewriting.url_rewriting import ( - ArticleUrlRewriter, - HttpUrl, - ZimPath, -) from libretexts2zim.ui import ( ConfigModel, PageContentModel,