From 6a79adb56bf5173d1cbc2205b1601cc282a04fad Mon Sep 17 00:00:00 2001 From: nyne Date: Tue, 21 Jan 2025 16:30:05 +0800 Subject: [PATCH] picacg: re-login if login expires while loading comic information --- index.json | 2 +- picacg.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/index.json b/index.json index fcf643f..e7d461e 100644 --- a/index.json +++ b/index.json @@ -21,7 +21,7 @@ "name": "Picacg", "fileName": "picacg.js", "key": "picacg", - "version": "1.0.0" + "version": "1.0.1" }, { "name": "nhentai", diff --git a/picacg.js b/picacg.js index 2a496b5..3948fb1 100644 --- a/picacg.js +++ b/picacg.js @@ -3,7 +3,7 @@ class Picacg extends ComicSource { key = "picacg" - version = "1.0.0" + version = "1.0.1" minAppVersion = "1.0.0" @@ -445,7 +445,17 @@ class Picacg extends ComicSource { }) return comics } - let [info, eps, related] = await Promise.all([infoLoader(), epsLoader(), relatedLoader()]) + let info, eps, related + try { + [info, eps, related] = await Promise.all([infoLoader(), epsLoader(), relatedLoader()]) + } + catch (e) { + if (e === 'Invalid status code: 401') { + await this.account.reLogin(); + [info, eps, related] = await Promise.all([infoLoader(), epsLoader(), relatedLoader()]); + } + throw e + } let tags = {} if(info.author) { tags['Author'] = [info.author];