feat(subsonic): support embedded cover art

closes #11
closes #556
This commit is contained in:
sentriz
2025-09-29 18:24:37 +01:00
parent 2fcba12650
commit ec7cffdd57
6 changed files with 109 additions and 29 deletions

No files matched your search

+32 -27
View File
@@ -316,33 +316,34 @@ type Play struct {
}
type Album struct {
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
ModifiedAt time.Time
LeftPath string `gorm:"unique_index:idx_album_abs_path"`
RightPath string `gorm:"not null; unique_index:idx_album_abs_path" sql:"default: null"`
RightPathUDec string `sql:"default: null"`
Parent *Album
ParentID int `sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"`
Genres []*Genre `gorm:"many2many:album_genres"`
Cover string `sql:"default: null"`
Artists []*Artist `gorm:"many2many:album_artists"`
TagTitle string `sql:"default: null"`
TagAlbumArtist string // display purposes only
TagTitleUDec string `sql:"default: null"`
TagBrainzID string `sql:"default: null"`
TagYear int `sql:"default: null"`
TagCompilation bool `sql:"default: null"`
TagReleaseType string `sql:"default: null"`
Tracks []*Track
ChildCount int `sql:"-"`
Duration int `sql:"-"`
AlbumStar *AlbumStar
AlbumRating *AlbumRating
AverageRating float64 `sql:"default: null"`
Play *Play
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
ModifiedAt time.Time
LeftPath string `gorm:"unique_index:idx_album_abs_path"`
RightPath string `gorm:"not null; unique_index:idx_album_abs_path" sql:"default: null"`
RightPathUDec string `sql:"default: null"`
Parent *Album
ParentID int `sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"`
Genres []*Genre `gorm:"many2many:album_genres"`
Cover string `sql:"default: null"`
EmbeddedCoverTrackID *int `sql:"default: null; type:int REFERENCES tracks(id) ON DELETE SET NULL"`
Artists []*Artist `gorm:"many2many:album_artists"`
TagTitle string `sql:"default: null"`
TagAlbumArtist string // display purposes only
TagTitleUDec string `sql:"default: null"`
TagBrainzID string `sql:"default: null"`
TagYear int `sql:"default: null"`
TagCompilation bool `sql:"default: null"`
TagReleaseType string `sql:"default: null"`
Tracks []*Track
ChildCount int `sql:"-"`
Duration int `sql:"-"`
AlbumStar *AlbumStar
AlbumRating *AlbumRating
AverageRating float64 `sql:"default: null"`
Play *Play
}
func (a *Album) SID() *specid.ID {
@@ -353,6 +354,10 @@ func (a *Album) ParentSID() *specid.ID {
return &specid.ID{Type: specid.Album, Value: a.ParentID}
}
func (a *Album) EmbeddedCoverTrackSID() *specid.ID {
return &specid.ID{Type: specid.Track, Value: *a.EmbeddedCoverTrackID}
}
func (a *Album) IndexRightPath() string {
if len(a.RightPathUDec) > 0 {
return a.RightPathUDec
+5
View File
@@ -79,6 +79,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
construct(ctx, "202508261102", migrateAddLyrics),
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
}
return gormigrate.
@@ -857,3 +858,7 @@ func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error {
func migrateAddLyrics(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
func migrateAddAlbumEmbeddedCoverTrackID(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Album{}).Error
}