From b61baf5760dcc0897f050c6be38edb601cfb5c0d Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Fri, 11 Mar 2022 13:14:23 -0800 Subject: [PATCH] Transliterate song metadata (Fixes #13) --- music.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/music.go b/music.go index 5c46bae..cac2fe2 100644 --- a/music.go +++ b/music.go @@ -22,22 +22,27 @@ import ( "github.com/rs/zerolog/log" "go.arsenm.dev/infinitime" "go.arsenm.dev/infinitime/pkg/player" + "go.arsenm.dev/itd/translit" ) func initMusicCtrl(dev *infinitime.Device) error { 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) { + newVal := translit.Transliterate(val, maps...) if !firmwareUpdating { switch ct { case player.ChangeTypeStatus: dev.Music.SetStatus(val == "Playing") case player.ChangeTypeTitle: - dev.Music.SetTrack(val) + dev.Music.SetTrack(newVal) case player.ChangeTypeAlbum: - dev.Music.SetAlbum(val) + dev.Music.SetAlbum(newVal) case player.ChangeTypeArtist: - dev.Music.SetArtist(val) + dev.Music.SetArtist(newVal) } } })