diff --git a/services/mpris/mpris_unix.go b/services/mpris/mpris_unix.go index d8622c1..f34fb6b 100644 --- a/services/mpris/mpris_unix.go +++ b/services/mpris/mpris_unix.go @@ -5,6 +5,8 @@ package mpris import ( "sptlrx/player" "strings" + "net/url" + "path/filepath" "github.com/Pauloo27/go-mpris" "github.com/godbus/dbus/v5" @@ -79,6 +81,15 @@ func (c *Client) State() (*player.State, error) { title = t } + // In case the player uses the file name with extension as title + if u, ok := meta["xesam:url"].Value().(string); ok { + u, err := url.Parse(u) + if err == nil { + ext := filepath.Ext(u.Path) + title = strings.TrimSuffix(title, ext) + } + } + var artist string switch a := meta["xesam:artist"].Value(); a.(type) { case string: