Merge branch 'master' into ldap_auth

This commit is contained in:
betapictoris
2024-04-01 10:49:18 -07:00
committed by GitHub
11 changed files with 102 additions and 13 deletions

No files matched your search

+3 -1
View File
@@ -95,6 +95,8 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
if err := scrobbleStatsUpdatePodcastEpisode(c.dbc, id.Value); err != nil {
return spec.NewError(0, "error updating stats: %v", err)
}
default:
return spec.NewError(10, "can't scrobble type %s", id.Type)
}
if scrobbleTrack.Track == "" {
@@ -435,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 {
+3
View File
@@ -199,6 +199,9 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
return spec.NewError(0, "couldn't find transcode preference: %v", err)
}
if pref == nil {
if maxBitRate > 0 && maxBitRate < audioFile.AudioBitrate() {
return spec.NewError(0, "param maxBitRate requested and no user transcode preferences found for user %q and client %q. please configure transcode settings if you want to transcode", user.Name, client)
}
log.Printf("serving raw file, no user transcode preferences found for user %q and client %q", user.Name, client)
http.ServeFile(w, r, file.AbsPath())
return nil
+13 -1
View File
@@ -29,6 +29,9 @@ func Locate(dbc *db.DB, id specid.ID) (Result, error) {
case specid.PodcastEpisode:
var pe db.PodcastEpisode
return &pe, dbc.Preload("Podcast").Where("id=? AND status=?", id.Value, db.PodcastEpisodeStatusCompleted).Find(&pe).Error
case specid.InternetRadioStation:
var irs db.InternetRadioStation
return &irs, dbc.Where("id=?", id.Value).Find(&irs).Error
default:
return nil, ErrNotFound
}
@@ -36,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
}
@@ -53,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) {