From 6840c7771e7c90032ef46e23c9891b4d54cbe68c Mon Sep 17 00:00:00 2001 From: violet-dev Date: Tue, 31 Dec 2024 12:25:52 +0900 Subject: [PATCH] Check valid eh html --- violet/lib/component/eh/eh_parser.dart | 6 ++++++ violet/lib/pages/article_info/article_info_page.dart | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/violet/lib/component/eh/eh_parser.dart b/violet/lib/component/eh/eh_parser.dart index 2a1079453..926dee69e 100644 --- a/violet/lib/component/eh/eh_parser.dart +++ b/violet/lib/component/eh/eh_parser.dart @@ -58,6 +58,12 @@ class EHParser { static final RegExp _thumbnailPattern = RegExp(r'https://(s\.)?(exhentai|ehgt).org/.*?(?=\))'); + static bool validHtml(String html) { + final removed = + html.contains('This gallery has been removed or is unavailable.'); + return !removed; + } + // ex: https://exhentai.org/g/1212168/421ef300a8/ static List getImagesUrl(String html) { var doc = parse(html).querySelector("div[id='gdt']"); diff --git a/violet/lib/pages/article_info/article_info_page.dart b/violet/lib/pages/article_info/article_info_page.dart index bfa51f2f8..82b5de17e 100644 --- a/violet/lib/pages/article_info/article_info_page.dart +++ b/violet/lib/pages/article_info/article_info_page.dart @@ -540,8 +540,7 @@ class __CommentAreaState extends State<_CommentArea> { final html = (await http.get( 'https://e-hentai.org/g/${widget.queryResult.id()}/${widget.queryResult.ehash()}/?p=0&inline_set=ts_l')) .body; - if (html - .contains('This gallery has been removed or is unavailable.')) { + if (!EHParser.validHtml(html)) { return; } final article = EHParser.parseArticleData(html);