This commit is contained in:
sentriz
2024-03-11 19:10:43 +01:00
parent 6b8d6b7184
commit 6ce1fe5a7e
4 changed files with 10 additions and 0 deletions

View File

@@ -557,6 +557,10 @@ func (ir *InternetRadioStation) SID() *specid.ID {
return &specid.ID{Type: specid.InternetRadioStation, Value: ir.ID}
}
func (ir *InternetRadioStation) AbsPath() string {
return ir.StreamURL
}
type ArtistInfo struct {
ID int `gorm:"primary_key" sql:"type:int REFERENCES artists(id) ON DELETE CASCADE"`
CreatedAt time.Time

View File

@@ -109,6 +109,7 @@ func (a *ArtistInfoCache) Refresh() error {
if err := q.Find(&artist).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return fmt.Errorf("finding non cached artist: %w", err)
}
if artist.ID == 0 {
return nil
}

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 == "" {

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
}