playlists now save to files, can be restored from files
This commit is contained in:
@@ -63,13 +63,20 @@ type queueClearer interface {
|
||||
Clear()
|
||||
}
|
||||
|
||||
// playlistRestorer is a narrow interface for restoring playlists
|
||||
// from M3U8 files after a library rescan.
|
||||
type playlistRestorer interface {
|
||||
RestoreAllPlaylists()
|
||||
}
|
||||
|
||||
// Library manages scanning and querying the music collection.
|
||||
type Library struct {
|
||||
ctx context.Context
|
||||
logger *slog.Logger
|
||||
conf *Config
|
||||
db *database.DB
|
||||
queue queueClearer
|
||||
ctx context.Context
|
||||
logger *slog.Logger
|
||||
conf *Config
|
||||
db *database.DB
|
||||
queue queueClearer
|
||||
playlistRestorer playlistRestorer
|
||||
}
|
||||
|
||||
// SetQueue provides the library with a reference to the queue so
|
||||
@@ -79,6 +86,13 @@ func (l *Library) SetQueue(q queueClearer) {
|
||||
l.queue = q
|
||||
}
|
||||
|
||||
// SetPlaylistRestorer provides the library with a reference to
|
||||
// the playlist service so that FullRescan can restore playlists
|
||||
// from M3U8 files after wiping data.
|
||||
func (l *Library) SetPlaylistRestorer(p playlistRestorer) {
|
||||
l.playlistRestorer = p
|
||||
}
|
||||
|
||||
// NewLibrary creates a new library with the given configuration.
|
||||
// A nil config is permitted; the library will be inert until a valid
|
||||
// configuration is supplied via the LibraryConfigChanged event.
|
||||
|
||||
@@ -68,6 +68,12 @@ func (l *Library) FullRescan() (*ScanMetrics, error) {
|
||||
clearDBDur + clearFilesDur
|
||||
}
|
||||
|
||||
// Restore playlists from M3U8 files now that the library
|
||||
// has been rescanned and audio_files are populated again.
|
||||
if l.playlistRestorer != nil {
|
||||
l.playlistRestorer.RestoreAllPlaylists()
|
||||
}
|
||||
|
||||
return metrics, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user