My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 215 attachment: 0001-Don-t-report-zero-recorded-items-as-a-connection-err.patch (4.0 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From bbe0d66f703afd66780204dd9e2d57da8fda9cfc Mon Sep 17 00:00:00 2001
From: Drew Moseley <drew@moseleynet.net>
Date: Sat, 8 Sep 2012 18:38:46 -0400
Subject: [PATCH] Don't report zero recorded items as a connection error

Signed-off-by: Drew Moseley <drew@moseleynet.net>
---
ParseXML.pl | 16 ++++++++++++----
iTiVo.applescript | 12 ++++++------
2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/ParseXML.pl b/ParseXML.pl
index 92a9f42..45850da 100755
--- a/ParseXML.pl
+++ b/ParseXML.pl
@@ -12,7 +12,7 @@ $usedCache = 0;
# Make sure we have a place to cache the results
`mkdir -p $CacheDir`;

-$fetchScript = "curl -q -s 'https://" . $IP . ":443/TiVoConnect?Command=QueryContainer&Container=%2FNowPlaying&Recurse=Yes&AnchorOffset=" . $anchor . "' -k --digest -u tivo:" . $MAK;
+$fetchScript = "curl --connect-timeout 3 -q -s 'https://" . $IP . ":443/TiVoConnect?Command=QueryContainer&Container=%2FNowPlaying&Recurse=Yes&AnchorOffset=" . $anchor . "' -k --digest -u tivo:" . $MAK;

if ((-e $CacheFile) && (((-M $CacheFile) * 24 * 60) < 5)) {
# We have already fetched the list from this tivo within the last five minutes, so just use the cached value
@@ -36,8 +36,14 @@ if ((-e $CacheFile) && (((-M $CacheFile) * 24 * 60) < 5)) {
close (RESULT);
}

-$file =~ m/<TotalItems>(.*?)<\/TotalItems>/g;
-$TotalItems = $1;
+$length = length($file);
+
+if ($length == 0) {
+ $TotalItems = -1
+} else {
+ $file =~ m/<TotalItems>(.*?)<\/TotalItems>/g;
+ $TotalItems = $1;
+}

$file =~ s/&amp;/&/g;
$file =~ s/&gt;/>/g;
@@ -179,6 +185,8 @@ while ($anchor < $TotalItems) {
$total = $space_regular + $space_suggestion + $space_expired + $space_expires_soon + $space_in_progress + $space_copyrighted + $space_save_until;
$final_result = "$total_shows|$total|$space_regular|$space_suggestion|$space_expired|$space_expires_soon|$space_in_progress|$space_copyrighted|$space_save_until\n" . $final_result;

-if ($total > 0) {
+if ($TotalItems == -1) {
+ print "connect-error\n";
+} elsif ($total > 0) {
print "$final_result";
}
diff --git a/iTiVo.applescript b/iTiVo.applescript
index ca82652..1504ff0 100755
--- a/iTiVo.applescript
+++ b/iTiVo.applescript
@@ -2161,15 +2161,15 @@ on ConnectTiVo()
my debug_log(ShellScriptCommand)
set TiVoList to do shell script ShellScriptCommand
end tell
- if TiVoList = "" then
+ if TiVoList = "connect-error" then
+ display dialog "iTiVo could not communicate with your TiVo. Please make sure your IP address and Media Access Key are correct (check your Prefs) and try again." buttons {"OK"} default button "OK" attached to window "iTiVo"
+ set contents of text field "status" of window "iTiVo" to "Failed to connect to tivo!"
+ return
+ else
if (MAK < 1) then
display dialog "Your Media Access Key is not set correctly. (Select *Help* from the menu if you don't know how) " buttons {"OK"} default button "OK" attached to window "iTiVo"
my displayPrefs()
- else
- display dialog "iTiVo could not communicate with your TiVo. Please make sure your IP address and Media Access Key are correct (check your Prefs) and try again." buttons {"OK"} default button "OK" attached to window "iTiVo"
end if
- set contents of text field "status" of window "iTiVo" to "Failed to connect to tivo!"
- return
end if
tell window "iTiVo"
if TiVoList ≠ "" then
@@ -2313,8 +2313,8 @@ on ConnectTiVo()
set DLHistoryTemp to items (DLHistoryCount - showcount) thru -1 of DLHistory
set DLHistory to DLHistoryTemp
end if
- set title of button "ConnectButton" to "Update from TiVo"
end if
+ set title of button "ConnectButton" to "Update from TiVo"
set myShowCount to (count data rows of data source of table view "ShowListTable" of scroll view "ShowList" of box "topBox" of split view "splitView1")
set myQueueCount to (count data rows of data source of table view "QueueListTable" of scroll view "QueueList" of view "bottomLeftView" of split view "splitView2" of box "bottomBox" of split view "splitView1")
if myQueueCount > 0 then
--
1.7.11.5

Powered by Google Project Hosting