Documentation
¶
Index ¶
- Constants
- Variables
- func ReadImage(path string) ([]byte, error)
- func ReadImageOptions(path string, index int) ([]byte, error)
- func ReadTags(path string) (map[string][]string, error)
- func WriteImage(path string, image []byte) error
- func WriteImageOptions(path string, image []byte, index int, imageType, description, mimeType string) error
- func WriteTags(path string, tags map[string][]string, opts WriteOption) error
- type ImageDesc
- type Properties
- type WriteOption
Constants ¶
const ( AcoustIDFingerprint = "ACOUSTID_FINGERPRINT" AcoustIDID = "ACOUSTID_ID" Album = "ALBUM" AlbumArtist = "ALBUMARTIST" AlbumArtistSort = "ALBUMARTISTSORT" AlbumSort = "ALBUMSORT" Arranger = "ARRANGER" Artist = "ARTIST" Artists = "ARTISTS" ArtistSort = "ARTISTSORT" ArtistWebpage = "ARTISTWEBPAGE" ASIN = "ASIN" AudioSourceWebpage = "AUDIOSOURCEWEBPAGE" Barcode = "BARCODE" BPM = "BPM" CatalogNumber = "CATALOGNUMBER" Comment = "COMMENT" Compilation = "COMPILATION" Composer = "COMPOSER" ComposerSort = "COMPOSERSORT" Conductor = "CONDUCTOR" Copyright = "COPYRIGHT" CopyrightURL = "COPYRIGHTURL" Date = "DATE" DiscNumber = "DISCNUMBER" DiscSubtitle = "DISCSUBTITLE" DJMixer = "DJMIXER" EncodedBy = "ENCODEDBY" Encoding = "ENCODING" EncodingTime = "ENCODINGTIME" Engineer = "ENGINEER" FileType = "FILETYPE" FileWebpage = "FILEWEBPAGE" GaplessPlayback = "GAPLESSPLAYBACK" Genre = "GENRE" Grouping = "GROUPING" InitialKey = "INITIALKEY" InvolvedPeople = "INVOLVEDPEOPLE" ISRC = "ISRC" Label = "LABEL" Language = "LANGUAGE" Length = "LENGTH" License = "LICENSE" Lyricist = "LYRICIST" Lyrics = "LYRICS" Media = "MEDIA" Mixer = "MIXER" Mood = "MOOD" MovementCount = "MOVEMENTCOUNT" MovementName = "MOVEMENTNAME" MovementNumber = "MOVEMENTNUMBER" MusicBrainzAlbumID = "MUSICBRAINZ_ALBUMID" MusicBrainzAlbumArtistID = "MUSICBRAINZ_ALBUMARTISTID" MusicBrainzArtistID = "MUSICBRAINZ_ARTISTID" MusicBrainzReleaseGroupID = "MUSICBRAINZ_RELEASEGROUPID" MusicBrainzReleaseTrackID = "MUSICBRAINZ_RELEASETRACKID" MusicBrainzTrackID = "MUSICBRAINZ_TRACKID" MusicBrainzWorkID = "MUSICBRAINZ_WORKID" MusicianCredits = "MUSICIANCREDITS" MusicIPPUID = "MUSICIP_PUID" OriginalAlbum = "ORIGINALALBUM" OriginalArtist = "ORIGINALARTIST" OriginalDate = "ORIGINALDATE" OriginalFilename = "ORIGINALFILENAME" OriginalLyricist = "ORIGINALLYRICIST" Owner = "OWNER" PaymentWebpage = "PAYMENTWEBPAGE" Performer = "PERFORMER" PlaylistDelay = "PLAYLISTDELAY" Podcast = "PODCAST" PodcastCategory = "PODCASTCATEGORY" PodcastDesc = "PODCASTDESC" PodcastID = "PODCASTID" PodcastURL = "PODCASTURL" ProducedNotice = "PRODUCEDNOTICE" Producer = "PRODUCER" PublisherWebpage = "PUBLISHERWEBPAGE" RadioStation = "RADIOSTATION" RadioStationOwner = "RADIOSTATIONOWNER" RadioStationWebpage = "RADIOSTATIONWEBPAGE" ReleaseCountry = "RELEASECOUNTRY" ReleaseDate = "RELEASEDATE" ReleaseStatus = "RELEASESTATUS" ReleaseType = "RELEASETYPE" Remixer = "REMIXER" Script = "SCRIPT" ShowSort = "SHOWSORT" ShowWorkMovement = "SHOWWORKMOVEMENT" Subtitle = "SUBTITLE" TaggingDate = "TAGGINGDATE" Title = "TITLE" TitleSort = "TITLESORT" TrackNumber = "TRACKNUMBER" TVEpisode = "TVEPISODE" TVEpisodeID = "TVEPISODEID" TVNetwork = "TVNETWORK" TVSeason = "TVSEASON" TVShow = "TVSHOW" URL = "URL" Work = "WORK" )
These constants define normalized tag keys used by TagLib's property mapping. When using ReadTags, the library will map format-specific metadata to these standardized keys. Similarly, WriteTags will map these keys back to the appropriate format-specific fields.
While these constants provide a consistent interface across different audio formats, you can also use custom tag keys if the underlying format supports arbitrary tags.
Variables ¶
var ErrInvalidFile = fmt.Errorf("invalid file")
var ErrSavingFile = fmt.Errorf("can't save file")
Functions ¶
func ReadImage ¶ added in v0.8.0
ReadImage reads the first embedded image from path. Returns empty byte slice if no images exist.
func ReadImageOptions ¶ added in v0.10.0
ReadImageOptions reads the embedded image at the specified index from path. Index 0 is the first image. Returns empty byte slice if index is out of range.
func WriteImage ¶ added in v0.8.0
WriteImage writes image as an embedded "Front Cover" at index 0 with auto-detected MIME type. Set image to nil to clear the image at that index.
func WriteImageOptions ¶ added in v0.10.0
func WriteImageOptions(path string, image []byte, index int, imageType, description, mimeType string) error
WriteImageOptions writes an image with custom metadata. Index specifies which image slot to write to (0 = first image). Set image to nil to clear the image at that index.
func WriteTags ¶
func WriteTags(path string, tags map[string][]string, opts WriteOption) error
WriteTags writes the metadata key-values pairs to path. The behavior can be controlled with WriteOption.
Types ¶
type ImageDesc ¶ added in v0.10.0
type ImageDesc struct {
// Type is the picture type (e.g., "Front Cover", "Back Cover")
Type string
// Description is a textual description of the image
Description string
// MIMEType is the MIME type of the image (e.g., "image/jpeg")
MIMEType string
}
ImageDesc contains metadata about an embedded image without the actual image data.
type Properties ¶
type Properties struct {
// Length is the duration of the audio
Length time.Duration
// Channels is the number of audio channels
Channels uint
// SampleRate in Hz
SampleRate uint
// Bitrate in kbit/s
Bitrate uint
// Images contains metadata about all embedded images
Images []ImageDesc
}
Properties contains the audio properties of a media file.
func ReadProperties ¶
func ReadProperties(path string) (Properties, error)
ReadProperties reads the audio properties from a file at the given path.
type WriteOption ¶ added in v0.6.0
type WriteOption uint8
WriteOption configures the behavior of write operations. The can be passed to WriteTags and combined with the bitwise OR operator.
const ( // Clear indicates that all existing tags not present in the new map should be removed. Clear WriteOption = 1 << iota )