Squash merge audio-player-component into main

This commit is contained in:
2026-02-13 20:39:23 -06:00
parent 9b7cfd5bd1
commit d78c0584e2
122 changed files with 11750 additions and 1175 deletions
+42
View File
@@ -0,0 +1,42 @@
package library
import (
"fmt"
"net/http"
"path/filepath"
"yellowjacket/backend/system"
)
// CoverArtHandler serves cover art images via HTTP.
type CoverArtHandler struct {
coversDir string
}
// NewCoverArtHandler creates a handler that serves cover art from the user data directory.
func NewCoverArtHandler() (*CoverArtHandler, error) {
dataDir, err := system.GetUserDataDirPath()
if err != nil {
return nil, fmt.Errorf("could not get user data directory: %w", err)
}
return &CoverArtHandler{
coversDir: filepath.Join(dataDir, "covers"),
}, nil
}
// ServeHTTP handles requests for cover art images.
func (h *CoverArtHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Extract filename from path like "/covers/abc123.jpg"
filename := filepath.Base(r.URL.Path)
// Prevent directory traversal
if filename == "." || filename == ".." {
http.NotFound(w, r)
return
}
filePath := filepath.Join(h.coversDir, filename)
http.ServeFile(w, r, filePath)
}