cessna 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cessna.rb +47 -17
- data/lib/cessna/version.rb +1 -1
- data/views/browse.haml +1 -1
- data/views/error.haml +7 -0
- metadata +2 -1
data/lib/cessna.rb
CHANGED
@@ -37,23 +37,32 @@ module Cessna
|
|
37
37
|
end
|
38
38
|
|
39
39
|
get '/browse' do
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
begin
|
41
|
+
items = fetch_items('/')
|
42
|
+
@folders = collect_folders(items)
|
43
|
+
@videos = collect_videos(items)
|
43
44
|
|
44
|
-
|
45
|
+
haml :browse
|
46
|
+
rescue RuntimeError
|
47
|
+
show_error('It was not possible to access the shared folders. Perhaps the content is protected?')
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
get '/browse/:folder_location' do
|
48
52
|
location = Base64.decode64(params[:folder_location])
|
49
|
-
@parent_location = parent_location(location)
|
50
|
-
@current_folder = item_name(location)
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
begin
|
55
|
+
@parent_location = parent_location(location)
|
56
|
+
@current_folder = item_name(location)
|
57
|
+
|
58
|
+
items = fetch_items(location)
|
59
|
+
@folders = collect_folders(items)
|
60
|
+
@videos = collect_videos(items)
|
55
61
|
|
56
|
-
|
62
|
+
haml :browse
|
63
|
+
rescue RuntimeError => e
|
64
|
+
show_runtime_error(e)
|
65
|
+
end
|
57
66
|
end
|
58
67
|
|
59
68
|
post '/session' do
|
@@ -66,15 +75,20 @@ module Cessna
|
|
66
75
|
|
67
76
|
get '/play/:video_location' do
|
68
77
|
location = Base64.decode64(params[:video_location])
|
69
|
-
client = airvideo_client
|
70
|
-
@parent_location = parent_location(location)
|
71
|
-
@video_name = item_name(location)
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
79
|
+
begin
|
80
|
+
client = airvideo_client
|
81
|
+
@parent_location = parent_location(location)
|
82
|
+
@video_name = item_name(location)
|
83
|
+
|
84
|
+
client.cd(@parent_location)
|
85
|
+
video = client.ls.select{|item| item.name == @video_name}.first
|
86
|
+
@video_stream_url = video.url
|
76
87
|
|
77
|
-
|
88
|
+
haml :play
|
89
|
+
rescue RuntimeError => e
|
90
|
+
show_runtime_error(e)
|
91
|
+
end
|
78
92
|
end
|
79
93
|
|
80
94
|
private
|
@@ -119,5 +133,21 @@ module Cessna
|
|
119
133
|
location.split('/').last
|
120
134
|
end
|
121
135
|
end
|
136
|
+
|
137
|
+
def show_runtime_error(exception)
|
138
|
+
show_error("AirVideo Runtime Error: #{exception}")
|
139
|
+
end
|
140
|
+
|
141
|
+
def show_error(error_message)
|
142
|
+
clear_session
|
143
|
+
@error_message = error_message
|
144
|
+
haml :error
|
145
|
+
end
|
146
|
+
|
147
|
+
def clear_session
|
148
|
+
session['hostname'] = nil
|
149
|
+
session['port'] = nil
|
150
|
+
session['password'] = nil
|
151
|
+
end
|
122
152
|
end
|
123
153
|
end
|
data/lib/cessna/version.rb
CHANGED
data/views/browse.haml
CHANGED
data/views/error.haml
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cessna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- public/assets/img/glyphicons-halflings-white.png
|
83
83
|
- public/assets/img/glyphicons-halflings.png
|
84
84
|
- views/browse.haml
|
85
|
+
- views/error.haml
|
85
86
|
- views/index.haml
|
86
87
|
- views/layout.haml
|
87
88
|
- views/play.haml
|