feat: import library from media root and stream tracks
Add a filesystem scanner that ingests supported audio files from MEDIA_ROOT into SQLite using embedded tags with filename fallbacks. Wire startup scanning, manual rescan, and authenticated audio streaming into the backend, then connect the web player to the real stream endpoint.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/benya/temporserv/internal/config"
|
||||
"github.com/benya/temporserv/internal/db"
|
||||
"github.com/benya/temporserv/internal/httpapi"
|
||||
"github.com/benya/temporserv/internal/scanner"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -32,7 +33,16 @@ func main() {
|
||||
log.Fatalf("database seed failed: %v", err)
|
||||
}
|
||||
|
||||
handler := httpapi.NewRouter(cfg, database)
|
||||
scanService := scanner.NewService(database, cfg.MediaRoot)
|
||||
if scanService.HasMediaFiles() {
|
||||
if result, err := scanService.Scan(ctx); err != nil {
|
||||
log.Printf("startup scan failed: %v", err)
|
||||
} else {
|
||||
log.Printf("startup scan completed: artists=%d albums=%d tracks=%d", result.Artists, result.Albums, result.Tracks)
|
||||
}
|
||||
}
|
||||
|
||||
handler := httpapi.NewRouter(cfg, database, scanService)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: cfg.Address(),
|
||||
|
||||
Reference in New Issue
Block a user