feat(subsonic): gracefully handle missing podcast episode paths when returning playlists
fixes #345 * fix return playlist if file not found and do not add to playlist not downloaded podcast --------- Co-authored-by: sentriz <senan@senan.xyz>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
@@ -208,8 +209,10 @@ func playlistRender(c *Controller, params params.Params, playlistID string, play
|
|||||||
for _, path := range playlist.Items {
|
for _, path := range playlist.Items {
|
||||||
file, err := specidpaths.Lookup(c.DB, PathsOf(c.MusicPaths), c.PodcastsPath, path)
|
file, err := specidpaths.Lookup(c.DB, PathsOf(c.MusicPaths), c.PodcastsPath, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("lookup path %q: %w", path, err)
|
log.Printf("error looking up path %q: %s", path, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var trch *spec.TrackChild
|
var trch *spec.TrackChild
|
||||||
switch id := file.SID(); id.Type {
|
switch id := file.SID(); id.Type {
|
||||||
case specid.Track:
|
case specid.Track:
|
||||||
@@ -237,5 +240,8 @@ func playlistRender(c *Controller, params params.Params, playlistID string, play
|
|||||||
trch.TranscodedSuffix = transcodeSuffix
|
trch.TranscodedSuffix = transcodeSuffix
|
||||||
resp.List = append(resp.List, trch)
|
resp.List = append(resp.List, trch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp.SongCount = len(resp.List)
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func Locate(dbc *db.DB, podcastsPath string, id specid.ID) (Result, error) {
|
|||||||
}
|
}
|
||||||
case specid.PodcastEpisode:
|
case specid.PodcastEpisode:
|
||||||
var pe db.PodcastEpisode
|
var pe db.PodcastEpisode
|
||||||
if err := dbc.Where("id=?", id.Value).Find(&pe).Error; err == nil {
|
if err := dbc.Where("id=? AND status=?", id.Value, db.PodcastEpisodeStatusCompleted).Find(&pe).Error; err == nil {
|
||||||
pe.AbsP = filepath.Join(podcastsPath, pe.Path)
|
pe.AbsP = filepath.Join(podcastsPath, pe.Path)
|
||||||
return &pe, err
|
return &pe, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user