airvideo 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/airvideo.rb +28 -15
- metadata +9 -4
data/README.rdoc
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
= AirVideo for Ruby
|
2
|
-
Have you ever thought to yourself: I have AirVideo
|
2
|
+
Have you ever thought to yourself: I have AirVideo[http://www.inmethod.com/air-video] running on my computer and I enjoy it so much
|
3
3
|
that not only have I bought the iPhone and iPad apps, I'd also love to be able to watch my video on my laptop too?
|
4
4
|
|
5
5
|
Me too! So I reverse engineered their communication protocol and came up with this. It's a little hacky (and it's certainly not been tested outside of Mac OS X 10.6)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/airvideo.rb
CHANGED
@@ -14,17 +14,13 @@ module AirVideo
|
|
14
14
|
# Setting #max_height and #max_width *should* be working with the Live Conversion, but for some reason it's not quite happening. Defaults are 640x480
|
15
15
|
class Client
|
16
16
|
attr_accessor :max_height, :max_width
|
17
|
+
attr_reader :proxy
|
17
18
|
|
18
19
|
# Specify where your AirVideo Server lives. If your HTTP_PROXY environment variable is set, it will be honoured.
|
19
20
|
#
|
20
21
|
# At the moment I'm expecting ENV['HTTP_PROXY'] to have the form 'sub.domain.com:8080', I throw an http:// and bung it into URI.parse for convenience.
|
21
22
|
def initialize(server,port = 45631,password=nil)
|
22
|
-
|
23
|
-
proxy = URI.parse("http://"+ENV['HTTP_PROXY'])
|
24
|
-
@http = Net::HTTP::Proxy(proxy.host, proxy.port)
|
25
|
-
rescue
|
26
|
-
@http = Net::HTTP
|
27
|
-
end
|
23
|
+
set_proxy # Set to environment proxy settings, if applicable
|
28
24
|
@endpoint = URI.parse "http://#{server}:#{port}/service"
|
29
25
|
@passworddigest = Digest::SHA1.hexdigest("S@17" + password + "@1r").upcase if !password.nil?
|
30
26
|
|
@@ -40,7 +36,23 @@ module AirVideo
|
|
40
36
|
@max_height = 480
|
41
37
|
end
|
42
38
|
|
43
|
-
#
|
39
|
+
# Potentially confusing:
|
40
|
+
# * Sending 'server:port' will use that address as an HTTP proxy
|
41
|
+
# * An empty string (or something not recognisable as a URL with http:// put infront of it) will try to use the ENV['HTTP_PROXY'] variable
|
42
|
+
# * Sending nil or any object that can't be parsed to a string will remove the proxy
|
43
|
+
#
|
44
|
+
# NB. You can access the @proxy URI object externally, but changing it will *not* automatically call set_proxy
|
45
|
+
def set_proxy(proxy_server_and_port = "")
|
46
|
+
begin
|
47
|
+
@proxy = URI.parse("http://"+((proxy_server_and_port.empty?) ? ENV['HTTP_PROXY'] : string_proxy))
|
48
|
+
@http = Net::HTTP::Proxy(@proxy.host, @proxy.port)
|
49
|
+
rescue
|
50
|
+
@proxy = nil
|
51
|
+
@http = Net::HTTP
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Lists the folders and videos in the current directory as an Array of AirVideo::VideoObject and AirVideo::FolderObject objects.
|
44
56
|
def ls(dir = ".")
|
45
57
|
dir = dir.location if dir.is_a? FolderObject
|
46
58
|
dir = File.expand_path(dir,@current_dir)[1..-1]
|
@@ -51,7 +63,7 @@ module AirVideo
|
|
51
63
|
when "air.video.DiskRootFolder", "air.video.ITunesRootFolder","air.video.Folder"
|
52
64
|
FolderObject.new(self,hash['name'],hash['itemId'])
|
53
65
|
when "air.video.VideoItem","air.video.ITunesVideoItem"
|
54
|
-
|
66
|
+
VideoObject.new(self,hash['name'],hash['itemId'],hash['detail'] || {})
|
55
67
|
else
|
56
68
|
raise NotImplementedError, "Unknown: #{hash.name}"
|
57
69
|
end
|
@@ -73,9 +85,9 @@ module AirVideo
|
|
73
85
|
self
|
74
86
|
end
|
75
87
|
|
76
|
-
# Returns the streaming video URL for the given AirVideo::
|
88
|
+
# Returns the streaming video URL for the given AirVideo::VideoObject.
|
77
89
|
def get_url(fileobj,liveconvert = false)
|
78
|
-
raise NoMethodError, "Please pass a
|
90
|
+
raise NoMethodError, "Please pass a VideoObject" if not fileobj.is_a? VideoObject
|
79
91
|
begin
|
80
92
|
if liveconvert
|
81
93
|
request("livePlaybackService","initLivePlayback",[conversion_settings(fileobj)])['result']['contentURL']
|
@@ -158,7 +170,7 @@ module AirVideo
|
|
158
170
|
attr_reader :name, :location
|
159
171
|
|
160
172
|
# Shouldn't be used outside of the AirVideo module
|
161
|
-
def initialize(server,name,location)
|
173
|
+
def initialize(server,name,location) # :nodoc:
|
162
174
|
@server = server
|
163
175
|
@name = name
|
164
176
|
@location = "/"+location
|
@@ -182,10 +194,11 @@ module AirVideo
|
|
182
194
|
# Represents a video file as listed by the AirVideo server.
|
183
195
|
#
|
184
196
|
# Has helper functions like #url and #live_url which give the video playback URLs of this video, as produced by the originating AirVideo::Client instance's AirVideo::Client.get_url method.
|
185
|
-
class
|
197
|
+
class VideoObject
|
186
198
|
attr_reader :name, :location, :details
|
187
199
|
|
188
|
-
|
200
|
+
# Shouldn't be used outside of the AirVideo module
|
201
|
+
def initialize(server,name,location,detail = {}) # :nodoc:
|
189
202
|
@server = server
|
190
203
|
@name = name
|
191
204
|
@location = "/"+location
|
@@ -301,8 +314,8 @@ module AirVideo
|
|
301
314
|
class BinaryData
|
302
315
|
attr_reader :data
|
303
316
|
|
304
|
-
# Not
|
305
|
-
def initialize(data)
|
317
|
+
# Not really useful outside of the AvMap module
|
318
|
+
def initialize(data) # :nodoc:
|
306
319
|
@data = data
|
307
320
|
end
|
308
321
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airvideo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- JP Hastings-Spital
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-05-
|
18
|
+
date: 2010-05-26 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -43,23 +44,27 @@ rdoc_options:
|
|
43
44
|
require_paths:
|
44
45
|
- lib
|
45
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
46
48
|
requirements:
|
47
49
|
- - ">="
|
48
50
|
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
49
52
|
segments:
|
50
53
|
- 0
|
51
54
|
version: "0"
|
52
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
53
57
|
requirements:
|
54
58
|
- - ">="
|
55
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
56
61
|
segments:
|
57
62
|
- 0
|
58
63
|
version: "0"
|
59
64
|
requirements: []
|
60
65
|
|
61
66
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.7
|
63
68
|
signing_key:
|
64
69
|
specification_version: 3
|
65
70
|
summary: Allows communication with an AirVideo server
|