Transliterate song metadata (Fixes #13)

This commit is contained in:
Elara 2022-03-11 13:14:23 -08:00
parent 32bb141244
commit 62597f70ee

View File

@ -22,22 +22,27 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"go.arsenm.dev/infinitime" "go.arsenm.dev/infinitime"
"go.arsenm.dev/infinitime/pkg/player" "go.arsenm.dev/infinitime/pkg/player"
"go.arsenm.dev/itd/translit"
) )
func initMusicCtrl(dev *infinitime.Device) error { func initMusicCtrl(dev *infinitime.Device) error {
player.Init() player.Init()
maps := k.Strings("notifs.translit.use")
translit.Transliterators["custom"] = translit.Map(k.Strings("notifs.translit.custom"))
player.OnChange(func(ct player.ChangeType, val string) { player.OnChange(func(ct player.ChangeType, val string) {
newVal := translit.Transliterate(val, maps...)
if !firmwareUpdating { if !firmwareUpdating {
switch ct { switch ct {
case player.ChangeTypeStatus: case player.ChangeTypeStatus:
dev.Music.SetStatus(val == "Playing") dev.Music.SetStatus(val == "Playing")
case player.ChangeTypeTitle: case player.ChangeTypeTitle:
dev.Music.SetTrack(val) dev.Music.SetTrack(newVal)
case player.ChangeTypeAlbum: case player.ChangeTypeAlbum:
dev.Music.SetAlbum(val) dev.Music.SetAlbum(newVal)
case player.ChangeTypeArtist: case player.ChangeTypeArtist:
dev.Music.SetArtist(val) dev.Music.SetArtist(newVal)
} }
} }
}) })