Documentation
¶
Overview ¶
Package files contains client code for reading song files.
Index ¶
- Constants
- func IsMusicPath(p string) bool
- func MetadataOverridePath(cfg *client.Config, songFilename string) (string, error)
- func ReadSong(cfg *client.Config, p string, fi os.FileInfo, flags ReadSongFlag, ...) (*db.Song, error)
- func UpdateMetadataOverride(cfg *client.Config, updated *db.Song) error
- type GainsCache
- type MetadataOverride
- type ReadSongFlag
Constants ¶
const (
// NonAlbumTracksValue is used as the album name for standalone recordings by Picard.
NonAlbumTracksValue = "[non-album tracks]"
)
Variables ¶
This section is empty.
Functions ¶
func IsMusicPath ¶
IsMusicPath returns true if path p has an extension suggesting that it's a music file.
func MetadataOverridePath ¶
MetadataOverridePath returns the path under cfg.MetadataDir for a JSON-marshaled MetadataOverride struct used to override metadata for a song with the supplied Filename value.
func ReadSong ¶
func ReadSong(cfg *client.Config, p string, fi os.FileInfo, flags ReadSongFlag, gc *GainsCache) (*db.Song, error)
ReadSong reads the song file at p and creates a Song object. If fi is non-nil, it will be used; otherwise the file will be stat-ed by this function. gc is only used if cfg.ComputeGains is true and flags does not contain SkipAudioData.
Types ¶
type GainsCache ¶
type GainsCache struct {
// contains filtered or unexported fields
}
GainsCache is passed to ReadSong to compute gain adjustments for MP3 files.
Gain adjustments need to be computed across entire albums, so adjustments are cached so they won't need to be computed multiple times.
func NewGainsCache ¶
func NewGainsCache(cfg *client.Config, dumpPath string) (*GainsCache, error)
NewGainsCache returns a new GainsCache.
If dumpPath is non-empty, db.Song objects are JSON-unmarshaled from it to initialize the cache with previously-computed gain adjustments.
type MetadataOverride ¶
type MetadataOverride struct { Artist *string `json:"artist,omitempty"` Title *string `json:"title,omitempty"` Album *string `json:"album,omitempty"` AlbumArtist *string `json:"albumArtist,omitempty"` DiscSubtitle *string `json:"discSubtitle,omitempty"` AlbumID *string `json:"albumId,omitempty"` RecordingID *string `json:"recordingId,omitempty"` Track *int `json:"track,omitempty"` Disc *int `json:"disc,omitempty"` Date *time.Time `json:"date,omitempty"` }
MetadataOverride overrides metadata in a song file's tag.
TODO: Add a way to reference another SHA1, filename, or song ID for https://github.com/derat/nup/issues/32? There should probably be a way to override AlbumGain too in that case.
TODO: Add some way to prevent fields from being updated with bad/messy data in MusicBrainz? Maybe just a single Readonly bool field for the whole struct?
type ReadSongFlag ¶
type ReadSongFlag uint32
ReadSongFlag values can be masked together to configure ReadSong's behavior.
const ( // SkipAudioData indicates that audio data (used to compute the song's SHA1, // duration, and gain adjustments) will not be read. SkipAudioData ReadSongFlag = 1 << iota // OnlyFileMetadata indicates that the returned db.Song object should only include // metadata from the file's ID3 tag. cfg.ArtistRewrites and cfg.AlbumIDRewrites will // not be used and metadata override files will not be read. OnlyFileMetadata )