Exemplo n.º 1
0
func OpenUrl(url string) (tag Tag) {
	response, _ := http.Get(url)
	ReadSeekerStream := httprs.NewHttpReadSeeker(response)
	if v2Tag := v2.ParseTag(ReadSeekerStream); v2Tag != nil {
		return Tag{
			title:  v2Tag.Title(),
			album:  v2Tag.Album(),
			artist: v2Tag.Artist(),
			year:   v2Tag.Year(),
			genre:  v2Tag.Genre()}
	} else if v1Tag := v1.ParseTag(ReadSeekerStream); v1Tag != nil {
		return Tag{
			title:  v1Tag.Title(),
			album:  v1Tag.Album(),
			artist: v1Tag.Artist(),
			year:   v1Tag.Year(),
			genre:  v1Tag.Genre()}
	}
	return Tag{
		title:  "Unknown",
		album:  "Unknown",
		artist: "Unknown",
		year:   "Unknown",
		genre:  "Unknown"}
}
Exemplo n.º 2
0
// Opens a new tagged file
func Open(name string) (*File, error) {
	fi, err := os.OpenFile(name, os.O_RDWR, 0666)
	if err != nil {
		return nil, err
	}

	file := &File{file: fi}

	if v2Tag := v2.ParseTag(fi); v2Tag != nil {
		file.Tagger = v2Tag
		file.originalSize = v2Tag.Size()
	} else if v1Tag := v1.ParseTag(fi); v1Tag != nil {
		file.Tagger = v1Tag
	} else {
		// Add a new tag if none exists
		file.Tagger = v2.NewTag(LatestVersion)
	}

	return file, nil
}