freedb

package module
v0.0.0-...-3ddeb38 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

README

Parse a freedb.org database dump.

Go Report Card

Documentation

Overview

Package freedb can parse freedb.org dumps and insert into PostgreSQL.

Index

Constants

This section is empty.

Variables

View Source
var Shards = []string{
	"blues",
	"classical",
	"country",
	"data",
	"folk",
	"jazz",
	"misc",
	"newage",
	"reggae",
	"rock",
	"soundtrack",
}

These shard names are meaningless and vestigal, but are needed to disambiguate the freedb.org DISCID

Functions

func ComposeUID

func ComposeUID(discID []uint8, shard uint8) []uint8

ComposeUID concatenates the non-unique DISCID with the unique shard number to create an actually unique ID.

func ShardPos

func ShardPos(name string) (uint8, error)

ShardPos returns the shard position of a named shard as well as a ShardErr if the named shard does not exist.

Types

type Disc

type Disc struct {
	// IDs is a list of non-unique algorithmically-generated hashes identifying
	// a compact disc stored in hexadecimal.
	IDs [][]uint8

	// Shard is an 8 bit unsigned int that represents the position of the shard
	// in the Shards slice. These shards look like genre subdirectories, but
	// that meaning is vestigal. The subdirectories are used as generic shard
	// buckets to work around ID collisions.
	Shard uint8

	// Title is the combined artist name and release name of a compact disc.
	Title string

	// Genre is an optional field that represents the genre of music found
	// on a compact disc.
	Genre *string

	// Year is an optional field denoting the release year of a compact disc.
	Year *uint16

	// Offsets are the positions on a CD where tracks begin.
	Offsets []uint32

	// Duration of the compact disc, in seconds.
	Duration uint16

	// Tracks is a slice of strings representing the track titles on a compact
	// disc.
	Tracks []string
}

Disc represents the parsed output of a freeDB dump

func ParseDump

func ParseDump(dump io.Reader, shard uint8) (*Disc, error)

ParseDump reads a freedb dump file, parses it, converts strings to UTF8, and returns the parsed data into a *freedb.Disc.

func (*Disc) AppendTitle

func (d *Disc) AppendTitle(s string)

AppendTitle appends to the string that represents the compact disc title, ensuring that the string is valid UTF8.

func (*Disc) AppendTrack

func (d *Disc) AppendTrack(s string, pos int) error

AppendTrack appends to the track title in the given slice position, ensuring that the string is valid UTF8.

type ShardErr

type ShardErr struct {
	// contains filtered or unexported fields
}

ShardErr is the response to an unknown shard name.

func (*ShardErr) Error

func (e *ShardErr) Error() string

Error provides an error string for the ShardErr type.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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