From: Andrew Ruthven <andrew@etc.gen.nz>
Date: Tue, 17 Jan 2012 20:56:24 +0000 (+1300)
Subject: Support the new location for the XML feed in MythTV 0.25
X-Git-Tag: debian-0.10.0-1~14
X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe6cb37a388703740e2bf65bfc56e62ffaa7e725;p=mythtv-status.git

Support the new location for the XML feed in MythTV 0.25
---

diff --git a/bin/mythtv-status b/bin/mythtv-status
index 6904325..2902d04 100755
--- a/bin/mythtv-status
+++ b/bin/mythtv-status
@@ -644,9 +644,15 @@ sub load_xml {
 
     close IN;
   } else {
-    my $url = "http://$c->{'host'}:$c->{'port'}/xml";
     my $content_type;
-    ($content_type, $status) = xml_fetch($url);
+    # In MythTV 0.25 the path changed from /xml to /Status/GetStatus
+    for my $path ('Status/GetStatus', 'xml') {
+      my $url = "http://$c->{'host'}:$c->{'port'}/$path";
+      ($content_type, $status) = xml_fetch($url);
+
+      last
+        if defined $status;
+    }
 
     die "Nothing was received from the MythTV Backend"
       unless defined $status;
@@ -1052,7 +1058,13 @@ sub xml_fetch {
     die "Sorry, failed to fetch $url: Connection to MythTV timed out.\n"
       unless defined $response;
 
-    die "Sorry, failed to fetch $url:\n" . $response->status_line . "\n"
+    # If we get a page doesn't exist, then just ignore it, we need to fetch
+    # the status page from a few different locations.
+    if ($response->code == 404) {
+      exit 1;
+    }
+
+    die "Sorry, failed to fetch $url: " . $response->status_line . "\n"
       unless $response->is_success;
 
     print $response->header('Content-Type') . "\n";