warc2zim 2.2.0__tar.gz → 2.2.2__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.
- {warc2zim-2.2.0 → warc2zim-2.2.2}/.pre-commit-config.yaml +4 -18
- {warc2zim-2.2.0 → warc2zim-2.2.2}/CHANGELOG.md +13 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/Dockerfile +1 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/PKG-INFO +21 -19
- {warc2zim-2.2.0 → warc2zim-2.2.2}/contrib/cleanup_log.py +2 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/contrib/html_convert.py +7 -4
- {warc2zim-2.2.0 → warc2zim-2.2.2}/contrib/marxists.org.py +3 -3
- warc2zim-2.2.2/docs/software_architecture.md +26 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/pyproject.toml +16 -16
- warc2zim-2.2.2/src/warc2zim/__about__.py +1 -0
- warc2zim-2.2.2/src/warc2zim/cdxj_indexer/__init__.py +9 -0
- warc2zim-2.2.2/src/warc2zim/cdxj_indexer/bufferiter.py +130 -0
- warc2zim-2.2.2/src/warc2zim/cdxj_indexer/main.py +17 -0
- warc2zim-2.2.2/src/warc2zim/cdxj_indexer/postquery.py +173 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/constants.py +1 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/converter.py +5 -5
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/items.py +1 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/rewriting.py +1 -1
- warc2zim-2.2.2/tests/cdxj_indexer/test_postappend.py +203 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_utils.py +1 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_warc_to_zim.py +2 -1
- warc2zim-2.2.0/src/warc2zim/__about__.py +0 -1
- {warc2zim-2.2.0 → warc2zim-2.2.2}/.eslintrc.json +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/.gitignore +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/LICENSE +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/README.md +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/__init__.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/icon_finder.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/language.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/main.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/templates/head_insert.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/src/warc2zim/utils.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tasks.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/Caddyfile +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/Dockerfile +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/README.md +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/audio.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/bad-encoding.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/bad-redirections.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/base-href/image1.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/base-href/something.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/base-href.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/chinese-encoding.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/content1.json +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/content2.json +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/image1.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/image2.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/index.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/script1.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/script2.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/small.pdf +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/style1.css +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/content-types/style2.css +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/css-broken-file.css +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/css-broken-file.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/css-inline-broken.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/dailymotion.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/double-slash.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/facebook1.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/facebook2.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/form-get-1.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/form-get-2.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/form-get-3.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/form-get-4.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/form-get.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/full.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/href-to-folder/index.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/http-equiv-redirect.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/http-return-codes.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/android-chrome-192x192.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/android-chrome-512x512.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/apple-touch-icon.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/favicon-16x16.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/favicon-32x32.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/favicon.ico +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/icons/site.webmanifest +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/image-srcset.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image1-1x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image1-2x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image1.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image2-1x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image2-2x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image2.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image3-high.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image3-medium.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image3-small.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image3.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image4-1.5x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/image4.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding1_ico/314/202ne-de/314/201buter-Solidarite/314/201-Nume/314/201rique_1@300x.png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding2_ico%CC%82ne-de%CC%81buter-Solidarite%CC%81-Nume%CC%81rique_1%40300x.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding3_ico/314/202ne-de/314/201buter-Solidarite%CC%81-Nume%CC%81rique_1@300x.png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding4_(_[_|_]_).png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding4_/330/274.png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding5_(_[_|_/330/274_]_).png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding5_(_[_|_/330/274_]_)_1.png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/images/urlencoding5_(_[_|_/330/274_]_)_2.png" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/index.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/instagram.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/internal_redirect_target.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/cont!nt.txt +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/cont?nt.txt +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/content.txt +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/cont/303/251nt.txt" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/cont/360/237/216/201nt.txt" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/not_working.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/r?sources.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/resources.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/r/303/251sources.js" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script02!b.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script02a.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script03.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script04.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script05.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06a.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06b.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06c.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06d.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06e.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06f.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06g.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06h.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06i.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script06j.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script07.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script08a.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script08b.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script08c.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script09a.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script09b.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script09c.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script09d.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/script10.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript/working.png +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/javascript.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/j/303/240v/303/240scr/303/257pt.html" +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/mediaelement.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/onxxx.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/soundcloud.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/spotify.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/tiktok.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/twitch1.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/twitch2.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/twitter1.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/twitter2.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/url-encoding.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/video.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/vimeo.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/content/youtube.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/entrypoint-reverse.sh +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/test-website/entrypoint.sh +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/__init__.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/bad-redirections.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/content-resource-types.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/empty-file +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/example-response.warc +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/example-revisit.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/example-utf8.warc +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/example-with-timestamp.warc +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/http-return-codes.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/kiwix-with-redirects.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/main-entry-403.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/self-redirect.warc +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/single-page-test.warc +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/solidaritenum.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/video-vimeo.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/video-yt-2.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data/video-yt.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data-special/icons.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/data-special/qsl.net-encoding-alias.warc.gz +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/definition.json +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file01.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file02.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file03.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file04.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file05.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file06.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file07.html +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/encodings/file08.js +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_converter.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_icon_finder.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_language.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_metadata_validation.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/test_rewriting.py +0 -0
- {warc2zim-2.2.0 → warc2zim-2.2.2}/tests/utils.py +0 -0
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
5
|
+
rev: v5.0.0
|
|
6
6
|
hooks:
|
|
7
7
|
- id: trailing-whitespace
|
|
8
8
|
- id: end-of-file-fixer
|
|
9
9
|
- repo: https://github.com/psf/black
|
|
10
|
-
rev: "
|
|
10
|
+
rev: "25.1.0"
|
|
11
11
|
hooks:
|
|
12
12
|
- id: black
|
|
13
13
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
-
rev: v0.
|
|
14
|
+
rev: v0.9.6
|
|
15
15
|
hooks:
|
|
16
16
|
- id: ruff
|
|
17
17
|
- repo: https://github.com/RobertCraigie/pyright-python
|
|
18
|
-
rev: v1.1.
|
|
18
|
+
rev: v1.1.394
|
|
19
19
|
hooks:
|
|
20
20
|
- id: pyright
|
|
21
21
|
name: pyright (system)
|
|
@@ -25,17 +25,3 @@ repos:
|
|
|
25
25
|
'types_or': [python, pyi]
|
|
26
26
|
require_serial: true
|
|
27
27
|
minimum_pre_commit_version: '2.9.2'
|
|
28
|
-
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
29
|
-
rev: v3.1.0
|
|
30
|
-
hooks:
|
|
31
|
-
- id: prettier
|
|
32
|
-
files: javascript\/.*$ # files in javascript folder
|
|
33
|
-
args:
|
|
34
|
-
- --config
|
|
35
|
-
- javascript/.prettierrc.json
|
|
36
|
-
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
37
|
-
rev: v8.51.0
|
|
38
|
-
hooks:
|
|
39
|
-
- id: eslint
|
|
40
|
-
types: [file]
|
|
41
|
-
files: javascript\/src\/.*(?:\.[jt]sx?|\.vue)$ # *.js, *.jsx, *.ts, *.tsx, *.vue in javascript/src folder
|
|
@@ -5,6 +5,19 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (as of version 1.4.0).
|
|
7
7
|
|
|
8
|
+
## [2.2.2] - 2024-02-17
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Upgrade dependencies especially zimscraperlib 5.1.1 (#439)
|
|
13
|
+
|
|
14
|
+
## [2.2.1] - 2024-02-07
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Upgrade dependencies: Python 3.13, zimscraperlib 5.1.0 and others (#434)
|
|
19
|
+
- Fork cdxj_indexer codebase (#428)
|
|
20
|
+
|
|
8
21
|
## [2.2.0] - 2024-01-10
|
|
9
22
|
|
|
10
23
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: warc2zim
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: Convert WARC to ZIM
|
|
5
5
|
Project-URL: Donate, https://www.kiwix.org/en/support-us/
|
|
6
6
|
Project-URL: Homepage, https://github.com/openzim/warc2zim
|
|
@@ -10,34 +10,36 @@ License-File: LICENSE
|
|
|
10
10
|
Keywords: offline,openzim,warc,zim
|
|
11
11
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.
|
|
14
|
-
Requires-Python: <3.
|
|
15
|
-
Requires-Dist: beautifulsoup4==4.
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Requires-Python: <3.14,>=3.13
|
|
15
|
+
Requires-Dist: beautifulsoup4==4.13.3
|
|
16
16
|
Requires-Dist: brotlipy==0.7.0
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist:
|
|
17
|
+
Requires-Dist: jinja2==3.1.5
|
|
18
|
+
Requires-Dist: lxml==5.3.1
|
|
19
|
+
Requires-Dist: multipart==1.2.1
|
|
20
20
|
Requires-Dist: python-dateutil==2.9.0.post0
|
|
21
21
|
Requires-Dist: requests==2.32.3
|
|
22
22
|
Requires-Dist: tinycss2==1.4.0
|
|
23
23
|
Requires-Dist: warcio==1.7.5
|
|
24
|
-
Requires-Dist: zimscraperlib==5.
|
|
24
|
+
Requires-Dist: zimscraperlib==5.1.1
|
|
25
25
|
Provides-Extra: check
|
|
26
|
-
Requires-Dist: pyright==1.1.
|
|
26
|
+
Requires-Dist: pyright==1.1.394; extra == 'check'
|
|
27
27
|
Provides-Extra: dev
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist:
|
|
28
|
+
Requires-Dist: black==25.1.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: coverage==7.6.12; extra == 'dev'
|
|
30
|
+
Requires-Dist: debugpy==1.8.12; extra == 'dev'
|
|
31
|
+
Requires-Dist: invoke==2.2.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pre-commit==4.1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pyright==1.1.394; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest==8.3.4; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff==0.9.6; extra == 'dev'
|
|
34
36
|
Provides-Extra: lint
|
|
35
|
-
Requires-Dist: black==
|
|
36
|
-
Requires-Dist: ruff==0.
|
|
37
|
+
Requires-Dist: black==25.1.0; extra == 'lint'
|
|
38
|
+
Requires-Dist: ruff==0.9.6; extra == 'lint'
|
|
37
39
|
Provides-Extra: scripts
|
|
38
40
|
Requires-Dist: invoke==2.2.0; extra == 'scripts'
|
|
39
41
|
Provides-Extra: test
|
|
40
|
-
Requires-Dist: coverage==7.6.
|
|
42
|
+
Requires-Dist: coverage==7.6.12; extra == 'test'
|
|
41
43
|
Requires-Dist: pytest==8.3.4; extra == 'test'
|
|
42
44
|
Description-Content-Type: text/markdown
|
|
43
45
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""html rewrite test utility
|
|
2
2
|
|
|
3
3
|
This utility takes a given HTML content as input, base64 encoded, its original URL, and
|
|
4
4
|
rewrites its content.
|
|
@@ -17,9 +17,10 @@ import logging
|
|
|
17
17
|
import sys
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
|
|
20
|
+
from zimscraperlib.rewriting.html import HtmlRewriter
|
|
21
|
+
from zimscraperlib.rewriting.url_rewriting import ArticleUrlRewriter, HttpUrl, ZimPath
|
|
22
|
+
|
|
20
23
|
from warc2zim.constants import logger
|
|
21
|
-
from warc2zim.content_rewriting.html import HtmlRewriter
|
|
22
|
-
from warc2zim.url_rewriting import ArticleUrlRewriter, HttpUrl, ZimPath
|
|
23
24
|
from warc2zim.utils import to_string
|
|
24
25
|
|
|
25
26
|
|
|
@@ -37,7 +38,9 @@ def main(path_to_content: str, article_url: str, encoding: str | None = None):
|
|
|
37
38
|
content = Path(path_to_content)
|
|
38
39
|
|
|
39
40
|
url_rewriter = ArticleUrlRewriter(
|
|
40
|
-
HttpUrl(article_url),
|
|
41
|
+
article_url=HttpUrl(article_url),
|
|
42
|
+
existing_zim_paths=set(),
|
|
43
|
+
missing_zim_paths=set(),
|
|
41
44
|
)
|
|
42
45
|
|
|
43
46
|
html_rewriter = HtmlRewriter(url_rewriter, "", None, notify)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""MIA English exclude list
|
|
2
2
|
|
|
3
3
|
This utility computes the list of all subpages/languages that must be ignored for the
|
|
4
4
|
English ZIM of The Marxists Internet Archive (MIA) at www.marxists.org.
|
|
@@ -23,9 +23,9 @@ soup = BeautifulSoup(resp.text, "html.parser")
|
|
|
23
23
|
subfolders = set()
|
|
24
24
|
REGEX = re.compile(r"\.\.\/(?P<subfolder>.*?)\/")
|
|
25
25
|
for anchor in soup.find_all("a"):
|
|
26
|
-
if not anchor.has_attr("href"):
|
|
26
|
+
if not anchor.has_attr("href"): # pyright: ignore
|
|
27
27
|
continue
|
|
28
|
-
if match := REGEX.match(anchor["href"]):
|
|
28
|
+
if match := REGEX.match(anchor["href"]): # pyright: ignore
|
|
29
29
|
subfolders.add(match.group("subfolder"))
|
|
30
30
|
|
|
31
31
|
print("|".join(sorted(subfolders))) # noqa: T201
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Software architecture
|
|
2
|
+
|
|
3
|
+
## cdxj_indexer and warcio
|
|
4
|
+
|
|
5
|
+
[cdxj_indexer Python library](https://pypi.org/project/cdxj-indexer/) is a thin wrapper over [warcio Python library](https://pypi.org/project/warcio/). It used to iterate all record in WARCs.
|
|
6
|
+
|
|
7
|
+
It provide two main features:
|
|
8
|
+
|
|
9
|
+
- Loop over several WARCs in a directory (A visit of a website may be stored in several WARCs in the same directory).
|
|
10
|
+
- Provide a buffered access to warcs content (and not a "stream" (fileio) only api) (but monkey patching returned WarcRecord.
|
|
11
|
+
|
|
12
|
+
Except that, scraper directly uses WarcRecord (returned by cdxj_indexer, implemented in warcio) to access metadata and such.
|
|
13
|
+
|
|
14
|
+
cdxj_indexer usefull methods are currently forked in warc2zim, see https://github.com/openzim/warc2zim/pull/428 for details.
|
|
15
|
+
|
|
16
|
+
## zimscraperlib
|
|
17
|
+
|
|
18
|
+
[zimscraperlib Python library](https://pypi.org/project/zimscraperlib) is used for ZIM operations and for all HTML / CSS / JS rewriting operations (mostly around URL manipulations, but not only).
|
|
19
|
+
|
|
20
|
+
## requests
|
|
21
|
+
|
|
22
|
+
[requests Python library](https://pypi.org/project/requests/) is used to retrieve the custom CSS file when a URL is passed.
|
|
23
|
+
|
|
24
|
+
## brotlipy
|
|
25
|
+
|
|
26
|
+
[brotlipy Python library](https://pypi.org/project/brotlipy/) is used to access brotli content in WARC records (not part of warcio because it is an optional dependency).
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["hatchling", "hatch-openzim
|
|
2
|
+
requires = ["hatchling", "hatch-openzim"]
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "warc2zim"
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.13,<3.14"
|
|
8
8
|
description = "Convert WARC to ZIM"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
dependencies = [
|
|
11
11
|
"warcio==1.7.5",
|
|
12
12
|
"requests==2.32.3",
|
|
13
|
-
"zimscraperlib==5.
|
|
14
|
-
"jinja2==3.1.
|
|
13
|
+
"zimscraperlib==5.1.1",
|
|
14
|
+
"jinja2==3.1.5",
|
|
15
15
|
# to support possible brotli content in warcs, must be added separately
|
|
16
16
|
"brotlipy==0.7.0",
|
|
17
|
-
"cdxj_indexer==1.4.6",
|
|
18
17
|
"tinycss2==1.4.0",
|
|
19
|
-
"beautifulsoup4==4.
|
|
20
|
-
"lxml==5.3.
|
|
18
|
+
"beautifulsoup4==4.13.3", # used to parse base href
|
|
19
|
+
"lxml==5.3.1", # used by beautifulsoup4 for parsing html
|
|
21
20
|
"python-dateutil==2.9.0.post0",
|
|
21
|
+
"multipart==1.2.1",
|
|
22
22
|
]
|
|
23
23
|
dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"]
|
|
24
24
|
|
|
@@ -35,19 +35,19 @@ scripts = [
|
|
|
35
35
|
"invoke==2.2.0",
|
|
36
36
|
]
|
|
37
37
|
lint = [
|
|
38
|
-
"black==
|
|
39
|
-
"ruff==0.
|
|
38
|
+
"black==25.1.0",
|
|
39
|
+
"ruff==0.9.6",
|
|
40
40
|
]
|
|
41
41
|
check = [
|
|
42
|
-
"pyright==1.1.
|
|
42
|
+
"pyright==1.1.394",
|
|
43
43
|
]
|
|
44
44
|
test = [
|
|
45
45
|
"pytest==8.3.4",
|
|
46
|
-
"coverage==7.6.
|
|
46
|
+
"coverage==7.6.12",
|
|
47
47
|
]
|
|
48
48
|
dev = [
|
|
49
|
-
"pre-commit==4.0
|
|
50
|
-
"debugpy==1.8.
|
|
49
|
+
"pre-commit==4.1.0",
|
|
50
|
+
"debugpy==1.8.12",
|
|
51
51
|
"warc2zim[scripts]",
|
|
52
52
|
"warc2zim[lint]",
|
|
53
53
|
"warc2zim[test]",
|
|
@@ -103,10 +103,10 @@ all = "inv checkall --args '{args}'"
|
|
|
103
103
|
|
|
104
104
|
[tool.black]
|
|
105
105
|
line-length = 88
|
|
106
|
-
target-version = ['
|
|
106
|
+
target-version = ['py313']
|
|
107
107
|
|
|
108
108
|
[tool.ruff]
|
|
109
|
-
target-version = "
|
|
109
|
+
target-version = "py313"
|
|
110
110
|
line-length = 88
|
|
111
111
|
src = ["src"]
|
|
112
112
|
|
|
@@ -229,6 +229,6 @@ exclude_lines = [
|
|
|
229
229
|
include = ["src", "tests", "tasks.py"]
|
|
230
230
|
exclude = [".env/**", ".venv/**"]
|
|
231
231
|
extraPaths = ["src"]
|
|
232
|
-
pythonVersion = "3.
|
|
232
|
+
pythonVersion = "3.13"
|
|
233
233
|
typeCheckingMode = "basic"
|
|
234
234
|
disableBytesTypePromotions = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.2"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from warc2zim.cdxj_indexer.bufferiter import buffering_record_iter
|
|
2
|
+
from warc2zim.cdxj_indexer.main import iter_file_or_dir
|
|
3
|
+
from warc2zim.cdxj_indexer.postquery import append_method_query_from_req_resp
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"append_method_query_from_req_resp",
|
|
7
|
+
"buffering_record_iter",
|
|
8
|
+
"iter_file_or_dir",
|
|
9
|
+
]
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import shutil
|
|
3
|
+
import tempfile
|
|
4
|
+
|
|
5
|
+
from warc2zim.cdxj_indexer.postquery import append_method_query_from_req_resp
|
|
6
|
+
|
|
7
|
+
BUFF_SIZE = 1024 * 64
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# ============================================================================
|
|
11
|
+
def buffering_record_iter(
|
|
12
|
+
record_iter, digest_reader=None, url_key_func=None, *, post_append=False
|
|
13
|
+
):
|
|
14
|
+
prev_record = None
|
|
15
|
+
|
|
16
|
+
for record in record_iter:
|
|
17
|
+
buffer_record_content(record)
|
|
18
|
+
|
|
19
|
+
record.file_offset = record_iter.get_record_offset()
|
|
20
|
+
record.file_length = record_iter.get_record_length()
|
|
21
|
+
|
|
22
|
+
if digest_reader:
|
|
23
|
+
curr = digest_reader.tell()
|
|
24
|
+
digest_reader.seek(record.file_offset)
|
|
25
|
+
record_digest, digest_length = digest_block(
|
|
26
|
+
digest_reader, record.file_length
|
|
27
|
+
)
|
|
28
|
+
digest_reader.seek(curr)
|
|
29
|
+
|
|
30
|
+
if digest_length != record.file_length:
|
|
31
|
+
raise Exception(
|
|
32
|
+
f"Digest block mismatch, expected {record.file_length}, "
|
|
33
|
+
f"got {digest_length}"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
record.record_digest = record_digest
|
|
37
|
+
|
|
38
|
+
req, resp = concur_req_resp(prev_record, record)
|
|
39
|
+
|
|
40
|
+
if not req or not resp:
|
|
41
|
+
if prev_record:
|
|
42
|
+
yield prev_record
|
|
43
|
+
prev_record.buffered_stream.close()
|
|
44
|
+
prev_record = record
|
|
45
|
+
continue
|
|
46
|
+
|
|
47
|
+
join_req_resp(req, resp, post_append, url_key_func)
|
|
48
|
+
|
|
49
|
+
yield prev_record
|
|
50
|
+
if prev_record:
|
|
51
|
+
prev_record.buffered_stream.close()
|
|
52
|
+
yield record
|
|
53
|
+
record.buffered_stream.close()
|
|
54
|
+
prev_record = None
|
|
55
|
+
|
|
56
|
+
if prev_record:
|
|
57
|
+
yield prev_record
|
|
58
|
+
prev_record.buffered_stream.close()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ============================================================================
|
|
62
|
+
def concur_req_resp(rec_1, rec_2):
|
|
63
|
+
if not rec_1 or not rec_2:
|
|
64
|
+
return None, None
|
|
65
|
+
|
|
66
|
+
if rec_1.rec_headers.get_header("WARC-Target-URI") != rec_2.rec_headers.get_header(
|
|
67
|
+
"WARC-Target-URI"
|
|
68
|
+
):
|
|
69
|
+
return None, None
|
|
70
|
+
|
|
71
|
+
if rec_2.rec_headers.get_header(
|
|
72
|
+
"WARC-Concurrent-To"
|
|
73
|
+
) != rec_1.rec_headers.get_header("WARC-Record-ID"):
|
|
74
|
+
return None, None
|
|
75
|
+
|
|
76
|
+
if rec_1.rec_type == "response" and rec_2.rec_type == "request":
|
|
77
|
+
req = rec_2
|
|
78
|
+
resp = rec_1
|
|
79
|
+
|
|
80
|
+
elif rec_1.rec_type == "request" and rec_2.rec_type == "response":
|
|
81
|
+
req = rec_1
|
|
82
|
+
resp = rec_2
|
|
83
|
+
|
|
84
|
+
else:
|
|
85
|
+
return None, None
|
|
86
|
+
|
|
87
|
+
return req, resp
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# ============================================================================
|
|
91
|
+
def buffer_record_content(record):
|
|
92
|
+
spool = tempfile.SpooledTemporaryFile(BUFF_SIZE)
|
|
93
|
+
shutil.copyfileobj(record.content_stream(), spool)
|
|
94
|
+
spool.seek(0)
|
|
95
|
+
record.buffered_stream = spool
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# ============================================================================
|
|
99
|
+
def join_req_resp(req, resp, post_append, url_key_func=None):
|
|
100
|
+
if req.http_headers is None:
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
resp.req = req
|
|
104
|
+
|
|
105
|
+
method = req.http_headers.protocol
|
|
106
|
+
if post_append and method.upper() in ("POST", "PUT"):
|
|
107
|
+
url = req.rec_headers.get_header("WARC-Target-URI")
|
|
108
|
+
query, append_str = append_method_query_from_req_resp(req)
|
|
109
|
+
resp.method = method.upper()
|
|
110
|
+
resp.requestBody = query
|
|
111
|
+
resp.urlkey = url + append_str
|
|
112
|
+
if url_key_func:
|
|
113
|
+
resp.urlkey = url_key_func(resp.urlkey)
|
|
114
|
+
req.urlkey = resp.urlkey
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ============================================================================
|
|
118
|
+
def digest_block(reader, length):
|
|
119
|
+
count = 0
|
|
120
|
+
hasher = hashlib.sha256()
|
|
121
|
+
|
|
122
|
+
while length > 0:
|
|
123
|
+
buff = reader.read(min(BUFF_SIZE, length))
|
|
124
|
+
if not buff:
|
|
125
|
+
break
|
|
126
|
+
hasher.update(buff)
|
|
127
|
+
length -= len(buff)
|
|
128
|
+
count += len(buff)
|
|
129
|
+
|
|
130
|
+
return "sha256:" + hasher.hexdigest(), count
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
ALLOWED_EXT = (".arc", ".arc.gz", ".warc", ".warc.gz")
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# =================================================================
|
|
7
|
+
def iter_file_or_dir(inputs: list[str]):
|
|
8
|
+
for input_ in inputs:
|
|
9
|
+
if not isinstance(input_, str) or not os.path.isdir(input_):
|
|
10
|
+
yield input_
|
|
11
|
+
continue
|
|
12
|
+
|
|
13
|
+
for root, _, files in os.walk(input_):
|
|
14
|
+
for filename in files:
|
|
15
|
+
if filename.endswith(ALLOWED_EXT):
|
|
16
|
+
full_path = os.path.join(root, filename)
|
|
17
|
+
yield full_path
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import json
|
|
3
|
+
import sys
|
|
4
|
+
from io import BytesIO
|
|
5
|
+
from urllib.parse import unquote_plus, urlencode
|
|
6
|
+
|
|
7
|
+
from multipart import MultipartParser
|
|
8
|
+
|
|
9
|
+
MAX_QUERY_LENGTH = 4096
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ============================================================================
|
|
13
|
+
def append_method_query_from_req_resp(req):
|
|
14
|
+
len_ = req.http_headers.get_header("Content-Length")
|
|
15
|
+
content_type = req.http_headers.get_header("Content-Type")
|
|
16
|
+
stream = req.buffered_stream
|
|
17
|
+
stream.seek(0)
|
|
18
|
+
|
|
19
|
+
url = req.rec_headers.get_header("WARC-Target-URI")
|
|
20
|
+
method = req.http_headers.protocol
|
|
21
|
+
return append_method_query(method, content_type, len_, stream, url)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# ============================================================================
|
|
25
|
+
def append_method_query(method, content_type, len_, stream, url):
|
|
26
|
+
# if method == 'GET':
|
|
27
|
+
# return '', ''
|
|
28
|
+
|
|
29
|
+
if method in ("POST", "PUT"):
|
|
30
|
+
query = query_extract(content_type, len_, stream)
|
|
31
|
+
else:
|
|
32
|
+
query = ""
|
|
33
|
+
|
|
34
|
+
if "?" not in url:
|
|
35
|
+
append_str = "?"
|
|
36
|
+
else:
|
|
37
|
+
append_str = "&"
|
|
38
|
+
|
|
39
|
+
append_str += "__wb_method=" + method
|
|
40
|
+
if query:
|
|
41
|
+
append_str += "&" + query
|
|
42
|
+
|
|
43
|
+
return query, append_str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# ============================================================================
|
|
47
|
+
def query_extract(mime, length, stream):
|
|
48
|
+
"""
|
|
49
|
+
Extract a url-encoded form POST/PUT from stream
|
|
50
|
+
content length, return None
|
|
51
|
+
Attempt to decode application/x-www-form-urlencoded or multipart/*,
|
|
52
|
+
otherwise read whole block and b64encode
|
|
53
|
+
"""
|
|
54
|
+
query_data = b""
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
length = int(length)
|
|
58
|
+
except (ValueError, TypeError):
|
|
59
|
+
if length is None:
|
|
60
|
+
length = 8192
|
|
61
|
+
else:
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
while length > 0:
|
|
65
|
+
buff = stream.read(length)
|
|
66
|
+
|
|
67
|
+
length -= len(buff)
|
|
68
|
+
|
|
69
|
+
if not buff:
|
|
70
|
+
break
|
|
71
|
+
|
|
72
|
+
query_data += buff
|
|
73
|
+
|
|
74
|
+
if not mime:
|
|
75
|
+
mime = ""
|
|
76
|
+
|
|
77
|
+
query = ""
|
|
78
|
+
|
|
79
|
+
def handle_binary(query_data):
|
|
80
|
+
return f"__wb_post_data={ base64.b64encode(query_data).decode()}"
|
|
81
|
+
|
|
82
|
+
if mime.startswith("application/x-www-form-urlencoded"):
|
|
83
|
+
try:
|
|
84
|
+
query = unquote_plus(query_data.decode("utf-8"))
|
|
85
|
+
except UnicodeDecodeError:
|
|
86
|
+
query = handle_binary(query_data)
|
|
87
|
+
|
|
88
|
+
elif mime.startswith("multipart/"):
|
|
89
|
+
try:
|
|
90
|
+
boundary = mime.split("boundary=")[1]
|
|
91
|
+
parser = MultipartParser(BytesIO(query_data), boundary, charset="utf8")
|
|
92
|
+
except (ValueError, IndexError):
|
|
93
|
+
# Content-Type multipart/form-data may lack "boundary" info
|
|
94
|
+
query = handle_binary(query_data)
|
|
95
|
+
else:
|
|
96
|
+
values = []
|
|
97
|
+
for part in parser:
|
|
98
|
+
if part is None:
|
|
99
|
+
continue
|
|
100
|
+
values.append((part.name, part.value))
|
|
101
|
+
|
|
102
|
+
query = urlencode(values, True)
|
|
103
|
+
|
|
104
|
+
elif mime.startswith("application/json"):
|
|
105
|
+
try:
|
|
106
|
+
query = json_parse(query_data)
|
|
107
|
+
except Exception:
|
|
108
|
+
if query_data:
|
|
109
|
+
try:
|
|
110
|
+
sys.stderr.write(
|
|
111
|
+
"Error parsing: " + query_data.decode("utf-8") + "\n"
|
|
112
|
+
)
|
|
113
|
+
except Exception: # noqa: S110 # nosec B110
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
query = ""
|
|
117
|
+
|
|
118
|
+
elif mime.startswith("text/plain"):
|
|
119
|
+
try:
|
|
120
|
+
query = json_parse(query_data)
|
|
121
|
+
except Exception:
|
|
122
|
+
query = handle_binary(query_data)
|
|
123
|
+
|
|
124
|
+
# Remove AMF parsing, we do not really need it in warc2zim and AMF library is not
|
|
125
|
+
# maintained at all
|
|
126
|
+
# elif mime.startswith("application/x-amf"):
|
|
127
|
+
# query = amf_parse(query_data)
|
|
128
|
+
|
|
129
|
+
else:
|
|
130
|
+
query = handle_binary(query_data)
|
|
131
|
+
|
|
132
|
+
if query:
|
|
133
|
+
query = query[:MAX_QUERY_LENGTH]
|
|
134
|
+
|
|
135
|
+
return query
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def json_parse(string):
|
|
139
|
+
data = {}
|
|
140
|
+
dupes = {}
|
|
141
|
+
|
|
142
|
+
def get_key(n):
|
|
143
|
+
if n not in data:
|
|
144
|
+
return n
|
|
145
|
+
|
|
146
|
+
if n not in dupes:
|
|
147
|
+
dupes[n] = 1
|
|
148
|
+
|
|
149
|
+
dupes[n] += 1
|
|
150
|
+
return n + "." + str(dupes[n]) + "_"
|
|
151
|
+
|
|
152
|
+
def _parser(json_obj, name=""):
|
|
153
|
+
if isinstance(json_obj, dict):
|
|
154
|
+
for n, v in json_obj.items():
|
|
155
|
+
_parser(v, n)
|
|
156
|
+
|
|
157
|
+
elif isinstance(json_obj, list):
|
|
158
|
+
for v in json_obj:
|
|
159
|
+
_parser(v, name)
|
|
160
|
+
|
|
161
|
+
elif name:
|
|
162
|
+
data[get_key(name)] = str(json_obj)
|
|
163
|
+
|
|
164
|
+
try:
|
|
165
|
+
_parser(json.loads(string))
|
|
166
|
+
except json.decoder.JSONDecodeError:
|
|
167
|
+
if b"\n" in string:
|
|
168
|
+
for line in string.split(b"\n"):
|
|
169
|
+
_parser(json.loads(line))
|
|
170
|
+
else:
|
|
171
|
+
raise
|
|
172
|
+
|
|
173
|
+
return urlencode(data)
|