ncm

package
v0.0.0-...-1d9f23a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ncm reads ncm file into memory, and cut it into different parts.

Index

Constants

View Source
const (
	// MagicHeader1 is used to check whether the file is ncm format file.
	MagicHeader1 = 0x4e455443
	MagicHeader2 = 0x4d414446
)

Variables

View Source
var ErrExtNcm = errors.New("file should have ext .ncm")

ErrExtNcm represents the file has not ext .ncm

View Source
var ErrLength = errors.New("Length of Integer must be 1,2,4 or 8")
View Source
var ErrMagicHeader = errors.New("magic header does not match")

ErrMagicHeader represents the file's header doesn't match required header

View Source
var ErrNcmFormat = errors.New("file is not NCM format")

ErrNcmFormat represents the file is not a ncm file

Functions

This section is empty.

Types

type Data

type Data struct {
	Length uint64
	Detail []byte
}

type NcmFile

type NcmFile struct {
	Path     string
	FileDir  string
	FileName string

	Ext string

	Key   Data
	Meta  Data
	Cover Data
	Music Data
	// contains filtered or unexported fields
}

NcmFile represents a ncm file on the computer

func NewNcmFile

func NewNcmFile(ncmpath string) (nf *NcmFile, err error)

NewNcmFile create a pointer to ncmfile ncmpath point out where the ncm file is.

func (*NcmFile) CheckHeader

func (nf *NcmFile) CheckHeader() error

CheckHeader check whether file's first 4 bytes equal to MagicHeader1 and the following 4 bytes equal to MagicHeader2.

func (*NcmFile) Close

func (nf *NcmFile) Close() error

Close closes fd.

func (*NcmFile) GetCover

func (nf *NcmFile) GetCover() (err error)

GetCover gets the cover of music.

func (*NcmFile) GetFDStat

func (nf *NcmFile) GetFDStat() (os.FileInfo, error)

func (*NcmFile) GetKey

func (nf *NcmFile) GetKey() (err error)

GetKey gets key used parse the music data.

func (*NcmFile) GetMeta

func (nf *NcmFile) GetMeta() (err error)

GetMeta gets meta data describing the music.

func (*NcmFile) GetMusicData

func (nf *NcmFile) GetMusicData() error

GetMusicData gets the decoded music data.

func (*NcmFile) Parse

func (nf *NcmFile) Parse() error

Parse is a combination of Validate,GetKey,GetMeta,GetCover and GetMusicData cause these methods have to be called in order except Validata.

func (*NcmFile) Validate

func (nf *NcmFile) Validate() error

Validate check the whether the file is ncm file by ext and header.

Jump to

Keyboard shortcuts

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