diff options
-rwxr-xr-x | rhautoimport-eu | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/rhautoimport-eu b/rhautoimport-eu index 79867d4..af23d87 100755 --- a/rhautoimport-eu +++ b/rhautoimport-eu @@ -31,7 +31,7 @@ use lib '/usr/local/share/rhautoimport/'; use rhautoimport; my $STAT_FILE = $ENV{'HOME'} . "/rhautoimport-eu.stat"; -my $API_URL = "https://api.audioboom.com/users/3848170/audio_clips"; +my $RSS_URL = "http://economicupdate.libsyn.com/rss"; my $RD_GROUP = "ecoupdate"; my $PV_ID = '568'; my $TITLE="Economic Update"; @@ -84,47 +84,50 @@ if(Date::Calc::Delta_Days(@broadcast_date, @today) <= 0) { my $id = sprintf("%04d-%02d-%02d", @import_date); my $bd = sprintf("%04d-%02d-%02d", @broadcast_date); -print "looking for files after $bd in Audioboom Clips\n"; -print " -> $API_URL\n"; +print "looking for files issued after $bd in RSS-Feed\n"; +print " -> $RSS_URL\n"; -my ($result, $data) = rhautoimport::fetch_parse_json_audioboom($API_URL); +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); unless ($result) { - print "Error fetching data: $data\n"; + print "Error fetching feed: $feed\n"; exit 1; } -my @clips = @{$data->{'body'}{'audio_clips'}}; - -my $titleexp = "^Economic\\s+Update\\s*:"; - my $uri = ""; my $file = ""; my $sum_title = ""; my $sum_text = ""; -for my $clip (@clips) { - $sum_title = decode_entities($clip->{title}); - next unless $sum_title =~ /$titleexp/; +for my $entry ($feed->entries) { + next unless $entry->enclosure; - my $recorded = $clip->{recorded_at}; - next unless (defined $recorded); - my $rdt = DateTime::Format::ISO8601->parse_datetime($recorded); - print " Title: $sum_title (Recorded: " . $rdt . ")\n"; + $sum_title = decode_entities($entry->title); + $sum_text = decode_entities($entry->content->body); - my @recoreded_date = ($rdt->year, $rdt->month, $rdt->day); - next if(Date::Calc::Delta_Days(@broadcast_date, @recoreded_date) < 0); + my $issued = $entry->issued; + next unless (defined $issued); + my $idt = DateTime::Format::ISO8601->parse_datetime($issued); + print " Title: $sum_title (Issued: " . $idt . ")\n"; - if (defined $clip->{description}) { - $sum_text = decode_entities($clip->{description}); - } else { - $sum_text = ''; + my @issued_date = ($idt->year, $idt->month, $idt->day); + next if(Date::Calc::Delta_Days(@broadcast_date, @issued_date) < 0); + + + my $j = 0; + for my $enclosure($entry->enclosure) { + $j++; + if($enclosure->type eq "audio/mpeg" || $enclosure->type eq "audio/ogg") { + my $orig_uri = $enclosure->url; + $uri = new URI::URL($orig_uri); + my @path = $uri->path_components; + $file = $path[-1]; + + print " $j: (" . $enclosure->type . ", " . $enclosure->length . ") " . $file . "\n"; + last; + } } - my $orig_uri = $clip->{urls}{high_mp3}; - next unless $orig_uri; - $uri = new URI::URL($orig_uri); - my @path = $uri->path_components; - $file = $path[-1]; + next if($file eq ""); my $current_file = `cat $STAT_FILE`; if($current_file eq $file) { |