summaryrefslogtreecommitdiff
path: root/rhimport.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport.pm')
-rw-r--r--rhimport.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/rhimport.pm b/rhimport.pm
index 6181f56..c9035c0 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -33,6 +33,8 @@ use URI::Escape;
use POSIX;
use DateTime;
use DateTime::TimeZone;
+use LWP::Simple;
+use XML::Feed;
my $ssh_host = "airplay";
my $ssh_user = "rhimport";
@@ -67,6 +69,26 @@ sub get_rd_week
return $week;
}
+sub fetch_parse_rss
+{
+ my ($url, $ua_str) = @_;
+
+ my $uri = URI->new($url);
+ $ua_str = "Radio Helsinki - Automatic Import" unless $ua_str;
+
+ my $ua = LWP::UserAgent->new;
+ $ua->agent($ua_str);
+ $ua->env_proxy;
+ my $res = URI::Fetch->fetch($uri, UserAgent => $ua)
+ or die URI::Fetch->errstr;
+ die "This feed has been permanently removed"
+ if $res->status == URI::Fetch::URI_GONE();
+
+ my $xml = $res->content;
+
+ return XML::Feed->parse(\$xml);
+}
+
sub check_key_file
{
if(-e "$ssh_key_file") {