id3v2

package module
v0.0.0-...-1323c2b Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 11 Imported by: 0

README

id3v2

go get github.com/rdeg/id3v2

Package id3v2 can be used to retrieve most of the ID3v2 tags of an MP3 file.

It currently offers the two functions ProcessAllTags and MakeFileName, as well as a Verbosity indicator that can be used to tune the level of verbosity of the package (and, hopefully, of the application that uses it too).

See https://godoc.org/github.com/rdeg/id3v2 documentation for details.

Motivation

I wrote this package (and the mp3copy utility) after the frustration that followed downloading my music library from Google Play Music on my PC. I found myself with over 5000 pieces of music in one folder, each song being named in a way that did not really fit me. Indeed, I tend to prefer full albums to playlists and I favor the usual classification of songs into artist / album / songs.

So if ProcessAllTags does the greatest job of harvesting ID3v2 tags from an MP3 file, MakeFileName is the tool that allows you to place each song in its 'ideal' tree. Of course, if what is ideal for me is not what you want, feel free to change the code accordingly ;-)

See the mp3copy example for more information.

Tags processing

The tags laying in the ID3v2 header of an MP3 file are processed in the ProcessAllTags function.

Many tags are taken into account but only a few one are actually processed. Namely, they are currently the APIC, PRIV and Txxx tags, but this may change in the future.

Tags of interest for later creation of a path and filename (ie, TALB, TIT2, TPE1, TPE2, TPOS, and TRCK) belong to this list. Please note that APIC tag processing only retrieves meta-information from the image that can be embedded in an MP3 file and not the actual bits of that image.

Bitrate

Bitrate determination is minimalistic and only relies on the information word of the first data frame of the file. It is thus not guaranteed to reflect the actual bitrate of a file, specially in case of variable bitrate.

Documentation

Overview

Package id3v2 can be used to retrieve most of the ID3v2 tags of an MP3 file.

It currently offers the two functions ProcessAllTags and MakeFileName, as well as a Verbosity indicator that can be used to tune the level of verbosity of the package (and, hopefully, of the application that uses it too).

Index

Constants

This section is empty.

Variables

View Source
var Verbose uint

The Verbose variable can be used to set the level of verbosity of the package. Possible values are 0 (no output), 1 (output discovered tags) and 2 (output ID3v2 headers information).

Functions

This section is empty.

Types

type MP3Info

type MP3Info struct {
	AllTags map[string]*ProcessedTag // the map of all processed tags
	BitRate int                      // bitrate (from the first sample)
}

Information for a MP3 file

func ProcessAllTags

func ProcessAllTags(fname string) (*MP3Info, error)

ProcessAllTags processes all the tags of an MP3 file and saves related information in an MP3Info structure returned to the caller.

func (*MP3Info) MakeFileName

func (mi *MP3Info) MakeFileName() string

MakeFileName makes an MP3 filename using the tags previously retrieved and saved in an MP3Info structure by ProcessAllTags. The resulting string should respect the following pattern:

artist/album/{disk-}track title.mp3

type ProcessedTag

type ProcessedTag struct {
	Name  string // understandable name
	Value string // tag value as a string
}

A processed tag, as stored in the map of all processed tags.

Directories

Path Synopsis
examples
mp3copy
This utility uses the id3v3 package to sort and organize an MP3 library in a tree that respects the following organization: <artist>/<album>/[<disk>-]<track> <title>.mp3
This utility uses the id3v3 package to sort and organize an MP3 library in a tree that respects the following organization: <artist>/<album>/[<disk>-]<track> <title>.mp3
mp3dup
This utility uses the id3v3 package to find duplicates in an MP3 library.
This utility uses the id3v3 package to find duplicates in an MP3 library.

Jump to

Keyboard shortcuts

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