From c1ff2938bf4b5c085824d43fedd3f6190d55d641 Mon Sep 17 00:00:00 2001 From: chuzhongzai Date: Sat, 22 Feb 2025 14:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0cookie=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=EF=BC=8C=E5=A4=B1=E6=95=88=E6=97=B6=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lionwebsite/Service/LocalServiceImpl.java | 20 ++++++++++++++++++- .../lion/lionwebsite/Util/GalleryUtil.java | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java b/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java index 8f8192e..17031c8 100644 --- a/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java +++ b/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java @@ -6,6 +6,7 @@ import com.lion.lionwebsite.Dao.normal.ShareFileMapper; import com.lion.lionwebsite.Domain.CustomConfiguration; import com.lion.lionwebsite.Domain.ShareFile; import com.lion.lionwebsite.Util.CustomUtil; +import com.lion.lionwebsite.Util.GalleryUtil; import lombok.Data; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -41,10 +42,13 @@ public class LocalServiceImpl{ GalleryMapper galleryMapper; - public LocalServiceImpl(CustomConfigurationMapper configurationMapper, ShareFileMapper shareFileMapper, GalleryMapper galleryMapper){ + PushService pushService; + + public LocalServiceImpl(CustomConfigurationMapper configurationMapper, ShareFileMapper shareFileMapper, GalleryMapper galleryMapper, PushService pushService) { this.shareFileMapper = shareFileMapper; this.configurationMapper = configurationMapper; this.galleryMapper = galleryMapper; + this.pushService = pushService; } /** @@ -56,6 +60,20 @@ public class LocalServiceImpl{ configurationMapper.updateConfiguration(CustomConfiguration.LAST_RESET_AMOUNT_TIME, CustomUtil.now()); } + /** + * 每天凌晨测试e-hentai cookie是否过期 + */ + @Scheduled(cron = "0 0 0 * * *") + public void verifyCookie(){ + try { + String content = GalleryUtil.requests("https://exhentai.org", "GET", null, null); + if(content.trim().isEmpty()) + pushService.sendToMe("cookie过期"); + } catch (IOException e) { + pushService.sendToMe("检测cookie异常:" + e.getMessage()); + } + } + /** * 定时更新订阅 * @throws IOException 下载以及保存异常 diff --git a/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java b/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java index f26401d..e317b5a 100644 --- a/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java +++ b/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java @@ -271,7 +271,7 @@ public class GalleryUtil { headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"); headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); if(url.contains("hentai")) { - headers.put("Cookie", "ipb_session_id=1b6cb1beb8948f5421e6f747e43feb82; ipb_member_id=5774855; ipb_pass_hash=4b061c3abe25289568b5a8e0123fb3b9; sk=oye107wk02gtomb56x65dmv4qzbn; nw=1"); + headers.put("Cookie", "ipb_session_id=af2b2b1a795b39550711134d7bdcbf7f; ipb_member_id=5774855; ipb_pass_hash=4b061c3abe25289568b5a8e0123fb3b9; sk=oye107wk02gtomb56x65dmv4qzbn; nw=1"); headers.put("Upgrade-Insecure-Requests", "1"); }