mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
feat(qq): add getUserPlaylists support for QQ Music provider
This commit is contained in:
1 parent
1a5bd74357
commit
43f4dd94aa
1 file changed
+22
@@ -271,4 +271,26 @@ export class QQMusicProvider implements MusicProvider {
|
|||||||
return { loggedIn: false };
|
return { loggedIn: false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getUserPlaylists(): Promise<Playlist[]> {
|
||||||
|
if (!this.cookie) return [];
|
||||||
|
const uinMatch = /(?:^|; )uin=o?0?(\d+)/.exec(this.cookie);
|
||||||
|
const uin = uinMatch ? uinMatch[1] : "";
|
||||||
|
if (!uin) return [];
|
||||||
|
try {
|
||||||
|
const res = await this.api.get("/user/getUserPlaylists", {
|
||||||
|
params: { uin, ...this.cookieParams },
|
||||||
|
});
|
||||||
|
if (res.data?.response?.code !== 0) return [];
|
||||||
|
return (res.data?.response?.data?.playlists ?? []).map((p: any) => ({
|
||||||
|
id: String(p.dissid ?? p.id ?? ""),
|
||||||
|
name: p.dissname ?? p.name ?? "",
|
||||||
|
coverUrl: p.imgurl ?? p.coverUrl ?? "",
|
||||||
|
songCount: p.song_count ?? p.listennum ?? 0,
|
||||||
|
platform: "qq",
|
||||||
|
}));
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user