From 61c4e1ee4e9b843daa30dcbb62cfc1e8612c7a5f Mon Sep 17 00:00:00 2001 From: Jamie Miller Date: Fri, 26 Sep 2025 11:44:20 +0000 Subject: [PATCH] Updated poller.pl validation checking --- poller.pl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/poller.pl b/poller.pl index a6e30cd..9fe907d 100644 --- a/poller.pl +++ b/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; } \ No newline at end of file