diff options
-rwxr-xr-x | rh-bin/showlist.json | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rh-bin/showlist.json b/rh-bin/showlist.json index ce59748..185a0a5 100755 --- a/rh-bin/showlist.json +++ b/rh-bin/showlist.json @@ -27,19 +27,34 @@ use JSON; my $status = 'ERROR'; my $errorstring = 'unknown'; my $responsecode = 500; +my @showlist; (my $ctx, $status, $errorstring) = RHRD::rddb::init(); if(defined $ctx) { - $status = 'ERROR'; - $errorstring = 'not yet implemented'; - $responsecode = 501; + my @shows = RHRD::rddb::list_shows($ctx); + if(!defined $shows[0] && defined $shows[1]) { + $responsecode = 500; + $status = $shows[1]; + $errorstring = $shows[2]; + } else { + for my $href (@shows) { + my %show; + $show{'id'} = $href->{'ID'}; + $show{'title'} = $href->{'ID'} . " | " . $href->{'TITLE'}; + push @showlist, %show; + } + $responsecode = 200; + $status = "OK"; + $errorstring = "success"; + } RHRD::rddb::destroy($ctx); } my %answer; $answer{'status'} = $status; $answer{'errorstring'} = $errorstring; +$answer{'shows'} = \@showlist; print "Content-type: application/json; charset=UTF-8\n"; print "Status: $responsecode\n\n"; |