summaryrefslogtreecommitdiff
path: root/rh-bin/showlist.json
diff options
context:
space:
mode:
Diffstat (limited to 'rh-bin/showlist.json')
-rwxr-xr-xrh-bin/showlist.json52
1 files changed, 43 insertions, 9 deletions
diff --git a/rh-bin/showlist.json b/rh-bin/showlist.json
index cbf3da3..6839842 100755
--- a/rh-bin/showlist.json
+++ b/rh-bin/showlist.json
@@ -28,6 +28,7 @@ my $status = 'ERROR';
my $errorstring = 'unknown';
my $responsecode = 500;
my @showlist;
+my @mshowlist;
(my $ctx, $status, $errorstring) = RHRD::rddb::init();
if(defined $ctx) {
@@ -38,16 +39,48 @@ if(defined $ctx) {
$status = $shows[1];
$errorstring = $shows[2];
} else {
- my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @shows;
- for my $href (@sorted) {
- my %show;
- $show{'id'} = int($href->{'ID'});
- $show{'title'} = $href->{'TITLE'};
- push @showlist, \%show;
+ my @mshows = RHRD::rddb::list_multi_shows($ctx);
+ if(!defined $mshows[0] && defined $mshows[1]) {
+ $responsecode = 500;
+ $status = $mshows[1];
+ $errorstring = $mshows[2];
+ } else {
+
+ my %multirefs;
+
+ my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @mshows;
+ for my $href (@sorted) {
+ my %mshow;
+ $mshow{'id'} = int($href->{'ID'});
+ $mshow{'title'} = $href->{'TITLE'};
+ $mshow{'weeks'} = $href->{'SHOWS'};
+
+ my %parts = %{$href->{'SHOWS'}};
+ foreach my $week (keys %parts) {
+ my %ref;
+ $ref{'week'} = int($week);
+ $ref{'id'} = $mshow{'id'};
+ $multirefs{$parts{$week}} = \%ref;
+ }
+ push @mshowlist, \%mshow;
+ }
+
+ @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @shows;
+ for my $href (@sorted) {
+ my %show;
+ $show{'id'} = int($href->{'ID'});
+ $show{'title'} = $href->{'TITLE'};
+ if(exists($multirefs{$href->{'ID'}})) {
+ $show{'multi'} = $multirefs{$href->{'ID'}};
+ }
+
+ push @showlist, \%show;
+ }
+
+ $responsecode = 200;
+ $status = "OK";
+ $errorstring = "success";
}
- $responsecode = 200;
- $status = "OK";
- $errorstring = "success";
}
RHRD::rddb::destroy($ctx);
}
@@ -56,6 +89,7 @@ my %answer;
$answer{'status'} = $status;
$answer{'errorstring'} = $errorstring;
$answer{'shows'} = \@showlist;
+$answer{'multi-shows'} = \@mshowlist;
my $j = JSON::MaybeXS->new(utf8 => 0);