feat: support internet radio stations for jukebox

fixes #481
This commit is contained in:
sentriz
2024-03-11 19:21:05 +01:00
parent 6ce1fe5a7e
commit 62d49a33d1
3 changed files with 15 additions and 3 deletions

View File

@@ -437,7 +437,7 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
case "get":
specPlaylist, err := getSpecPlaylist()
if err != nil {
return spec.NewError(10, "error getting status tracks: %v", err)
return spec.NewError(10, "error getting spec playlist: %v", err)
}
status, err := getSpecStatus()
if err != nil {

View File

@@ -39,7 +39,7 @@ func Locate(dbc *db.DB, id specid.ID) (Result, error) {
// Locate maps a location on the filesystem to a specid
func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (Result, error) {
if !filepath.IsAbs(path) {
if !strings.HasPrefix(path, "http") && !filepath.IsAbs(path) {
return nil, ErrNotAbs
}
@@ -56,6 +56,15 @@ func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (
return nil, ErrNotFound
}
// probably internet radio
if strings.HasPrefix(path, "http") {
var irs db.InternetRadioStation
if err := dbc.First(&irs, "stream_url=?", path).Error; err == nil {
return &irs, nil
}
return nil, ErrNotFound
}
var musicPath string
for _, mp := range musicPaths {
if fileutil.HasPrefix(path, mp) {