summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutils/rhrd-schedules64
1 files changed, 62 insertions, 2 deletions
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index ef6b680..6e60509 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -31,7 +31,8 @@ use String::MkPasswd qw(mkpasswd);
sub print_usage
{
- print STDERR "Usage: rhrd-schedules generate YYYY-MM-DD\n";
+ print STDERR "Usage: rhrd-schedules generate YYYY-MM-DD\n" .
+ " rhrd-schedules show (W1|W2|W3|W4|ALL) (MO|TU|WE|TH|FR|SA|SU|ALL)\n";
}
sub generate
@@ -48,10 +49,62 @@ sub generate
my $start = ${$entry}{'start'};
my $title = ${$entry}{'title'};
my $showid = ${$entry}{'id'};
-
print "$start: ($showid) $title\n";
}
+ # TODO: create day log in rddb
+ return 0;
+}
+
+sub show__day
+{
+ my ($ctx, $year, $month, $day) = @_;
+
+ my ($ret, $data) = RHRD::utils::fetch_parse_json("https://pv.helsinki.at/export/day_schedule/$year/$month/$day", "rhrd-schedules");
+ if(!$ret) {
+ print STDERR "Error fetching export from PV: $data\n";
+ return 1;
+ }
+
+ my $errcnt = 0;
+ for my $entry (@{$data}) {
+ my $start = ${$entry}{'start'};
+ my $title = ${$entry}{'title'};
+ my $showid = ${$entry}{'id'};
+
+ print " $start: ($showid) -> ";
+ if($showid > 0) {
+ my ($rdtitle, $rdlog, $status, $errorstring) = RHRD::rddb::get_show_title_and_log($ctx, $showid);
+ if(!defined $rdtitle || !defined $rdlog) {
+ print "$status: $errorstring\n";
+ $errcnt++;
+ } elsif ($title ne $rdtitle) {
+ print "WARNING: title mismatch (PV: '$title' != RD: '$rdtitle')\n";
+ $errcnt++;
+ } else {
+ # TODO: check DayOfWeek!!!
+ print "OK: $title\n";
+ }
+ } else {
+ print "ERROR: show not configured\n";
+ $errcnt++;
+ }
+ }
+
+ return $errcnt;
+}
+sub show
+{
+ my ($ctx, $week, $dow) = @_;
+
+ # TODO: parse week number and day
+ my $year = 2016;
+ my $month = 4;
+ my $day = 14;
+
+ print "$day.$month.$year:\n"; # TODO: print dow
+ my $errcnt = show__day($ctx, $year, $month, $day);
+ print " -> $errcnt errors.\n\n";
return 0;
}
@@ -75,6 +128,13 @@ if(defined $ctx) {
print_usage();
$ret = 1;
}
+ } elsif($cmd eq "show") {
+ if($num_args != 3) {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = show($ctx, $ARGV[1], $ARGV[2]);
+ }
} else {
print_usage();
$ret = 1;