summaryrefslogtreecommitdiff
path: root/rhimport-rs
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2013-02-21 14:13:36 (GMT)
committerChristian Pointner <equinox@helsinki.at>2013-02-21 14:13:36 (GMT)
commit206a1b98bce0c0e4fa4936805aa88258a3c1fb8e (patch)
tree1890e4fac660185adfb9fdbdf1bf5df990efc01b /rhimport-rs
parent3eeb626406c2790c98e04aecacf7a61cc903e2ed (diff)
radio stimme works now with new cba (_cut vs no _cut)
Diffstat (limited to 'rhimport-rs')
-rwxr-xr-xrhimport-rs67
1 files changed, 41 insertions, 26 deletions
diff --git a/rhimport-rs b/rhimport-rs
index a0c7012..f78fbb7 100755
--- a/rhimport-rs
+++ b/rhimport-rs
@@ -43,7 +43,8 @@ my $DBPW = "lldriven";
my $DB = "rivendell";
my $STAT_FILE = $ENV{'HOME'} . "/rhimport-rs.stat";
-my $RSS_URL = "http://cba.fro.at/seriesrss/197";
+my $RSS_URL = "http://cba.fro.at/seriesrss/197?dev=true";
+$XML::Feed::MULTIPLE_ENCLOSURES=1;
my $PV_ID = '75';
binmode(STDIN, ":utf8");
@@ -139,33 +140,47 @@ my $feed = XML::Feed->parse(URI->new($RSS_URL))
my $file = "";
my $out_file = "";
+my $i = 0;
for my $entry ($feed->entries) {
- if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
- my $ff = File::Fetch->new(uri => $entry->enclosure->url);
- next unless (uc($ff->output_file) =~ $bdfile); # file not from correct day
-
- my $sum_title = decode_entities($entry->title);
- my $sum_text = decode_entities($entry->content->body);
-
- my $current_stat = `cat $STAT_FILE`;
- my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/;
- if($current_id eq $id && $current_file eq $ff->output_file) {
- print "Already downloaded file of today\n";
- $dbh->disconnect();
- exit 0;
+ $i++;
+ next unless $entry->enclosure;
+ my $j = 0;
+ for my $enclosure($entry->enclosure) {
+ $j++;
+ if($enclosure->type eq "audio/mpeg" || $enclosure->type eq "audio/ogg") {
+ print "$i/$j: (" . $enclosure->type . ", " . $enclosure->length . ") " . $enclosure->url . "\n";
+ my $url = $enclosure->url;
+ if($url =~ /^(.*)_cut(\.[^\.]+)$/) {
+ $url = $1 . $2;
+ }
+
+ my $ff = File::Fetch->new(uri => $url);
+ next unless (uc($ff->output_file) =~ $bdfile); # file not from correct day
+
+ my $sum_title = decode_entities($entry->title);
+ my $sum_text = decode_entities($entry->content->body);
+
+ my $current_stat = `cat $STAT_FILE`;
+ my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/;
+ if($current_id eq $id && $current_file eq $ff->output_file) {
+ print "Already downloaded file of today\n";
+ $dbh->disconnect();
+ exit 0;
+ }
+ $out_file = $ff->output_file;
+
+ print " --> " . $bdfile . ": downloading " . $url . " (" . $enclosure->length . " Bytes) .. ";
+ $file = $ff->fetch( to => '/tmp' ) or die $ff->error;
+ print "ok\n";
+
+ print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
+
+ rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1");
+ print "\n";
+
+ last;
}
- $out_file = $ff->output_file;
-
- print $bdfile . ": downloading " . $entry->enclosure->url . " (" . $entry->enclosure->length . " Bytes) .. ";
- $file = $ff->fetch( to => '/tmp' ) or die $ff->error;
- print "ok\n";
-
- print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
-
- rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1");
- print "\n";
-
- last;
+ last if $file != "";
}
}