From f4fae9d8b6ac5c89a22a341d671626e6e547a282 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Mon, 19 Aug 2024 15:18:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=A2=9E=E5=8A=A0B?= =?UTF-8?q?=E7=AB=99=E7=95=AA=E5=89=A7=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 26 ++++++++++++++++++++------ constants/tools.js | 13 +++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 8480a6d..9a10055 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -26,8 +26,9 @@ import { XHS_NO_WATERMARK_HEADER, } from "../constants/constant.js"; import { + ANIME_SERIES_SEARCH_LINK, BILI_EP_INFO, - BILI_ONLINE, + BILI_ONLINE, BILI_SSID_INFO, BILI_STREAM_INFO, BILI_SUMMARY, DY_COMMENT, @@ -519,9 +520,8 @@ export class tools extends plugin { return true; } // 处理番剧 - if (url.includes("ep")) { - const ep = url.match(/\/ep(\d+)/)?.[1]; - await this.biliEpInfo(ep, e); + if (url.includes("play\/ep") || url.includes("play\/ss")) { + await this.biliEpInfo(url, e); return true } // 处理专栏 @@ -615,11 +615,24 @@ export class tools extends plugin { /** * 获取哔哩哔哩番剧信息 - * @param ep + * @param url * @param e * @returns {Promise} */ - async biliEpInfo(ep, e) { + async biliEpInfo(url, e) { + let ep; + // 处理ssid + if (url.includes("play\/ss")) { + const ssid = url.match(/\/ss(\d+)/)?.[1]; + let resp = await (await fetch(BILI_SSID_INFO.replace("{}", ssid), { + headers: BILI_HEADER + })).json() + ep = (resp.result.main_section.episodes[0].share_url).replace("https://www.bilibili.com/bangumi/play/ep", "") + } + // 处理普通情况,上述情况无法处理的 + if (_.isEmpty(ep)) { + ep = url.match(/\/ep(\d+)/)?.[1]; + } const resp = await (await fetch(BILI_EP_INFO.replace("{}", ep), { headers: BILI_HEADER })).json(); @@ -636,6 +649,7 @@ export class tools extends plugin { segment.image(resp.result.cover), `${ this.identifyPrefix }识别:哔哩哔哩番剧,${ result.title }\n🎯 评分: ${ result?.rating?.score ?? '-' } / ${ result?.rating?.count ?? '-' }\n📺 ${ result.new_ep.desc }, ${ result.seasons[0].new_ep.index_show }\n`, `${ formatBiliInfo(dataProcessMap) }`, + `\n\n在线观看: ${ANIME_SERIES_SEARCH_LINK}${encodeURI(result.title)}` ], true) } diff --git a/constants/tools.js b/constants/tools.js index 395b5a8..4891754 100644 --- a/constants/tools.js +++ b/constants/tools.js @@ -75,6 +75,13 @@ export const BILI_ONLINE = "https://api.bilibili.com/x/player/online/total?bvid= */ export const BILI_EP_INFO = "https://api.bilibili.com/pgc/view/web/season?ep_id={}" +/** + * 剧集基本信息 + * https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/bangumi/info.md + * @type {string} + */ +export const BILI_SSID_INFO = "https://api.bilibili.com/pgc/web/season/section?season_id={}" + /** * 米游社网页端获取文章 * https://github.com/UIGF-org/mihoyo-api-collect/blob/main/hoyolab/article/article.md#%E8%8E%B7%E5%8F%96%E5%AE%8C%E6%95%B4%E6%96%87%E7%AB%A0%E4%BF%A1%E6%81%AF @@ -180,3 +187,9 @@ export const WEIBO_SINGLE_INFO = "https://m.weibo.cn/statuses/show?id={}" * @type {string} */ export const WEISHI_VIDEO_INFO = "https://h5.weishi.qq.com/webapp/json/weishi/WSH5GetPlayPage?feedid={}" + +/** + * 番剧搜索链接 + * @type {string} + */ +export const ANIME_SERIES_SEARCH_LINK = "https://ylu.cc/so.php?wd=" \ No newline at end of file