Add album/track releases with audio analysis, AnalyzeAlbumRelease RPC, Docker path auto-resolution, release parsing decision tree
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package audio
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type TrackInfo struct {
|
||||
Format string
|
||||
BitDepth int
|
||||
SampleRate int
|
||||
Channels int
|
||||
DurationMs int
|
||||
BitrateKbps int
|
||||
IsLossless bool
|
||||
}
|
||||
|
||||
func Analyze(filePath string) (*TrackInfo, error) {
|
||||
ext := strings.ToLower(filepath.Ext(filePath))
|
||||
|
||||
switch ext {
|
||||
case ".flac":
|
||||
return analyzeFLAC(filePath)
|
||||
case ".mp3":
|
||||
return analyzeMP3(filePath)
|
||||
case ".aac", ".m4a", ".ogg", ".wav", ".ape", ".wv", ".alac":
|
||||
return &TrackInfo{
|
||||
Format: strings.ToUpper(strings.TrimPrefix(ext, ".")),
|
||||
IsLossless: ext == ".wav" || ext == ".ape" || ext == ".wv" || ext == ".alac",
|
||||
}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported audio format: %s", ext)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user