Skip to content

Commit

Permalink
fix: bvid2aid
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed Apr 19, 2024
1 parent efdb955 commit e4a1158
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/Bilibili/BiliOperate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/utils/mediafetch/bilivideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ export const fetchBVID = async (
return fetchBVIDRaw(bvid);
});

export const BVIDtoAID = (bvid: string): Promise<string> =>
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,
Expand Down

0 comments on commit e4a1158

Please sign in to comment.