From 89e4bbd453a1679df49cfb32cfe4158968d7b24e Mon Sep 17 00:00:00 2001 From: snowtafir Date: Wed, 23 Oct 2024 20:01:05 +0800 Subject: [PATCH] optimize: risk code -352 --- models/bilibili/bilibili.api.ts | 19 +++++++++---------- models/bilibili/bilibili.get.web.data.ts | 4 ++-- models/bilibili/bilibili.task.ts | 4 ++-- package.json | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/models/bilibili/bilibili.api.ts b/models/bilibili/bilibili.api.ts index f9db0c8..b905a04 100644 --- a/models/bilibili/bilibili.api.ts +++ b/models/bilibili/bilibili.api.ts @@ -27,9 +27,8 @@ export class BiliApi { /**header */ static BILIBILI_HEADERS = { 'Accept': '*/*', - 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-type': 'application/json;charset=UTF-8', + 'Accept-Language': 'zh-CN,en-US;q=0.5', + 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Cookie': '', 'pragma': 'no-cache', 'Cache-control': 'max-age=0', @@ -41,15 +40,15 @@ export class BiliApi { 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-site', 'Sec-Fetch-User': '?0', + 'Priority': 'u=4', 'TE': 'trailers', - 'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0' + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0' }; /**Login header */ static BIlIBILI_LOGIN_HEADERS = { 'Accept': '*/*', - 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', - 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'zh-CN,en-US;q=0.5', + 'Accept-Encoding': 'gzip, deflate, br, zstd', 'DNT': '1', 'Sec-GPC': '1', 'Upgrade-Insecure-Requests': '1', @@ -62,8 +61,8 @@ export class BiliApi { /**FullArticle header */ static BILIBILI_ARTICLE_HEADERS = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8', - 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', - 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'zh-CN,en-US;q=0.5', + 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Content-type': 'text/html; charset=utf-8', 'Cookie': '', 'pragma': 'no-cache', @@ -77,6 +76,6 @@ export class BiliApi { 'Sec-Fetch-User': '?1', 'TE': 'trailers', 'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0' + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0' }; } diff --git a/models/bilibili/bilibili.get.web.data.ts b/models/bilibili/bilibili.get.web.data.ts index 68a8543..554691d 100644 --- a/models/bilibili/bilibili.get.web.data.ts +++ b/models/bilibili/bilibili.get.web.data.ts @@ -39,8 +39,8 @@ export class BiliGetWebData { headers: lodash.merge(BiliApi.BILIBILI_HEADERS, { Cookie: `${cookie}`, Host: `api.bilibili.com`, - Origin: 'https://www.bilibili.com', - Referer: `https://www.bilibili.com/` + Origin: 'https://space.bilibili.com', + Referer: `https://space.bilibili.com/${uid}/dynamic` }) }); return res; diff --git a/models/bilibili/bilibili.task.ts b/models/bilibili/bilibili.task.ts index f39d922..3c5b8ac 100644 --- a/models/bilibili/bilibili.task.ts +++ b/models/bilibili/bilibili.task.ts @@ -115,11 +115,11 @@ export class BiliTask { continue; } else if (resp.code !== 0) { logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:${resp.code}`); - continue; + return; } } else { logger.error(`获取 ${subInfoOfup.uid} 动态失败,无响应数据,请待下次任务自动重试`); - continue; + return; } } diff --git a/package.json b/package.json index 38a3ad7..26436e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yuki-plugin", - "version": "2.0.5-7", + "version": "2.0.5-8", "author": "snowtafir", "description": "优纪插件,yunzai-V4 关于 微博推送、B站推送 等功能的拓展插件", "main": "./index",