From 3540869748d402abddf89eb8c1c21f13bbef5b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=85=B1=E5=A4=A9=E5=B0=8F=E7=A6=BD=E5=85=BD?= Date: Sat, 9 Mar 2024 15:42:17 +0800 Subject: [PATCH] Fix the bug of 509 recognition error in some cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复部分情况下509识别错误的bug --- changelog/v7.4.12+172.md | 5 +++ changelog/v7.4.13.md | 4 ++- lib/src/consts/eh_consts.dart | 50 ++++++++++++++++------------- lib/src/utils/eh_spider_parser.dart | 5 +-- 4 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 changelog/v7.4.12+172.md diff --git a/changelog/v7.4.12+172.md b/changelog/v7.4.12+172.md new file mode 100644 index 00000000..bab5dd2d --- /dev/null +++ b/changelog/v7.4.12+172.md @@ -0,0 +1,5 @@ +- 修复部分情况下509识别错误的bug + +------------------------------------------------------------------------------------------ + +- Fix the bug of 509 recognition error in some cases \ No newline at end of file diff --git a/changelog/v7.4.13.md b/changelog/v7.4.13.md index c5d495a0..dbae8d9f 100644 --- a/changelog/v7.4.13.md +++ b/changelog/v7.4.13.md @@ -13,6 +13,7 @@ - 修复部分情况下无法超分图片的bug - 修复在关闭标签搜索继承时点击tag搜索时的路由bug - 修复下载页列表布局下暂停时进度条颜色显示不正确的bug +- 修复部分情况下509识别错误的bug ------------------------------------------------------------------------------------------ @@ -30,4 +31,5 @@ - Fix the bug that super-resolution images cannot be deleted - Fix the bug that super-resolution images cannot be generated in some cases - Fix the routing bug when clicking tag search when closing tag search inheritance -- Fix the bug that the progress bar color is displayed incorrectly when pausing in the download page list layout \ No newline at end of file +- Fix the bug that the progress bar color is displayed incorrectly when pausing in the download page list layout +- Fix the bug of 509 recognition error in some cases \ No newline at end of file diff --git a/lib/src/consts/eh_consts.dart b/lib/src/consts/eh_consts.dart index 9089dff1..6b918e62 100644 --- a/lib/src/consts/eh_consts.dart +++ b/lib/src/consts/eh_consts.dart @@ -5,33 +5,33 @@ class EHConsts { static String get EIndex => EHSetting.site.value == 'EH' ? EHIndex : EXIndex; - static String get EHIndex => 'https://e-hentai.org'; + static const String EHIndex = 'https://e-hentai.org'; - static String get EXIndex => 'https://exhentai.org'; + static const String EXIndex = 'https://exhentai.org'; static String get EPopular => EHSetting.site.value == 'EH' ? EHPopular : EXPopular; - static String get EHPopular => 'https://e-hentai.org/popular'; + static const String EHPopular = 'https://e-hentai.org/popular'; - static String get EXPopular => 'https://exhentai.org/popular'; + static const String EXPopular = 'https://exhentai.org/popular'; static String get EApi => EHSetting.site.value == 'EH' ? EHApi : EXApi; - static String get EHApi => 'https://api.e-hentai.org/api.php'; + static const String EHApi = 'https://api.e-hentai.org/api.php'; - static String get EXApi => 'https://exhentai.org/api.php'; + static const String EXApi = 'https://exhentai.org/api.php'; - static String get EHome => 'https://e-hentai.org/home.php'; + static const String EHome = 'https://e-hentai.org/home.php'; - static String get ERanklist => 'https://e-hentai.org/toplist.php'; + static const String ERanklist = 'https://e-hentai.org/toplist.php'; static String get EWatched => EHSetting.site.value == 'EH' ? EHWatched : EXWatched; - static String get EHWatched => 'https://e-hentai.org/watched'; + static const String EHWatched = 'https://e-hentai.org/watched'; - static String get EXWatched => 'https://exhentai.org/watched'; + static const String EXWatched = 'https://exhentai.org/watched'; - static String get EForums => 'https://forums.e-hentai.org/index.php'; + static const String EForums = 'https://forums.e-hentai.org/index.php'; static String get EPopup => EHSetting.site.value == 'EH' ? 'https://e-hentai.org/gallerypopups.php' : 'https://exhentai.org/gallerypopups.php'; @@ -39,33 +39,37 @@ class EHConsts { static String get ETorrent => EHSetting.site.value == 'EH' ? EHTorrent : EXTorrent; - static String get EHTorrent => 'https://e-hentai.org/gallerytorrents.php'; + static const String EHTorrent = 'https://e-hentai.org/gallerytorrents.php'; - static String get EXTorrent => 'https://exhentai.org/gallerytorrents.php'; + static const String EXTorrent = 'https://exhentai.org/gallerytorrents.php'; static String get EArchive => EHSetting.site.value == 'EH' ? EHArchive : EXArchive; - static String get EHArchive => 'https://e-hentai.org/archiver.php'; + static const String EHArchive = 'https://e-hentai.org/archiver.php'; - static String get EXArchive => 'https://exhentai.org/archiver.php'; + static const String EXArchive = 'https://exhentai.org/archiver.php'; - static String get ELogin => 'https://forums.e-hentai.org/index.php?act=Login&CODE=00'; + static const String ELogin = 'https://forums.e-hentai.org/index.php?act=Login&CODE=00'; static String get EUconfig => EHSetting.site.value == 'EH' ? EHUconfig : EXUconfig; - static String get EHUconfig => 'https://e-hentai.org/uconfig.php'; + static const String EHUconfig = 'https://e-hentai.org/uconfig.php'; - static String get EXUconfig => 'https://exhentai.org/uconfig.php'; + static const String EXUconfig = 'https://exhentai.org/uconfig.php'; - static String get EStat => 'https://e-hentai.org/stats.php'; + static const String EStat = 'https://e-hentai.org/stats.php'; static String get ELookup => EHSetting.site.value == 'EH' ? EHLookup : EXLookup; - static String get EHLookup => 'https://upld.e-hentai.org/image_lookup.php'; + static const String EHLookup = 'https://upld.e-hentai.org/image_lookup.php'; - static String get EXLookup => 'https://exhentai.org/upld/image_lookup.php'; + static const String EXLookup = 'https://exhentai.org/upld/image_lookup.php'; - static String get EMyTags => 'https://e-hentai.org/mytags'; + static const String EMyTags = 'https://e-hentai.org/mytags'; - static String get EExchange => 'https://e-hentai.org/exchange.php?t=gp'; + static const String EExchange = 'https://e-hentai.org/exchange.php?t=gp'; + + static const String EH509ImageUrl = 'https://ehgt.org/g/509.gif'; + + static const String EX509ImageUrl = 'https://exhentai.org/img/509.gif'; } diff --git a/lib/src/utils/eh_spider_parser.dart b/lib/src/utils/eh_spider_parser.dart index 0c6e6384..fca57b0a 100644 --- a/lib/src/utils/eh_spider_parser.dart +++ b/lib/src/utils/eh_spider_parser.dart @@ -27,6 +27,7 @@ import 'package:jhentai/src/setting/site_setting.dart'; import 'package:jhentai/src/utils/color_util.dart'; import 'package:jhentai/src/utils/string_uril.dart'; +import '../consts/eh_consts.dart'; import '../database/database.dart'; import '../exception/eh_parse_exception.dart'; import '../model/gallery.dart'; @@ -471,7 +472,7 @@ class EHSpiderParser { /// height: 1600px; width: 1124px; String style = img!.attributes['style']!; String url = img.attributes['src']!; - if (url.contains('509.gif')) { + if (url == EHConsts.EH509ImageUrl || url == EHConsts.EX509ImageUrl) { throw EHParseException(type: EHParseExceptionType.exceedLimit, message: 'exceedImageLimits'.tr); } double height = double.parse(RegExp(r'height:(\d+)px').firstMatch(style)!.group(1)!); @@ -507,7 +508,7 @@ class EHSpiderParser { /// height: 1600px; width: 1124px; String style = img!.attributes['style']!; String url = img.attributes['src']!; - if (url.contains('509.gif')) { + if (url == EHConsts.EH509ImageUrl || url == EHConsts.EX509ImageUrl) { throw EHParseException(type: EHParseExceptionType.exceedLimit, message: 'exceedImageLimits'.tr); } double height = double.parse(RegExp(r'height:(\d+)px').firstMatch(style)!.group(1)!);