Skip to content

Commit c03f1cb

Browse files
authored
Merge pull request #52 from YanceyChiew/local_fix_best_file
fix: trim .ext from title to optimize query.
2 parents b243a22 + e149349 commit c03f1cb

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)