diff --git a/backend/mediaprovider/mediaprovider.go b/backend/mediaprovider/mediaprovider.go index 648a363..c3d97d7 100644 --- a/backend/mediaprovider/mediaprovider.go +++ b/backend/mediaprovider/mediaprovider.go @@ -267,6 +267,10 @@ type LyricsProvider interface { GetLyrics(track *Track) (*Lyrics, error) } +type RadioProvider interface { + GetRadioStations() ([]*RadioStation, error) +} + type JukeboxProvider interface { JukeboxStart() error JukeboxStop() error diff --git a/backend/mediaprovider/subsonic/subsonicmediaprovider.go b/backend/mediaprovider/subsonic/subsonicmediaprovider.go index bddffea..bbe7dcd 100644 --- a/backend/mediaprovider/subsonic/subsonicmediaprovider.go +++ b/backend/mediaprovider/subsonic/subsonicmediaprovider.go @@ -386,6 +386,7 @@ func (s *subsonicMediaProvider) GetLyrics(track *mediaprovider.Track) (*mediapro } // CanSavePlayQueue interface +var _ mediaprovider.CanSavePlayQueue = (*subsonicMediaProvider)(nil) func (s *subsonicMediaProvider) SavePlayQueue(trackIDs []string, currentTrackIdx int, timeSeconds int) error { if len(trackIDs) == 0 { @@ -413,6 +414,24 @@ func (s *subsonicMediaProvider) GetPlayQueue() (*mediaprovider.SavedPlayQueue, e return savedQueue, nil } +// RadioProvider interface +var _ mediaprovider.RadioProvider = (*subsonicMediaProvider)(nil) + +func (s *subsonicMediaProvider) GetRadioStations() ([]*mediaprovider.RadioStation, error) { + rs, err := s.client.GetInternetRadioStations() + if err != nil { + return nil, err + } + return sharedutil.MapSlice(rs, func(rs *subsonic.InternetRadioStation) *mediaprovider.RadioStation { + return &mediaprovider.RadioStation{ + ID: "radio-" + strings.ReplaceAll(rs.Name, " ", ""), + Name: rs.Name, + HomePageURL: rs.HomePageUrl, + StreamURL: rs.StreamUrl, + } + }), nil +} + func toTrack(ch *subsonic.Child) *mediaprovider.Track { if ch == nil { return nil