Closed FledgeXu closed 1 year ago
Thanks for the report ; there are two issue:
get_media_info()
. I can't reproduce. Definitely not tied to libzim. Since this is returned directly from ffprobe
, I'm not much worried but we should find out what's happening:
I tested it with the ffprobe 5.1.2
and the bug is gone. It seems that ffmpeg 6.0
introduced this bug.
Even the duration is returned differently
❯ diff ffprobe5.1.2.csv ffprobe6.0.7.csv
3c3
< format,2.638000,3818365
---
> format,2.625000,3837275
system:
logs:
\n- PDF doc
\n - text ...="300" height="200">\n\n\n\n'
def test_zim_creator(tmp_path, png_image, html_file, html_str):
fpath = tmp_path / "test.zim"
main_path = "welcome"
tags = ";".join(["toto", "tata"])
with open(png_image, "rb") as fh:
png_data = fh.read()
with Creator(fpath, main_path).config_dev_metadata(
Tags=tags, Illustration_48x48_at_1=png_data
) as creator:
# verbatim HTML from string
creator.add_item_for("welcome", "wel", content=html_str, is_front=True)
# verbatim HTML from file
creator.add_item_for("welcome3", "wel3", fpath=html_file)
creator.add_item_for("welcome4", "wel4", fpath=html_file)
# single binary image
creator.add_item_for(
"images/yahoo.png", "Home !!", fpath=png_image, is_front=True
)
# redirect to our main page (no title)
creator.add_redirect("home", "welcome")
# redirect to our main page (with a custom title)
creator.add_redirect("home2", "welcome", "Home !!")
creator.add_redirect("home3", "welcome3", "Home !!", is_front=True)
creator.add_redirect("home4", "welcome4", "Home !!", is_front=False)
# ensure args requirement are checked
with pytest.raises(ValueError, match="One of fpath or content is required"):
creator.add_item_for("images/yahoo.png")
assert fpath.exists()
reader = Archive(fpath)
assert reader.get_text_metadata("Title") == DEFAULT_DEV_ZIM_METADATA["Title"]
assert reader.get_text_metadata("Language") == DEFAULT_DEV_ZIM_METADATA["Language"]
assert reader.get_text_metadata("Tags") == tags
assert reader.main_entry.get_item().path == f"{main_path}"
# make sure we have our image
assert reader.get_item("images/yahoo.png")
# make sure we have our redirects
assert reader.get_entry_by_path("home2").is_redirect
assert reader.get_entry_by_path("home2").get_redirect_entry().path == f"{main_path}"
# make sure titles were indexed (html with title for xapian ; redirects are not)
# see https://github.com/openzim/python-libzim/issues/125
# see https://github.com/openzim/libzim/issues/642
assert "home2" not in list(reader.get_suggestions("Home !!")) # no is_front > False
> assert "home3" in list(reader.get_suggestions("Home !!")) # is_front=True
E AssertionError: assert 'home3' in []
E + where [] = list(
)
E + where = ('Home !!')
E + where = Archive(filename=/private/var/folders/2h/kc3zwff52ws96r__pgrrqp540000gn/T/pytest-of-fledge/pytest-6/test_zim_creator0/test.zim).get_suggestions
tests/zim/test_zim_creator.py:93: AssertionError
----------------------------- Captured stdout call -----------------------------
Resolve redirect
set index
=============================== warnings summary ===============================
tests/i18n/test_i18n.py::test_lang_details[zh-Hans-expected0]
/Users/fledge/Developer/python-scraperlib/.tox/py311/lib/python3.11/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---------- coverage: platform darwin, python 3.11.3-final-0 ----------
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------------------------------------------
.tox/py311/lib/python3.11/site-packages/zimscraperlib/__init__.py 6 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/constants.py 16 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/download.py 80 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/filesystem.py 19 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/fix_ogvjs_dist.py 25 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/html.py 39 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/i18n.py 94 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/__init__.py 5 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/convertion.py 27 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/optimization.py 94 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/presets.py 62 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/probing.py 44 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/transformation.py 27 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/image/utils.py 7 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/inputs.py 22 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/logging.py 33 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/misc.py 3 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/types.py 19 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/uri.py 17 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/video/__init__.py 3 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/video/config.py 92 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/video/encoding.py 22 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/video/presets.py 27 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/video/probing.py 9 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/__init__.py 8 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/_libkiwix.py 78 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/archive.py 52 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/creator.py 136 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/filesystem.py 62 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/items.py 77 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/metadata.py 46 0 100%
.tox/py311/lib/python3.11/site-packages/zimscraperlib/zim/providers.py 46 0 100%
-------------------------------------------------------------------------------------------------------------
TOTAL 1297 0 100%
=========================== short test summary info ============================
FAILED tests/video/test_video.py::test_get_media_info[mp4-video.mp4-expected1]
FAILED tests/zim/test_zim_creator.py::test_zim_creator - AssertionError: asse...
================== 2 failed, 317 passed, 1 warning in 34.34s ===================
py311: exit 1 (34.55 seconds) /Users/fledge/Developer/python-scraperlib> pytest --runslow --runinstalled --cov=zimscraperlib --cov-report=term --cov-report term-missing pid=39839
.pkg: _exit> python /Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py311: FAIL code 1 (35.60=setup[1.05]+cmd[34.55] seconds)
evaluation failed :( (35.63 seconds)
```
This looks like a bug in
python-libzim
, notpython-scraperlib
.