audiotags

package module
v0.0.0-...-4bba61f Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: LGPL-2.1 Imports: 4 Imported by: 0

README

audiotags

library and command to retrieve audio metadata tags (uses TagLib)

  • uses libtag directly (doesn't use the C bindings)
  • read and write support
  • returns the extended metadata (albumartist, composer, discnumber, etc...)
  • builds with cgo

Install command and library

go get github.com/nbonaparte/audiotags/audiotags

Install library

go get github.com/nbonaparte/audiotags

Command example

# audiotags '/store/music/John Holloway/J.S. Bach_ The Sonatas and Partitas for violin solo/2-09 Allegro assai [Sonata No. 3 in C major BWV 1005].mp3'
album J.S. Bach: The Sonatas and Partitas for violin solo
date 2007
filetype MPG/3
title Allegro assai [Sonata No. 3 in C major BWV 1005]
tracknumber 9
albumartist John Holloway
artist John Holloway
composer Johann Sebastian Bach
discnumber 2/2
genre Classical
length 320
bitrate 222
samplerate 44100
channels 2

Library example

package main

import (
	"fmt"
	"github.com/nbonaparte/audiotags"
	"log"
	"os"
)

func main() {

	if len(os.Args) != 2 {
		fmt.Println("pass path to file")
		return
	}

	props, audioProps, err := audiotags.Read(os.Args[1])

	if err != nil {
		log.Fatal(err)
	}

	for k, v := range props {
		fmt.Printf("%s %s\n", k, v)
	}

	fmt.Printf("length %d\nbitrate %d\nsamplerate %d\nchannels %d\n",
		audioProps.Length, audioProps.Bitrate, audioProps.Samplerate, audioProps.Channels)

}

Dependencies

On Debian/Ubuntu:

apt-get install libtag1-vanilla

On OS X:

brew install taglib

Documentation

Index

Constants

View Source
const (
	JPEG = iota
	PNG  = iota
)

Variables

This section is empty.

Functions

func ReadTags

func ReadTags(filename string) (map[string]string, error)

Types

type AudioProperties

type AudioProperties struct {
	Length, LengthMs, Bitrate, Samplerate, Channels int
}

func Read

func Read(filename string) (map[string]string, *AudioProperties, error)

func ReadAudioProperties

func ReadAudioProperties(filename string) (*AudioProperties, error)

func ReadFromData

func ReadFromData(data []byte) (map[string]string, *AudioProperties, error)

func ReadFromDataWithName

func ReadFromDataWithName(filename string, data []byte) (map[string]string, *AudioProperties, error)

type File

type File C.TagLib_FileRefRef

func FromData

func FromData(data []byte) (*File, error)

func FromDataWithName

func FromDataWithName(filename string, data []byte) (*File, error)

func Open

func Open(filename string) (*File, error)

func (*File) Close

func (f *File) Close()

func (*File) ReadAudioProperties

func (f *File) ReadAudioProperties() *AudioProperties

func (*File) ReadTags

func (f *File) ReadTags() map[string]string

func (*File) RemovePictures

func (f *File) RemovePictures() bool

func (*File) WritePicture

func (f *File) WritePicture(data []byte, fmt, w, h int) bool

func (*File) WriteTag

func (f *File) WriteTag(tag, value string) bool

func (*File) WriteTags

func (f *File) WriteTags(tag_map map[string]string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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