feat(ipc): add an endpoint for getting current track (#911)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package mediaprovider
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -205,11 +206,14 @@ type SavedPlayQueue struct {
|
||||
}
|
||||
|
||||
type RadioStation struct {
|
||||
Name string
|
||||
ID string
|
||||
StationName string
|
||||
HomePageURL string
|
||||
StreamURL string
|
||||
CoverArtID string
|
||||
|
||||
Title string
|
||||
Artists []string
|
||||
CoverArtID string
|
||||
}
|
||||
|
||||
type MediaItemType int
|
||||
@@ -267,16 +271,30 @@ func (r *RadioStation) Metadata() MediaItemMetadata {
|
||||
if r == nil {
|
||||
return MediaItemMetadata{}
|
||||
}
|
||||
name := r.Title
|
||||
if name == "" {
|
||||
name = r.StationName
|
||||
}
|
||||
return MediaItemMetadata{
|
||||
Type: MediaItemTypeRadioStation,
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
Name: name,
|
||||
CoverArtID: r.CoverArtID,
|
||||
Artists: r.Artists,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RadioStation) Copy() MediaItem {
|
||||
return r // no need to copy since RadioStations are immutable
|
||||
return &RadioStation{
|
||||
ID: r.ID,
|
||||
StationName: r.StationName,
|
||||
HomePageURL: r.HomePageURL,
|
||||
StreamURL: r.StreamURL,
|
||||
|
||||
Title: r.Title,
|
||||
Artists: slices.Clone(r.Artists),
|
||||
CoverArtID: r.CoverArtID,
|
||||
}
|
||||
}
|
||||
|
||||
type ContentType int
|
||||
|
||||
@@ -70,7 +70,7 @@ func (s *subsonicMediaProvider) SearchAll(searchQuery string, maxResults int) ([
|
||||
r, e := s.GetRadioStations()
|
||||
if e == nil {
|
||||
radios = sharedutil.FilterSlice(r, func(r *mediaprovider.RadioStation) bool {
|
||||
return helpers.AllTermsMatch(strings.ToLower(sanitize.Accents(r.Name)), queryLowerWords)
|
||||
return helpers.AllTermsMatch(strings.ToLower(sanitize.Accents(r.StationName)), queryLowerWords)
|
||||
})
|
||||
}
|
||||
wg.Done()
|
||||
@@ -156,7 +156,7 @@ func mergeResults(
|
||||
results = append(results, &mediaprovider.SearchResult{
|
||||
Type: mediaprovider.ContentTypeRadioStation,
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
Name: r.StationName,
|
||||
Item: r,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ func (s *subsonicMediaProvider) GetRadioStations() ([]*mediaprovider.RadioStatio
|
||||
return &mediaprovider.RadioStation{
|
||||
// TODO - subsonic library is missing ID in its radiostation object. add it
|
||||
ID: "radio-" + strings.ReplaceAll(rs.Name, " ", ""),
|
||||
Name: rs.Name,
|
||||
StationName: rs.Name,
|
||||
HomePageURL: rs.HomePageUrl,
|
||||
StreamURL: rs.StreamUrl,
|
||||
CoverArtID: rs.CoverArt,
|
||||
|
||||
Reference in New Issue
Block a user