summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-04-15 19:42:05 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-04-15 19:42:05 (GMT)
commitd1016e1e09bf460ede1ac49e91650351b3aff4a4 (patch)
treed4b31cb6a98fc71532120599bae2bd60c3434a0c
parent5c4012722941048622b0b00054ef08d4bb128c7c (diff)
new export format of PV
-rw-r--r--debian/control2
-rwxr-xr-xutils/rhrd-schedules32
2 files changed, 19 insertions, 15 deletions
diff --git a/debian/control b/debian/control
index e6c6cf8..b185e24 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.9.6
Package: librhrd-perl
Architecture: all
-Depends: ${misc:Depends}, ${perl:Depends}, libconfig-inifiles-perl, libdbi-perl, libdbd-mysql-perl, libdatetime-perl, libdatetime-timezone-perl, libjson-any-perl, liburi-perl, libwww-perl
+Depends: ${misc:Depends}, ${perl:Depends}, libconfig-inifiles-perl, libdbi-perl, libdbd-mysql-perl, libdate-calc-perl, libdatetime-perl, libdatetime-timezone-perl, libjson-any-perl, liburi-perl, libwww-perl
Description: Radio Helsinki Rivendell Perl Modules
These modules are used by rhwebimport, rhimport as well by
some other scripts.
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index 6e60509..3579821 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -27,7 +27,7 @@ use lib "../lib/";
use RHRD::rddb;
use RHRD::utils;
-use String::MkPasswd qw(mkpasswd);
+use Date::Calc;
sub print_usage
{
@@ -57,19 +57,26 @@ sub generate
sub show__day
{
- my ($ctx, $year, $month, $day) = @_;
+ my ($ctx, @date) = @_;
- my ($ret, $data) = RHRD::utils::fetch_parse_json("https://pv.helsinki.at/export/day_schedule/$year/$month/$day", "rhrd-schedules");
+ print "https://pv.helsinki.at/export/day_schedule/$date[0]/$date[1]/$date[2]\n";
+
+ my ($ret, $data) = RHRD::utils::fetch_parse_json("https://pv.helsinki.at/export/day_schedule/$date[0]/$date[1]/$date[2]", "rhrd-schedules");
if(!$ret) {
print STDERR "Error fetching export from PV: $data\n";
return 1;
}
+ my $dow = Date::Calc::Day_of_Week(@date);
+
my $errcnt = 0;
for my $entry (@{$data}) {
my $start = ${$entry}{'start'};
my $title = ${$entry}{'title'};
- my $showid = ${$entry}{'id'};
+ my $pvid = ${$entry}{'id'};
+ my $showid = ${$entry}{'automation-id'};
+
+ next if $pvid == 1; # 'Unmoderiertes Musikprogramm'
print " $start: ($showid) -> ";
if($showid > 0) {
@@ -85,7 +92,7 @@ sub show__day
print "OK: $title\n";
}
} else {
- print "ERROR: show not configured\n";
+ print "ERROR: show '$pvid|$title' not configured\n";
$errcnt++;
}
}
@@ -98,12 +105,12 @@ 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);
+ my @date = (2016, 4, 14);
+
+# print "$date[0].$date[1].$date[2] (" . Date::Calc::Day_of_Week_to_Text() . "):\n";
+ print Date::Calc::Date_to_Text(@date) . ":\n";
+ my $errcnt = show__day($ctx, @date);
print " -> $errcnt errors.\n\n";
return 0;
}
@@ -120,10 +127,7 @@ my ($ctx, undef, $errorstring) = RHRD::rddb::init();
if(defined $ctx) {
if($cmd eq "generate") {
if($num_args == 2 && $ARGV[1] =~ m/^(\d{4})-(\d{2})-(\d{2})$/) {
- my $year = $1;
- my $month = $2;
- my $day = $3;
- $ret = generate($ctx, $year, $month, $day);
+ $ret = generate($ctx, $1, $2, $3);
} else {
print_usage();
$ret = 1;