Skip to content

Commit

Permalink
fix: BiliFavSync
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed Apr 19, 2024
1 parent 4cf3fc1 commit 6b6a4c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@mui/material": "^5.15.15",
"@mui/styles": "^5.15.15",
"axios": "^1.6.8",
"base-64": "^1.0.0",
"base64-js": "^1.5.1",
"big-integer": "^1.6.52",
"bottleneck": "^2.19.5",
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/usePlaylistCRUD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNoxSetting } from '@APM/stores/useApp';
import { dummyPlaylist } from '@APM/objects/Playlist';
import usePlaylistCRUD from '@APM/hooks/usePlaylistCRUD';
import textToDialogContent from '@components/dialogs/DialogContent';
import { updateSubscribeFavList as updateSubscribeFavListRaw } from '@APM/utils/BiliSubscribe';
import { updateSubscribeFavList as _updateSubscribeFavList } from '@APM/utils/BiliSubscribe';
import { reorder } from '@APM/utils/Utils';

interface UpdateSubscribeFavListProps {
Expand Down Expand Up @@ -124,14 +124,14 @@ export default (mPlaylist?: NoxMedia.Playlist) => {
subscribeUrls,
}: UpdateSubscribeFavListProps) => {
const oldListLength = playlist.songList.length;
const newList: NoxMedia.Playlist = await updateSubscribeFavListRaw({
const newList = await _updateSubscribeFavList({
playlist,
subscribeUrls,
updatePlaylist,
});
// sinse we do NOT delete songs from this operation, any update requiring a fav update really need
// to have a change in list size.
if (oldListLength !== newList.songList.length) {
if (oldListLength !== newList?.songList?.length) {
setSelectedList(playlists[playlist.id]!);
}
return newList;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Bilibili/BiliOperate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bvidToAid } from '@APM/utils/bvid';
import { BVIDtoAID } from '@APM/utils/mediafetch/bilivideo';

const BILI_LIKE_API = 'https://api.bilibili.com/x/web-interface/archive/like';
const BILI_TRIP_API =
Expand Down Expand Up @@ -107,7 +107,7 @@ export const sendBVFavorite = async (
},
referrer: `https://www.bilibili.com/video/${bvid}/`,
body: new URLSearchParams({
rid: String(bvidToAid(bvid)),
rid: await BVIDtoAID(bvid),
add_media_ids: addfav.join(','),
del_media_ids: removefav.join(','),
csrf: (biliject?.value as string) || '',
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base-64@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/base-64/-/base-64-1.0.0.tgz#09d0f2084e32a3fd08c2475b973788eee6ae8f4a"
integrity sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==

base62@^1.1.0:
version "1.2.8"
resolved "https://registry.yarnpkg.com/base62/-/base62-1.2.8.tgz#1264cb0fb848d875792877479dbe8bae6bae3428"
Expand Down

0 comments on commit 6b6a4c9

Please sign in to comment.