@@ -12,6 +12,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -133,7 +134,9 @@ func (j *Jukebox) SetPlaylist(items []string) error {
|
|||||||
|
|
||||||
var newPlayingIndex = -1
|
var newPlayingIndex = -1
|
||||||
for i, item := range items {
|
for i, item := range items {
|
||||||
item, _ = filepath.Abs(item)
|
if !strings.HasPrefix(item, "http") {
|
||||||
|
item, _ = filepath.Abs(item)
|
||||||
|
}
|
||||||
if currentPlayingIndex >= 0 && playlist[currentPlayingIndex].Filename == item {
|
if currentPlayingIndex >= 0 && playlist[currentPlayingIndex].Filename == item {
|
||||||
newPlayingIndex = i
|
newPlayingIndex = i
|
||||||
continue // don't add current track to loadlist
|
continue // don't add current track to loadlist
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
|
|||||||
case "get":
|
case "get":
|
||||||
specPlaylist, err := getSpecPlaylist()
|
specPlaylist, err := getSpecPlaylist()
|
||||||
if err != nil {
|
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()
|
status, err := getSpecStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func Locate(dbc *db.DB, id specid.ID) (Result, error) {
|
|||||||
|
|
||||||
// Locate maps a location on the filesystem to a specid
|
// Locate maps a location on the filesystem to a specid
|
||||||
func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (Result, error) {
|
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
|
return nil, ErrNotAbs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +56,15 @@ func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (
|
|||||||
return nil, ErrNotFound
|
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
|
var musicPath string
|
||||||
for _, mp := range musicPaths {
|
for _, mp := range musicPaths {
|
||||||
if fileutil.HasPrefix(path, mp) {
|
if fileutil.HasPrefix(path, mp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user