v1.0.5 confirm tags exist when scanning for tags
This commit is contained in:
26
main.go
26
main.go
@@ -71,7 +71,10 @@ func getDir() (string, error) {
|
||||
if len(os.Args) > 1 {
|
||||
return os.Args[1], nil
|
||||
} else {
|
||||
dataArg := os.Getenv("SLSKD_SCRIPT_DATA")
|
||||
dataArg, found := os.LookupEnv("SLSKD_SCRIPT_DATA")
|
||||
if !found {
|
||||
return "", errors.New("missing any reference to a path")
|
||||
}
|
||||
var data DownloadDirectoryComplete
|
||||
if err := json.Unmarshal([]byte(dataArg), &data); err != nil {
|
||||
return "", err
|
||||
@@ -155,6 +158,7 @@ func getTagsInDir(directory string) (tag.Metadata, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
missingTags := false
|
||||
for _, file := range files {
|
||||
fname := path.Join(directory, file.Name())
|
||||
|
||||
@@ -173,12 +177,30 @@ func getTagsInDir(directory string) (tag.Metadata, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
// if we found tags but they're incomplete, switch the flag
|
||||
if !checkTags(tags) {
|
||||
missingTags = true
|
||||
continue
|
||||
}
|
||||
|
||||
// found tag data
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
// no tag data in any file
|
||||
return nil, errors.New("missing tag data")
|
||||
if missingTags {
|
||||
return nil, errors.New("files have incomplete tag data")
|
||||
} else {
|
||||
return nil, errors.New("unable to read tag data")
|
||||
}
|
||||
}
|
||||
|
||||
func checkTags(tags tag.Metadata) bool {
|
||||
// most important tags
|
||||
if tags.Album() == "" || tags.AlbumArtist() == "" || tags.Artist() == "" || tags.Title() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func doMoveNotags(directory string) error {
|
||||
|
||||
Reference in New Issue
Block a user