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 198 attachment: 0005-Move-logic-to-find-local-TiVo-IP-addresses-to-an-ext.patch (6.7 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 1b2075b8c65c285d0a35d63633ee1795ef7eb1f0 Mon Sep 17 00:00:00 2001
From: Drew Moseley <drew@moseleynet.net>
Date: Sun, 2 Sep 2012 23:32:44 -0400
Subject: [PATCH 5/5] Move logic to find local TiVo IP addresses to an
external script and allow the mDNS utility to not exist
for Mountain Lion

Signed-off-by: Drew Moseley <drew@moseleynet.net>
---
findLocalTivoIPAddress.sh | 16 ++++++++++++++++
iTiVo.applescript | 36 +++++++++++-------------------------
iTiVo.xcodeproj/project.pbxproj | 4 ++++
3 files changed, 31 insertions(+), 25 deletions(-)
create mode 100755 findLocalTivoIPAddress.sh

diff --git a/findLocalTivoIPAddress.sh b/findLocalTivoIPAddress.sh
new file mode 100755
index 0000000..814216e
--- /dev/null
+++ b/findLocalTivoIPAddress.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+
+if [ -L /usr/bin/mDNS -o ! -e /usr/bin/mDNS ]; then
+ # If it is a symlink or it doesn't exist, defer to the dns-sd command
+ HNAME=$(dns-sd -L "$1" _tivo-videos._tcp local | grep 'can be reached.*:443' | colrm 1 78 | awk -F: '{print $1}' | sed 's@\.$@@' | sort | uniq | head -1 &
+ sleep 2
+ killall dns-sd)
+ ping -c 1 ${HNAME} | head -1 | cut -d \( -f 2 | cut -d \) -f 1
+else
+ # Go ahead and use the mDNS executable
+ IP_ADDRESS=$(mDNS -L "$1" _tivo-videos._tcp local | grep ':443' | colrm 1 42 | awk '{print $1}' | sort | uniq | head -1 &
+ sleep 2
+ killall mDNS)
+ echo ${IP_ADDRESS}
+fi
diff --git a/iTiVo.applescript b/iTiVo.applescript
index 45eebcc..148c013 100755
--- a/iTiVo.applescript
+++ b/iTiVo.applescript
@@ -615,20 +615,13 @@ on readSettings()
if TiVo ≠ "My TiVos" then
set title of popup button "MyTiVos" of window "iTiVo" to TiVo
try
- set theScript to "mDNS -L \"" & TiVo & "\" _tivo-videos._tcp local | colrm 1 42 &
-sleep 2
-killall mDNS"
+ set myPath to my prepareCommand(POSIX path of (path to me))
+ set theScript to "sh " & myPath & "Contents/Resources/findLocalTivoIPAddress.sh \"" & TiVo & "\""
my debug_log(theScript)
- set hostList to paragraphs 1 thru -1 of (do shell script theScript)
- repeat with j in hostList
- try
- if text 17 thru 19 of j is "443" then
- set IPA to first word of j
- set contents of text field "IP" of window "iTiVo" to IPA
- set canAutoConnect to true
- end if
- end try
- end repeat
+ set IPA to first word of (do shell script theScript)
+ my debug_log("IPA = " & IPA)
+ set contents of text field "IP" of window "iTiVo" to IPA
+ set canAutoConnect to true
on error
display dialog "Unable to connect to TiVo " & TiVo & ". It is no longer available on your network."
end try
@@ -1277,19 +1270,12 @@ on choose menu item theObject
if title of theObject ≠ "My TiVos" then
tell window "iTiVo"
try
- set theScript to "mDNS -L \"" & title of theObject & "\" _tivo-videos._tcp local | colrm 1 42 &
-sleep 2
-killall mDNS"
+ set myPath to my prepareCommand(POSIX path of (path to me))
+ set theScript to "sh " & myPath & "Contents/Resources/findLocalTivoIPAddress.sh \"" & title of theObject & "\""
my debug_log(theScript)
- set hostList to paragraphs 1 thru -1 of (do shell script theScript)
- repeat with j in hostList
- try
- if text 17 thru 19 of j is "443" then
- set IPA to first word of j
- set contents of text field "IP" to IPA
- end if
- end try
- end repeat
+ set IPA to first word of (do shell script theScript)
+ my debug_log("IPA = " & IPA)
+ set contents of text field "IP" to IPA
set filterValue to ""
set contents of text field "filterField" of box "topBox" of split view "splitView1" to filterValue
my ConnectTiVo()
diff --git a/iTiVo.xcodeproj/project.pbxproj b/iTiVo.xcodeproj/project.pbxproj
index 22c0efb..7aa5cdc 100755
--- a/iTiVo.xcodeproj/project.pbxproj
+++ b/iTiVo.xcodeproj/project.pbxproj
@@ -37,6 +37,7 @@

/* Begin PBXBuildFile section */
2441259D15F436B800710497 /* findLocalTivos.sh in Resources */ = {isa = PBXBuildFile; fileRef = 2441259C15F436B800710497 /* findLocalTivos.sh */; };
+ 248B1FF615F44CBE00756168 /* findLocalTivoIPAddress.sh in Resources */ = {isa = PBXBuildFile; fileRef = 248B1FF515F44CBE00756168 /* findLocalTivoIPAddress.sh */; };
257572C5072881A4000BE9CA /* iTiVo.applescript in AppleScript */ = {isa = PBXBuildFile; fileRef = DA206CF3015C4E8B03C91932 /* iTiVo.applescript */; settings = {ATTRIBUTES = (Debug, ); }; };
257572C7072881A4000BE9CA /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
257572C8072881A4000BE9CA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
@@ -115,6 +116,7 @@
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
2441259C15F436B800710497 /* findLocalTivos.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = findLocalTivos.sh; sourceTree = "<group>"; };
+ 248B1FF515F44CBE00756168 /* findLocalTivoIPAddress.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = findLocalTivoIPAddress.sh; sourceTree = "<group>"; };
257572D5072881A4000BE9CA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
257572D6072881A4000BE9CA /* iTiVo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iTiVo.app; sourceTree = BUILT_PRODUCTS_DIR; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -264,6 +266,7 @@
isa = PBXGroup;
children = (
2441259C15F436B800710497 /* findLocalTivos.sh */,
+ 248B1FF515F44CBE00756168 /* findLocalTivoIPAddress.sh */,
5393FA6F0F425DDD0025D17A /* copyright.png */,
536575DA0EE2791800B68A56 /* empty-check.png */,
536575DB0EE2791800B68A56 /* empty.png */,
@@ -409,6 +412,7 @@
535A80C60F5A2AA000F149FC /* generate_subtitles.pl in Resources */,
535A80D70F5A3F6300F149FC /* subtitlesSize.pl in Resources */,
2441259D15F436B800710497 /* findLocalTivos.sh in Resources */,
+ 248B1FF615F44CBE00756168 /* findLocalTivoIPAddress.sh in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--
1.7.11.5

Powered by Google Project Hosting