本文整理汇总了Golang中github.com/dhowden/tag.Metadata.Format方法的典型用法代码示例。如果您正苦于以下问题:Golang Metadata.Format方法的具体用法?Golang Metadata.Format怎么用?Golang Metadata.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dhowden/tag.Metadata
的用法示例。
在下文中一共展示了Metadata.Format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Extract
// Extract tags created by MusicBrainz Picard which can be used with with the MusicBrainz and LastFM APIs.
// See https://picard.musicbrainz.org/docs/mappings/ for more information.
func Extract(m tag.Metadata) Info {
switch m.Format() {
case tag.ID3v2_2, tag.ID3v2_3, tag.ID3v2_4:
return extractID3(m)
}
return extractMP4Vorbis(m)
}
示例2: extractID3
// extractID3 attempts to extract MusicBrainz Picard tags from m.Raw(), where m.Format
// is assumed to be a supported version of ID3.
func extractID3(m tag.Metadata) Info {
var txxx, ufid string
switch m.Format() {
case tag.ID3v2_2:
txxx, ufid = "TXX", "UFI"
case tag.ID3v2_3, tag.ID3v2_4:
txxx, ufid = "TXXX", "UFID"
}
i := Info{}
for k, v := range m.Raw() {
switch {
case strings.HasPrefix(k, txxx):
if str, ok := v.(*tag.Comm); ok {
i.set(str.Description, str.Text)
}
case strings.HasPrefix(k, ufid):
if id, ok := v.(*tag.UFID); ok {
if id.Provider == UFIDProviderURL {
i.set(Recording, string(id.Identifier))
}
}
}
}
return i
}
示例3: printMetadata
func printMetadata(m tag.Metadata) {
fmt.Printf("Metadata Format: %v\n", m.Format())
fmt.Printf("File Type: %v\n", m.FileType())
fmt.Printf(" Title: %v\n", m.Title())
fmt.Printf(" Album: %v\n", m.Album())
fmt.Printf(" Artist: %v\n", m.Artist())
fmt.Printf(" Composer: %v\n", m.Composer())
fmt.Printf(" Genre: %v\n", m.Genre())
fmt.Printf(" Year: %v\n", m.Year())
track, trackCount := m.Track()
fmt.Printf(" Track: %v of %v\n", track, trackCount)
disc, discCount := m.Disc()
fmt.Printf(" Disc: %v of %v\n", disc, discCount)
fmt.Printf(" Picture: %v\n", m.Picture())
fmt.Printf(" Lyrics: %v\n", m.Lyrics())
}