mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 21:12:49 +08:00
feat(search): server-side offset pagination through providers + /search route (#115 backend)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
81b8953d52
commit
a1cc0b8574
14 files changed
+322
-34
No files matched your search
+5
-2
@@ -616,12 +616,15 @@ export class KugouProvider implements MusicProvider {
|
||||
}
|
||||
|
||||
// --- Search (verified live via the unsigned mobile endpoint) ---------------
|
||||
async search(query: string, limit = 20): Promise<SearchResult> {
|
||||
async search(query: string, limit = 20, offset = 0): Promise<SearchResult> {
|
||||
const q = query.trim();
|
||||
if (!q) return { songs: [], playlists: [], albums: [] };
|
||||
try {
|
||||
// Songs only. `page` is the 1-based cursor; the web pages in limit-aligned
|
||||
// steps so offset is a multiple of pagesize.
|
||||
const page = Math.floor(offset / limit) + 1;
|
||||
const res = await this.mobileHttp.get("http://mobilecdn.kugou.com/api/v3/search/song", {
|
||||
params: { format: "json", keyword: q, page: 1, pagesize: limit, showtype: 1 },
|
||||
params: { format: "json", keyword: q, page, pagesize: limit, showtype: 1 },
|
||||
});
|
||||
const info = res.data?.data?.info as KugouRawSong[] | undefined;
|
||||
return { songs: mapKugouSongs(info), playlists: [], albums: [] };
|
||||
|
||||
Reference in new issue
Block a user