From 5fe911dd01df29eee0f06c1ff58b067d956ff770 Mon Sep 17 00:00:00 2001 From: Yonah Date: Fri, 19 Sep 2025 20:49:51 +0900 Subject: [PATCH] songs: represent autoplay as integer This is represented in the same way as CID fields, so use the same data type. Signed-off-by: Yonah --- cmd/msrserve/api.go | 6 +++--- songs.go | 4 ++-- songs_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/msrserve/api.go b/cmd/msrserve/api.go index 54fa967..4a2e1c8 100644 --- a/cmd/msrserve/api.go +++ b/cmd/msrserve/api.go @@ -12,12 +12,12 @@ import ( var ( flagMetadataPath string - flagAutoplay string + flagAutoplay int ) func init() { flag.StringVar(&flagMetadataPath, "m", "data/metadata", "Path to enriched metadata") - flag.StringVar(&flagAutoplay, "autoplay", "048794", "Value to set for autoplay field in /api/songs") + flag.IntVar(&flagAutoplay, "autoplay", 48794, "Value to set for autoplay field in /api/songs") } func handleAPINew(metadata *monstersirenfetch.Metadata) http.HandlerFunc { @@ -76,7 +76,7 @@ func handleAPINew(metadata *monstersirenfetch.Metadata) http.HandlerFunc { { resp := monstersirenfetch.SongsResponse{Data: monstersirenfetch.SongsData{ List: make([]monstersirenfetch.Song, len(metadata.Songs)), - Autoplay: flagAutoplay, + Autoplay: monstersirenfetch.StringInt(flagAutoplay), }} for i := range metadata.Songs { if !metadata.Songs[i].Copy(&resp.Data.List[i], monstersirenfetch.SongVariantBase) { diff --git a/songs.go b/songs.go index 2c41555..181f368 100644 --- a/songs.go +++ b/songs.go @@ -5,6 +5,6 @@ type SongsResponse Response[SongsData] // SongsData is the type of [SongsResponse] data. type SongsData = struct { - List []Song `json:"list"` - Autoplay string `json:"autoplay"` + List []Song `json:"list"` + Autoplay StringInt `json:"autoplay"` } diff --git a/songs_test.go b/songs_test.go index 6bcc408..a85268c 100644 --- a/songs_test.go +++ b/songs_test.go @@ -770,5 +770,5 @@ func TestSongs(t *testing.T) { {CID: 125010, Name: "泛用型自动化解决方案0.3.2.9f2", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}}, {CID: 232202, Name: "生命流", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}}, {CID: 953921, Name: "逃亡part2", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}}, - {CID: 880375, Name: "Synthetech", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}}}, Autoplay: "048794"}}, songsJSON) + {CID: 880375, Name: "Synthetech", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}}}, Autoplay: 48794}}, songsJSON) }