Ejemplo n.º 1
0
// ReadFrom creates a Tchaik Library implementation from an iTunes Music Library passed through
// an io.Reader.
func ReadFrom(r io.Reader) (index.Library, error) {
	l, err := rawitl.ReadFromXML(r)
	if err != nil {
		return nil, err
	}
	return &itlLibrary{&l}, nil
}
Ejemplo n.º 2
0
func walkLibrary(path string) (<-chan string, error) {
	f, err := os.Open(itlXML)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	l, err := itl.ReadFromXML(f)
	if err != nil {
		return nil, err
	}

	paths := make(chan string)
	go func() {
		for _, t := range l.Tracks {
			loc, err := decodeLocation(t.Location)
			if err != nil {
				fmt.Println(err)
				break
			}
			paths <- loc
		}
		close(paths)
	}()
	return paths, nil
}