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:
saopig1andClaude Opus 4.8 committed 2026-07-04 14:36:54 +08:00
1 parent 81b8953d52
commit a1cc0b8574
14 files changed
+322 -34

No files matched your search

+5 -2
View File
@@ -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: [] };