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 <contrib@gensokyo.uk>
This commit is contained in:
parent
8edf742aaa
commit
5fe911dd01
@ -12,12 +12,12 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
flagMetadataPath string
|
flagMetadataPath string
|
||||||
flagAutoplay string
|
flagAutoplay int
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&flagMetadataPath, "m", "data/metadata", "Path to enriched metadata")
|
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 {
|
func handleAPINew(metadata *monstersirenfetch.Metadata) http.HandlerFunc {
|
||||||
@ -76,7 +76,7 @@ func handleAPINew(metadata *monstersirenfetch.Metadata) http.HandlerFunc {
|
|||||||
{
|
{
|
||||||
resp := monstersirenfetch.SongsResponse{Data: monstersirenfetch.SongsData{
|
resp := monstersirenfetch.SongsResponse{Data: monstersirenfetch.SongsData{
|
||||||
List: make([]monstersirenfetch.Song, len(metadata.Songs)),
|
List: make([]monstersirenfetch.Song, len(metadata.Songs)),
|
||||||
Autoplay: flagAutoplay,
|
Autoplay: monstersirenfetch.StringInt(flagAutoplay),
|
||||||
}}
|
}}
|
||||||
for i := range metadata.Songs {
|
for i := range metadata.Songs {
|
||||||
if !metadata.Songs[i].Copy(&resp.Data.List[i], monstersirenfetch.SongVariantBase) {
|
if !metadata.Songs[i].Copy(&resp.Data.List[i], monstersirenfetch.SongVariantBase) {
|
||||||
|
|||||||
4
songs.go
4
songs.go
@ -5,6 +5,6 @@ type SongsResponse Response[SongsData]
|
|||||||
|
|
||||||
// SongsData is the type of [SongsResponse] data.
|
// SongsData is the type of [SongsResponse] data.
|
||||||
type SongsData = struct {
|
type SongsData = struct {
|
||||||
List []Song `json:"list"`
|
List []Song `json:"list"`
|
||||||
Autoplay string `json:"autoplay"`
|
Autoplay StringInt `json:"autoplay"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -770,5 +770,5 @@ func TestSongs(t *testing.T) {
|
|||||||
{CID: 125010, Name: "泛用型自动化解决方案0.3.2.9f2", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}},
|
{CID: 125010, Name: "泛用型自动化解决方案0.3.2.9f2", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}},
|
||||||
{CID: 232202, Name: "生命流", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}},
|
{CID: 232202, Name: "生命流", AlbumCID: 4527, Artists: []string{"塞壬唱片-MSR"}},
|
||||||
{CID: 953921, Name: "逃亡part2", 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)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user