Skip to content

Commit e149349

Browse files
committed
fix: trim .ext from title to optimize query.
The unexpected .<ext> field in the title directly corrupts local.go:findFile, so that the last part of the title never accurately matches the lrc file.
1 parent b243a22 commit e149349

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

services/mpris/mpris_unix.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package mpris
55
import (
66
"sptlrx/player"
77
"strings"
8+
"net/url"
9+
"path/filepath"
810

911
"github.com/Pauloo27/go-mpris"
1012
"github.com/godbus/dbus/v5"
@@ -79,6 +81,15 @@ func (c *Client) State() (*player.State, error) {
7981
title = t
8082
}
8183

84+
// In case the player uses the file name with extension as title
85+
if u, ok := meta["xesam:url"].Value().(string); ok {
86+
u, err := url.Parse(u)
87+
if err == nil {
88+
ext := filepath.Ext(u.Path)
89+
title = strings.TrimSuffix(title, ext)
90+
}
91+
}
92+
8293
var artist string
8394
switch a := meta["xesam:artist"].Value(); a.(type) {
8495
case string:

0 commit comments

Comments
 (0)