Пример #1
0
// GetMusicFiles returns flac or mp3 files of the album.
func (a *Album) GetMusicFiles() (contents []string, err error) {
	fileList, err := directory.GetFiles(a.NewPath)
	if err != nil {
		return []string{}, err
	}
	// check for music files
	for _, file := range fileList {
		switch filepath.Ext(file) {
		case ".flac", ".mp3":
			// accepted extensions
			contents = append(contents, filepath.Join(a.NewPath, file))
		}
	}
	sort.Strings(contents)
	return
}
Пример #2
0
// HasNonFlacFiles returns true if an album contains files other than flac songs and cover pictures.
func (a *Album) HasNonFlacFiles() (bool, error) {
	fileList, err := directory.GetFiles(a.Path)
	if err != nil {
		return false, err
	}
	// check for suspicious files
	hasNonFlac := false
	for _, file := range fileList {
		switch filepath.Ext(file) {
		case ".flac", ".jpg", ".jpeg", ".png":
			// accepted extensions
		case ".mp3", ".wma", ".m4a":
			hasNonFlac = true
			break
		default:
			fmt.Println("Found suspicious file ", file, " in ", a.Path)
			hasNonFlac = true
			break
		}
	}
	return hasNonFlac, err
}