當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tag.Metadata類代碼示例

本文整理匯總了Golang中github.com/dhowden/tag.Metadata的典型用法代碼示例。如果您正苦於以下問題:Golang Metadata類的具體用法?Golang Metadata怎麽用?Golang Metadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Metadata類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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
}
開發者ID:herotl2005,項目名稱:tag,代碼行數:28,代碼來源:mbz.go

示例2: 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)
}
開發者ID:herotl2005,項目名稱:tag,代碼行數:9,代碼來源:mbz.go

示例3: extractMP4Vorbis

// extractMP4Vorbis attempts to extract MusicBrainz Picard tags from m.Raw(), where m.Format
// is assumed to be MP4 or VORBIS.
func extractMP4Vorbis(m tag.Metadata) Info {
	i := Info{}
	for t, v := range m.Raw() {
		if s, ok := v.(string); ok {
			i.set(t, s)
		}
	}
	return i
}
開發者ID:herotl2005,項目名稱:tag,代碼行數:11,代碼來源:mbz.go

示例4: dataURL

func dataURL(m tag.Metadata) string {
	p := m.Picture()
	if p == nil {
		return ""
	}
	if p.MIMEType == "-->" {
		return string(p.Data)
	}
	return fmt.Sprintf("data:%s;base64,%s", p.MIMEType, base64.StdEncoding.EncodeToString(p.Data))
}
開發者ID:shazow,項目名稱:mog,代碼行數:10,代碼來源:codec.go

示例5: getNewFolderName

// Get the new folder name
func getNewFolderName(m tag.Metadata) (string, error) {
	artist := m.AlbumArtist()

	if artist == "" {
		artist = m.Artist()
	}

	year := strconv.Itoa(m.Year())
	album := m.Album()

	if len(artist) == 0 {
		return "", errors.New("Artist not found")
	}

	if year == "0" {
		return "", errors.New("Year not found")
	}

	if len(album) == 0 {
		return "", errors.New("Album not found")
	}

	folder := artist + " - " + year + " - " + album

	return folder, nil
}
開發者ID:aeyoll,項目名稱:music-folder-rename,代碼行數:27,代碼來源:music_folder_rename.go

示例6: Open

// Open the given file and return an http.File which contains the artwork, and hence
// the Name() of the returned file will have an extention for the artwork, not the
// media file.
func (afs artworkFileSystem) Open(ctx context.Context, path string) (http.File, error) {
	f, err := afs.FileSystem.Open(ctx, path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	stat, err := f.Stat()
	if err != nil {
		return nil, err
	}

	var m tag.Metadata
	m, err = tag.ReadFrom(f)
	if err != nil {
		return nil, fmt.Errorf("error extracting picture from '%v': %v", path, err)
	}

	p := m.Picture()
	if p == nil {
		return nil, fmt.Errorf("no picture attached to '%v'", path)
	}

	name := stat.Name()
	if p.Ext != "" {
		name += "." + p.Ext
	}

	return &file{
		ReadSeeker: bytes.NewReader(p.Data),
		stat: &fileInfo{
			name:    name,
			size:    int64(len(p.Data)),
			modTime: stat.ModTime(),
		},
	}, nil
}
開發者ID:davelondon,項目名稱:tchaik,代碼行數:40,代碼來源:artwork.go

示例7: 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())
}
開發者ID:herotl2005,項目名稱:tag,代碼行數:20,代碼來源:tag.go


注:本文中的github.com/dhowden/tag.Metadata類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。