summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INFO9
-rw-r--r--debian/changelog6
-rwxr-xr-xrhautoimport-ra42
3 files changed, 39 insertions, 18 deletions
diff --git a/INFO b/INFO
index b83690e..65b76b0 100644
--- a/INFO
+++ b/INFO
@@ -1,6 +1,15 @@
*** add info about other importers... ***
+- Radio Attac:
+ https://cba.fro.at/series/radioattac/feed
+
+ Original: wöchentlich Montags
+ Upload: meistens am selben Tag, abends (> 20 Uhr)
+ Such-Kriterium: cba:productionDate
+ RH: wöchentlich, Mittwoch, 15:00-15:30
+ wöchentlich, Samstag, 15:30-16:00, Wiederholung
+
- Eigenklang:
https://cba.fro.at/series/eigenklang/feed
diff --git a/debian/changelog b/debian/changelog
index c470c91..dceebfa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+rhautoimport (37-1) UNRELEASED; urgency=medium
+
+ * radio attac importer now uses cba Production Date
+
+ -- Christian Pointner <equinox@spreadspace.org> Thu, 07 Sep 2017 16:44:26 +0200
+
rhautoimport (36-1) unstable; urgency=medium
* added import for x_xy
diff --git a/rhautoimport-ra b/rhautoimport-ra
index bdf0760..710bd64 100755
--- a/rhautoimport-ra
+++ b/rhautoimport-ra
@@ -23,6 +23,7 @@
use strict;
use Date::Calc;
+use DateTime::Format::Strptime;
use XML::Feed;
use XML::Feed::Entry;
use XML::Feed::Content;
@@ -40,6 +41,7 @@ my $RD_GROUP = "RadioATTAC";
my $PV_ID = '76';
my $TITLE="radio%attac";
my $LAST_RUN = 0;
+my $upload_delay_days = 0; # files are usally there on the same day of the original broadcast
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
@@ -70,17 +72,23 @@ my $show_id_reb = $allowed_dbs[$idx_reb]->{'SHOWID'};
my $show_title_reb = $allowed_dbs[$idx_reb]->{'SHOWTITLE'};
-my @today = Date::Calc::Standard_to_Business(Date::Calc::Today());
-$today[2] = 1;
-my @broadcast_day = Date::Calc::Business_to_Standard(@today);
-$today[2] = 3;
-my @import_date = Date::Calc::Business_to_Standard(@today);
+my @today = Date::Calc::Today();
+my @tmp = Date::Calc::Standard_to_Business(@today);
+$tmp[2] = 1;
+my @broadcast_date = Date::Calc::Business_to_Standard(@tmp);
+$tmp[2] = 3;
+my @import_date = Date::Calc::Business_to_Standard(@tmp);
my @import_date_reb = Date::Calc::Add_Delta_Days(@import_date, 3);
-print "day of original broadcast: " . Date::Calc::Date_to_Text(@broadcast_day) . "\n";
+print "day of original broadcast: " . Date::Calc::Date_to_Text(@broadcast_date) . "\n";
print "day of Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n";
print "day of Radio Helsinki rebroadcast: " . Date::Calc::Date_to_Text(@import_date_reb) . "\n";
-my $bd = sprintf("%04d-%02d-%02d", @broadcast_day);
+if(Date::Calc::Delta_Days(@broadcast_date, @today) <= $upload_delay_days) {
+ print "File won't be available by now!\n";
+ exit 42;
+}
+
+my $bd = sprintf("%04d-%02d-%02d", @broadcast_date);
print "looking for files from $bd in RSS Feed\n";
print " -> $RSS_URL\n";
@@ -90,8 +98,6 @@ unless ($result) {
exit 1;
}
-my $bdexp = sprintf("^(\\d+)\\..*\\s*0?%d\\s*[.,]\\s*0?%d\\s*[.,]\\s*%4d", $broadcast_day[2], $broadcast_day[1], $broadcast_day[0]);
-
my $uri = "";
my $file = "";
my $sum_title = "";
@@ -101,6 +107,13 @@ my $i = 0;
for my $entry ($feed->entries) {
$i++;
next unless $entry->enclosure;
+
+ my $entry_bdt = $entry->{'entry'}{'https://cba.fro.at/help#feeds'}{'productionDate'};
+ next unless (defined $entry_bdt);
+ my $bdt = DateTime::Format::Strptime::strptime("%a, %d %b %Y", $entry_bdt);
+
+ next unless($broadcast_date[0] == $bdt->year && $broadcast_date[1] == $bdt->month && $broadcast_date[2] == $bdt->day);
+
my $j = 0;
for my $enclosure($entry->enclosure) {
$j++;
@@ -111,18 +124,9 @@ for my $entry ($feed->entries) {
$orig_uri = $1 . $2;
}
- $sum_title = decode_entities($entry->title);
- $sum_text = decode_entities($entry->content->body);
- next unless $sum_title =~ /$bdexp/;
- my $bnum = $1;
-
$uri = new URI::URL($orig_uri);
my @path = $uri->path_components;
$file = $path[-1];
- unless($bnum eq substr($file, 0, 3)) {
- $uri = "";
- next;
- }
my $current_file = `cat $STAT_FILE`;
if($current_file eq $file) {
@@ -135,6 +139,8 @@ for my $entry ($feed->entries) {
exit 1;
}
+ $sum_title = decode_entities($entry->title);
+ $sum_text = decode_entities($entry->content->body);
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
last;
}