summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-14 22:12:03 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-14 22:13:01 (GMT)
commit0505c209f2e6ccf869f28baf48375f05f7c117b4 (patch)
tree1a2655654f1f852bdea2fb5b31ea120396c3a6a8
parent4198d67490328138e0483b2359f86a9864adfbe9 (diff)
added support for multi-shows
-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);