From e71caa719c3a61cda1e30aa4b2deb232992ca192 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Tue, 5 Nov 2024 08:07:53 +0000 Subject: [PATCH 1/4] Remove dead code --- scraper/src/mindtouch2zim/processor.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scraper/src/mindtouch2zim/processor.py b/scraper/src/mindtouch2zim/processor.py index fc02bf6..65ec21a 100644 --- a/scraper/src/mindtouch2zim/processor.py +++ b/scraper/src/mindtouch2zim/processor.py @@ -768,8 +768,6 @@ def rewrite_iframe_tags( '', + '' + '
' + '' + "
" + "
" + '', + { + ZimPath( + "i.ytimg.com.fuzzy.replayweb.page/vi/sQaEthBmZB0/thumbnail.jpg" + ): {HttpUrl("https://i.ytimg.com/vi/sQaEthBmZB0/hqdefault.jpg")} + }, + id="youtube", + ), + pytest.param( + '', + '' + '
' + '' + "" + "
" + "
" + '', + { + ZimPath( + "i.vimeocdn.com/video/553546340-" + "35aa6d23b04e9bdaf254c3cfc4da56bcfd7ff3f75a517c485536082edbf547dd-" + "d_640" + ): { + HttpUrl( + "https://i.vimeocdn.com/video/553546340-" + "35aa6d23b04e9bdaf254c3cfc4da56bcfd7ff3f75a517c485536082e" + "dbf547dd-d_640" + ) + } + }, + id="vimeo", + ), + pytest.param( + '', + "This content is not inside the ZIM. View content online at " + '' + "
https://www.acme.com/embed/sQaEthBmZB0?vq=hd1080
" + "
" + '', + {}, + id="unhandled", + ), + ], +) +def test_html_iframe_rewriting( + url_rewriter: HtmlUrlsRewriter, + html_rewriter: HtmlRewriter, + source_html: str, + expected_html: str, + expected_items_to_download: dict[ZimPath, set[HttpUrl]], +): + rewritten = html_rewriter.rewrite(source_html) + assert rewritten.content == expected_html + assert rewritten.title == "" + assert url_rewriter.items_to_download == expected_items_to_download + + +def test_html_picture_rewriting(html_rewriter: HtmlRewriter): + with pytest.raises(UnsupportedTagError): + html_rewriter.rewrite("") + + +def test_html_script_rewriting(html_rewriter: HtmlRewriter): + with pytest.raises(UnsupportedHrefSrcError): + html_rewriter.rewrite("