fix: 修复单个哈希查询时的歌曲ID获取逻辑

This commit is contained in:
lixiangwuxian
2025-03-08 21:15:18 +08:00
parent e645ed5366
commit b22185e87f
2 changed files with 23 additions and 3 deletions

View File

@@ -389,7 +389,7 @@ func (ss *ssQuery) GetRecentScores(count int, qqId string) ([]RecordDataLite, er
if err != nil {
return nil, err
}
for i := 0; i < len(records); i++ {
for i := range records {
records[i].SongId = hashToSongId[records[i].SongHash]
}
return records, nil
@@ -425,7 +425,15 @@ func GetSongIdsByHash(hashs []string) (hashToSongId map[string]string, err error
var response map[string]struct {
ID string `json:"id"`
}
err = json.Unmarshal(body, &response)
if len(batchHashs) == 1 {
var singleResponse struct {
ID string `json:"id"`
}
err = json.Unmarshal(body, &singleResponse)
response[batchHashs[0]] = singleResponse
} else {
err = json.Unmarshal(body, &response)
}
if err != nil {
return nil, err
}