From e4a11582dc50af49e043ed877d6fb9c33c909789 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:26:32 -0700 Subject: [PATCH] fix: bvid2aid --- src/utils/Bilibili/BiliOperate.ts | 4 ++-- src/utils/mediafetch/bilivideo.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/Bilibili/BiliOperate.ts b/src/utils/Bilibili/BiliOperate.ts index ec5e5813..6dda3bc1 100644 --- a/src/utils/Bilibili/BiliOperate.ts +++ b/src/utils/Bilibili/BiliOperate.ts @@ -2,7 +2,7 @@ import { getBiliJct } from '@utils/Bilibili/biliCookies'; import bfetch from '@utils/BiliFetch'; import { logger } from '@utils/Logger'; import { throttler } from '../throttle'; -import { bvidToAid } from '../bvid'; +import { BVIDtoAID } from '../mediafetch/bilivideo'; const BILI_LIKE_API = 'https://api.bilibili.com/x/web-interface/archive/like'; const BILI_RELATED_API = @@ -126,7 +126,7 @@ export const sendBVFavorite = async ( }, referrer: `https://www.bilibili.com/video/${bvid}/`, body: { - rid: String(bvidToAid(bvid)), + rid: BVIDtoAID(bvid), add_media_ids: addfav.join(','), del_media_ids: removefav.join(','), csrf: biliJct, diff --git a/src/utils/mediafetch/bilivideo.ts b/src/utils/mediafetch/bilivideo.ts index 00d7781b..19d1e024 100644 --- a/src/utils/mediafetch/bilivideo.ts +++ b/src/utils/mediafetch/bilivideo.ts @@ -64,6 +64,13 @@ export const fetchBVID = async ( return fetchBVIDRaw(bvid); }); +export const BVIDtoAID = (bvid: string): Promise => + biliApiLimiter.schedule(async () => { + const res = await bfetch(URL_VIDEO_INFO.replace('{bvid}', bvid)); + const json = await res.json(); + return String(json.data.aid); + }); + export const fetchBiliBVIDs = async ( BVids: string[], progressEmitter: (val: number) => void = () => undefined,