Updated poller.pl validation checking
This commit is contained in:
25
poller.pl
25
poller.pl
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user