Index: shepherd
===================================================================
--- shepherd (revision 151)
+++ shepherd (revision 158)
@@ -3,5 +3,5 @@
 # "Shepherd"
 
-my $version = '0.2.26';
+my $version = '0.2.27';
 
 # A wrapper for various Aussie TV guide data grabbers
@@ -39,4 +39,5 @@
 # 0.2.25  : use open-with-pipe rather than system() and look at
 #           return codes from called programmes
+# 0.2.27  : Identify self in useragent when fetching shepherd files
 
 BEGIN { *CORE::GLOBAL::die = \&my_die; }
@@ -44,5 +45,5 @@
 use strict;
 
-use LWP::Simple;
+use LWP::UserAgent;
 use Sort::Versions;
 use Cwd;
@@ -1469,5 +1470,5 @@
     &log("\nChecking for updates:\n\n");
 
-    my $data = fetch_file("status");
+    my $data = fetch_shepherd_file("status");
 
     return unless ($data);
@@ -1564,9 +1565,9 @@
     my $rfile = "$rdir/$proggy";
 
-    return unless (fetch_file($rfile, $newfile));
+    return unless (fetch_shepherd_file($rfile, $newfile));
 
     # Fetch grabber config file
     $rfile .= ".conf";
-    $config = fetch_file($rfile);
+    $config = fetch_shepherd_file($rfile);
 
     if (!$config) {
@@ -1618,5 +1619,5 @@
 }
 
-sub fetch_file
+sub fetch_shepherd_file
 {
     my ($fn, $store) = @_;
@@ -1629,16 +1630,6 @@
     foreach my $site (split(/,/,$sites)) 
     {
-	&log("Fetching $site/$fn.\n");
-	if ($store)
-	{
-	    $ret = LWP::Simple::getstore("$site/$fn", $store);
-	    return 1 if (is_success($ret));
-	}
-	else
-	{
-	    $ret = LWP::Simple::get("$site/$fn");
-	    return $ret if ($ret);
-	}
-	&log("Failed to retrieve $site/$fn.\n");
+	$ret = fetch_file("$site/$fn", $store, 1);
+	return $ret if ($ret);
     }
     return undef;
@@ -1851,4 +1842,40 @@
 	return ($? >> 8);
     }
+}
+
+sub fetch_file
+{
+    my ($url, $store, $id_self) = @_;
+
+    &log("Fetching $url.\n");
+    
+    my $ua = LWP::UserAgent->new();
+    if ($id_self)
+    {
+	$ua->agent(ucfirst("$progname/$version"));
+    }
+    else
+    {
+	$ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322')
+    }
+
+    my $response = $ua->get($url);
+    if ($response->is_success())
+    {
+	if ($store)
+	{
+	    open (FILE, ">$store") 
+		or (&log("ERROR: Unable to open $store for writing.\n") and return undef);
+	    print FILE $response->content();
+	    close FILE;
+	    return 1;
+	}
+	else 
+	{
+	    return $response->content();
+	} 
+    }
+    &log("Failed to retrieve $url!\n" . $response->status_line() . "\n");
+    return undef;
 }
 
@@ -2146,5 +2173,5 @@
 {
     my @date = localtime;
-    my $page = LWP::Simple::get(
+    my $page = fetch_file(
 	"http://au.tv.yahoo.com/results.html?rg=$region&dt=" .
 	($date[5] + 1900) . "-$date[4]-$date[3]");
