From cc7d0e4ae43b6ec892a51bf6b58f33209ca7805e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 23 Mar 2016 19:55:44 +0100 Subject: implemented show listing 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"; -- cgit v0.10.2