audiometa

package module
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2024 License: BSD-3-Clause Imports: 21 Imported by: 0

README

audiometa

MP3/MP4/FLAC/OGG tag reader and writer for go

Go Reference

This package allows you to parse and write ID tags for mp3, mp4 (m4a, m4b, m4p), FLAC, and ogg (Vorbis, OPUS) files.

This is the only package available in Go that uses native Go to allow writing of ogg vorbis metadata. As an added bonus I've added support for ogg OPUS as well.

Simply use the OpenTag() function with a string file path as the argument and the library will return the IDTag.

You can access all of the fields of the IDTag through the accessor functions.

Fields that can be parsed:

MP3: Artist, AlbumArtist, Album, AlbumArt, Comments, Composer, Genre, Title, Year, BPM, ContentType, CopyrightMessage, Date, EncodedBy, Lyricist, FileType, Language, Length, PartOfSet, and Publisher

MP4: Artist, AlbumArtist, Album, AlbumArt, Comments, Composer, Genre, Title, Year, EncodedBy, and CopyrightMessage

FLAC: Artist, Album, AlbumArt, Date, Genre Title

OGG: Artist, AlbumArtist, Album, AlbumArt, Comment, Date, Genre, Title, Copyright, Publisher, Composer, and has extended support for all other custom or unmapped fields

Fields that can be written:

MP3: Artist, AlbumArtist, Album, AlbumArt, Comments, Composer, Genre, Title, Year, BPM, ContentType, CopyrightMessage, Date, EncodedBy, Lyricist, FileType, Language, Length, PartOfSet, and Publisher

MP4: Artist, AlbumArtist, Album, AlbumArt, Comments, Composer, Genre, Title, Year, and CopyrightMessage

FLAC: Artist, Album, AlbumArt, Genre, Title

OGG: Artist, AlbumArtist, Album, AlbumArt, Comment, Date, Genre, Title, Copyright, Publisher, Composer, and has extended support to allow for passthrough of unknown fields and adding any custom or unmapped field

Documentation

Overview

Package audiometa is an all in one solution for reading and writing audio meta data in Go. It's the only Go module available that can read and write OGG Vorbis and OGG Opus metadata. auidometa supports several different filetypes and a wide range of tags.

Index

Constants

View Source
const (
	// Continuation of packet
	COP byte = 1 << iota
	// Beginning of stream
	BOS = 1 << iota
	// End of stream
	EOS = 1 << iota
)
View Source
const (
	MP3  string = "mp3"
	M4P  string = "m4p"
	M4A  string = "m4a"
	M4B  string = "m4b"
	MP4  string = "mp4"
	FLAC string = "flac"
	OGG  string = "ogg"
)
View Source
const (
	ALBUM  string = "album"
	ARTIST string = "artist"
	DATE   string = "date"
	TITLE  string = "title"
	GENRE  string = "genre"
)
View Source
const MIMEType = "application/ogg"

The MIME type as defined in RFC 3534.

Variables

This section is empty.

Functions

func GetFileType

func GetFileType(filepath string) (string, error)

GetFileType returns the file type of the file pointed to by filepath. If the filetype is not supported, an error is returned.

func SaveTag

func SaveTag(tag *IDTag) error

SaveTag saves the corresponding IDTag to the audio file that it references and returns an error if the saving process fails

Types

type IDTag

type IDTag struct {
	PassThrough map[string]string
	// contains filtered or unexported fields
}

The IDTag represents all of the metadata that can be retrieved from a file. The IDTag contains all tags for all audio types. Some tags may not be applicable to all types. Only the valid types are written to the respective data files. Although a tag may be set, if the function to write that tag attribute doesn't exist, the tag attribute will be ignored and the save function will not produce an error.

func OpenTag

func OpenTag(filepath string) (*IDTag, error)

OpenTag Opens the ID tag for the corresponding file as long as it is a supported filetype Use the OpenTag command and you will be able to access all metadata associated with the file

func (*IDTag) AdditionalTags

func (tag *IDTag) AdditionalTags() map[string]string

AdditionalTags gets all additional (unmapped) tags

func (*IDTag) Album

func (tag *IDTag) Album() string

Album gets the album for a tag

func (*IDTag) AlbumArtist

func (tag *IDTag) AlbumArtist() string

AlbumArtist gets the album artist for a tag

func (*IDTag) Artist

func (tag *IDTag) Artist() string

Artist gets the artist for a tag

func (*IDTag) BPM

func (tag *IDTag) BPM() string

BPM gets the BPM for a tag as a string

func (*IDTag) ClearAllTags

func (tag *IDTag) ClearAllTags(preserveUnknown ...bool)

ClearAllTags clears all tags except the fileUrl tag which is used to reference the file, takes an optional parameter "preserveUnkown": when this is true passThroughMap is not cleared and unknown tags are preserved

func (*IDTag) Comments

func (tag *IDTag) Comments() string

Comments gets the comments for a tag

func (*IDTag) Composer

func (tag *IDTag) Composer() string

Composer gets the composer for a tag

func (*IDTag) CopyrightMsg

func (tag *IDTag) CopyrightMsg() string

CopyrightMs gets the Copyright Messgae for a tag

func (*IDTag) Date

func (tag *IDTag) Date() string

Date gets the date for a tag as a string

func (*IDTag) EncodedBy

func (tag *IDTag) EncodedBy() string

EncodedBy gets who encoded the tag

func (*IDTag) FileType

func (tag *IDTag) FileType() string

FileType gets the filetype of the tag

func (*IDTag) Genre

func (tag *IDTag) Genre() string

Genre gets the genre for a tag

func (*IDTag) Language

func (tag *IDTag) Language() string

Language gets the language of the tag

func (*IDTag) Length

func (tag *IDTag) Length() string

Length gets the length of the audio file

func (*IDTag) Lyricist

func (tag *IDTag) Lyricist() string

Lyricist gets the lyricist for the tag

func (*IDTag) PartOfSet

func (tag *IDTag) PartOfSet() string

PartOfSet gets if the track is part of a set

func (*IDTag) Publisher

func (tag *IDTag) Publisher() string

Publisher gets the publisher for the tag

func (*IDTag) Save

func (tag *IDTag) Save() error

Save saves the corresponding IDTag to the audio file that it references and returns an error if the saving process fails

func (*IDTag) SetAdditionalTag

func (tag *IDTag) SetAdditionalTag(id string, value string)

SetAdditionalTag sets an additional (unmapped) tag taking an id and value (id,value) (ogg only)

func (*IDTag) SetAlbum

func (tag *IDTag) SetAlbum(album string)

SetAlbum sets the album for a tag

func (*IDTag) SetAlbumArtFromByteArray

func (tag *IDTag) SetAlbumArtFromByteArray(albumArt []byte) error

SetAlbumArtFromByteArray sets the album art by passing a byte array for the album art

func (*IDTag) SetAlbumArtFromFilePath

func (tag *IDTag) SetAlbumArtFromFilePath(filePath string) error

SetAlbumArtFromFilePath sets the album art by passing a filepath as a string

func (*IDTag) SetAlbumArtFromImage

func (tag *IDTag) SetAlbumArtFromImage(albumArt *image.Image)

SetAlbumArtFromImage sets the album art by passing an *image.Image as the album art

func (*IDTag) SetAlbumArtist

func (tag *IDTag) SetAlbumArtist(albumArtist string)

SetAlbumArtist sets the album artist for a tag

func (*IDTag) SetArtist

func (tag *IDTag) SetArtist(artist string)

SetArtist sets the artist for a tag

func (*IDTag) SetBPM

func (tag *IDTag) SetBPM(bpm string)

SetBPM sets the BPM for a tag

func (*IDTag) SetComments

func (tag *IDTag) SetComments(comments string)

SetComments sets the comments for a tag

func (*IDTag) SetComposer

func (tag *IDTag) SetComposer(composer string)

SetComposer sets the composer for a tag

func (*IDTag) SetCopyrightMsg

func (tag *IDTag) SetCopyrightMsg(copyrightMsg string)

SetCopyrightMsg sets the Copyright Message for a tag

func (*IDTag) SetDate

func (tag *IDTag) SetDate(date string)

SetDate sets the date for a tag

func (*IDTag) SetEncodedBy

func (tag *IDTag) SetEncodedBy(encodedBy string)

SetEncodedBy sets who encoded the tag

func (*IDTag) SetFileType

func (tag *IDTag) SetFileType(fileType string)

SetFileType sets the filtype of the tag

func (*IDTag) SetGenre

func (tag *IDTag) SetGenre(genre string)

SetGenre sets the genre for a tag

func (*IDTag) SetLanguage

func (tag *IDTag) SetLanguage(language string)

SetLanguage sets the lanuguage of the tag

func (*IDTag) SetLength

func (tag *IDTag) SetLength(length string)

SetLength sets the length of the audio file

func (*IDTag) SetLyricist

func (tag *IDTag) SetLyricist(lyricist string)

SetLyricist sets the lyricist for the tag

func (*IDTag) SetPartOfSet

func (tag *IDTag) SetPartOfSet(partOfSet string)

SetPartOfSet sets if the track is part of a set

func (*IDTag) SetPublisher

func (tag *IDTag) SetPublisher(publisher string)

SetPublisher sets the publisher for the tag

func (*IDTag) SetTitle

func (tag *IDTag) SetTitle(title string)

SetTitle sets the title for a tag

func (*IDTag) SetYear

func (tag *IDTag) SetYear(year string)

SetYear sets the year for a tag

func (*IDTag) Title

func (tag *IDTag) Title() string

Title gets the title for a tag

func (*IDTag) Year

func (tag *IDTag) Year() string

Year gets the year for a tag as a string

type MP4Delete added in v1.3.0

type MP4Delete []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL