Skip to content

Commit

Permalink
Check valid eh html
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Dec 31, 2024
1 parent 4ae26ec commit 6840c77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions violet/lib/component/eh/eh_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getImagesUrl(String html) {
var doc = parse(html).querySelector("div[id='gdt']");
Expand Down
3 changes: 1 addition & 2 deletions violet/lib/pages/article_info/article_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6840c77

Please sign in to comment.