mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2026-04-05 18:49:06 +08:00
Merge pull request #68 from njzydark/patch-3
fix(utils/isTrackPlayable): songs that have been removed from the shelves cannot be played either
This commit is contained in:
@@ -47,7 +47,10 @@ export function getPlaylistDetail(id, noCache = false) {
|
||||
method: "get",
|
||||
params,
|
||||
}).then((data) => {
|
||||
data.playlist.tracks = mapTrackPlayableStatus(data.playlist.tracks);
|
||||
data.playlist.tracks = mapTrackPlayableStatus(
|
||||
data.playlist.tracks,
|
||||
data.privileges || []
|
||||
);
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export function getTrackDetail(ids) {
|
||||
ids,
|
||||
},
|
||||
}).then((data) => {
|
||||
data.songs = mapTrackPlayableStatus(data.songs);
|
||||
data.songs = mapTrackPlayableStatus(data.songs, data.privileges);
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,12 +25,21 @@ export function isTrackPlayable(track) {
|
||||
) {
|
||||
result.playable = false;
|
||||
result.reason = "No Copyright";
|
||||
} else if (track.privilege?.st < 0) {
|
||||
result.playable = false;
|
||||
result.reason = "The song has been removed from the shelves";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapTrackPlayableStatus(tracks) {
|
||||
export function mapTrackPlayableStatus(tracks, privileges = []) {
|
||||
return tracks.map((t) => {
|
||||
const privilege = privileges.find((item) => item.id === t.id) || {};
|
||||
if (t.privilege) {
|
||||
Object.assign(t.privilege, privilege);
|
||||
} else {
|
||||
t.privilege = privilege;
|
||||
}
|
||||
let result = isTrackPlayable(t);
|
||||
t.playable = result.playable;
|
||||
t.reason = result.reason;
|
||||
|
||||
Reference in New Issue
Block a user