Updated poller.pl validation checking

This commit is contained in:
2025-09-26 11:44:20 +00:00
parent 35afe1c492
commit 61c4e1ee4e

View File

@@ -153,9 +153,30 @@ sub validate {
my @warnings;
if ($type eq 'artist') {
# make sure there are albums
unless (exists $json->{albums} and scalar @{$json->{albums}}) {
unless (exists $json->{Albums} and scalar @{$json->{Albums}}) {
push(@warnings, 'no albums');
}
}
return @warnings;
else {
# detect Unknown Artist problem
unless (exists $json->{artists} and scalar @{$json->{artists}} and
exists $json->{artists}[0]{artistname} and
$json->{artists}[0]{artistname} !~ m%^Unknown Artist \(%) {
push(@warnings, 'no artist');
}
unless (exists $json->{Releases} and scalar @{$json->{Releases}}) {
push(@warnings, 'no releases');
}
else {
unless (exists $json->{Releases}[0]{Tracks} and
scalar @{$json->{Releases}[0]{Tracks}}) {
push(@warnings, 'no tracks');
}
}
}
if (@warnings) {
warn 'WARNING: ' . join(', ', @warnings) . "\n";
return 0;
}
return 1;
}