botr 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.gitignore +31 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +278 -0
- data/Rakefile +43 -0
- data/botr.gemspec +24 -0
- data/botr.watchr +3 -0
- data/certs/cacert.pem +3554 -0
- data/lib/botr.rb +34 -0
- data/lib/botr/api/api.rb +83 -0
- data/lib/botr/api/authentication.rb +24 -0
- data/lib/botr/channels/channel.rb +137 -0
- data/lib/botr/channels/channel_thumbnail.rb +88 -0
- data/lib/botr/channels/channel_video.rb +130 -0
- data/lib/botr/channels/channel_view.rb +88 -0
- data/lib/botr/common/logger.rb +31 -0
- data/lib/botr/configuration.rb +18 -0
- data/lib/botr/http/http.rb +88 -0
- data/lib/botr/http/http_backend.rb +66 -0
- data/lib/botr/http/http_response.rb +48 -0
- data/lib/botr/http/multipart.rb +84 -0
- data/lib/botr/http/uri_ext.rb +28 -0
- data/lib/botr/object.rb +20 -0
- data/lib/botr/players/player.rb +149 -0
- data/lib/botr/players/player_view.rb +88 -0
- data/lib/botr/version.rb +3 -0
- data/lib/botr/videos/video.rb +187 -0
- data/lib/botr/videos/video_caption.rb +154 -0
- data/lib/botr/videos/video_conversion.rb +114 -0
- data/lib/botr/videos/video_engagement.rb +51 -0
- data/lib/botr/videos/video_tag.rb +52 -0
- data/lib/botr/videos/video_thumbnail.rb +87 -0
- data/lib/botr/videos/video_view.rb +89 -0
- data/spec/authentication_spec.rb +31 -0
- data/spec/botr_spec.rb +8 -0
- data/spec/http_backend_spec.rb +93 -0
- data/spec/http_response_spec.rb +48 -0
- data/spec/multipart_spec.rb +35 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/test.txt +1 -0
- metadata +150 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
module BOTR
|
2
|
+
|
3
|
+
class VideoCaption < BOTR::Object
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_reader :last_status
|
8
|
+
|
9
|
+
def show(key)
|
10
|
+
json = get_request({:method => 'show',
|
11
|
+
:caption_key => key})
|
12
|
+
res = JSON.parse(json.body)
|
13
|
+
|
14
|
+
if json.status == 200
|
15
|
+
params = process_show_response(res)
|
16
|
+
else
|
17
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
18
|
+
end
|
19
|
+
|
20
|
+
return new(params)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :find :show
|
24
|
+
|
25
|
+
def list(key, **options)
|
26
|
+
json = get_request(options.merge(:method => 'list',
|
27
|
+
:video_key => key))
|
28
|
+
res = JSON.parse(json.body)
|
29
|
+
|
30
|
+
if json.status == 200
|
31
|
+
results = process_list_response(res)
|
32
|
+
else
|
33
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
34
|
+
end
|
35
|
+
|
36
|
+
return results
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def process_show_response(body)
|
42
|
+
@last_status = body["status"]
|
43
|
+
|
44
|
+
return body["caption"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def process_list_response(body)
|
48
|
+
res = []
|
49
|
+
|
50
|
+
body["captions"].each do |caption|
|
51
|
+
res << new(caption)
|
52
|
+
end
|
53
|
+
|
54
|
+
return res
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :last_status, :key, :label, :format, :link, :position,
|
60
|
+
:md5, :status, :error
|
61
|
+
|
62
|
+
def initialize(params = {})
|
63
|
+
params.each do |key, val|
|
64
|
+
param = "@#{key.to_s}"
|
65
|
+
next unless methods.include? key.to_sym
|
66
|
+
instance_variable_set(param, val)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def create(video_key, **options)
|
71
|
+
json = get_request(options.merge(:method => 'create',
|
72
|
+
:video_key => video_key))
|
73
|
+
res = JSON.parse(json.body)
|
74
|
+
|
75
|
+
if json.status == 200
|
76
|
+
process_create_response(res)
|
77
|
+
else
|
78
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
79
|
+
end
|
80
|
+
|
81
|
+
return self
|
82
|
+
end
|
83
|
+
|
84
|
+
def upload(data_path, **options)
|
85
|
+
json = post_request(options, data_path)
|
86
|
+
res = JSON.parse(json.body)
|
87
|
+
|
88
|
+
if json.status == 200
|
89
|
+
process_upload_response(res)
|
90
|
+
else
|
91
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
92
|
+
end
|
93
|
+
|
94
|
+
return self
|
95
|
+
end
|
96
|
+
|
97
|
+
def update(**options)
|
98
|
+
json = put_request(options.merge(:caption_key => @key))
|
99
|
+
res = JSON.parse(json.body)
|
100
|
+
|
101
|
+
if json.status == 200
|
102
|
+
process_update_response(res, options)
|
103
|
+
else
|
104
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
105
|
+
end
|
106
|
+
|
107
|
+
return self
|
108
|
+
end
|
109
|
+
|
110
|
+
def delete
|
111
|
+
json = delete_request({:caption_key => @key})
|
112
|
+
res = JSON.parse(json.body)
|
113
|
+
|
114
|
+
if json.status == 200
|
115
|
+
process_delete_response(res)
|
116
|
+
else
|
117
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
118
|
+
end
|
119
|
+
|
120
|
+
return self
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def process_create_response(body)
|
126
|
+
@last_status = body["status"]
|
127
|
+
@key = body["media"]["key"]
|
128
|
+
@link = body["link"]
|
129
|
+
end
|
130
|
+
|
131
|
+
def process_upload_response(body)
|
132
|
+
@last_status = body["status"]
|
133
|
+
@file = body["file"]
|
134
|
+
end
|
135
|
+
|
136
|
+
def process_update_response(body, updated_params)
|
137
|
+
@last_status = body["status"]
|
138
|
+
updated_params.each do |key, val|
|
139
|
+
param = "@#{key.to_s}"
|
140
|
+
next unless methods.include? key
|
141
|
+
instance_variable_set(param, val)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def process_delete_response(body)
|
146
|
+
@last_status = body["status"]
|
147
|
+
instance_variables.each do |param|
|
148
|
+
instance_variable_set(param, nil)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module BOTR
|
2
|
+
|
3
|
+
class VideoConversion < BOTR::Object
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_reader :last_status
|
8
|
+
|
9
|
+
def show(key)
|
10
|
+
json = get_request({:method => 'show',
|
11
|
+
:conversion_key => key})
|
12
|
+
res = JSON.parse(json.body)
|
13
|
+
|
14
|
+
if json.status == 200
|
15
|
+
params = process_show_response(res)
|
16
|
+
else
|
17
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
18
|
+
end
|
19
|
+
|
20
|
+
return new(params)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :find :show
|
24
|
+
|
25
|
+
def list(key)
|
26
|
+
json = get_request({:method => 'list',
|
27
|
+
:video_key => key})
|
28
|
+
res = JSON.parse(json.body)
|
29
|
+
|
30
|
+
if json.status == 200
|
31
|
+
results = process_list_response(res)
|
32
|
+
else
|
33
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
34
|
+
end
|
35
|
+
|
36
|
+
return results
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def process_show_response(body)
|
42
|
+
@last_status = body["status"]
|
43
|
+
|
44
|
+
return body["conversion"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def process_list_response(body)
|
48
|
+
res = []
|
49
|
+
|
50
|
+
body["conversions"].each do |conversion|
|
51
|
+
res << new(conversion)
|
52
|
+
end
|
53
|
+
|
54
|
+
return res
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :last_status, :key, :mediatype, :status, :duration,
|
60
|
+
:filesize, :width, :height, :template, :error, :link
|
61
|
+
|
62
|
+
def initialize(params = {})
|
63
|
+
params.each do |key, val|
|
64
|
+
param = "@#{key.to_s}"
|
65
|
+
next unless methods.include? key.to_sym
|
66
|
+
instance_variable_set(param, val)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def create(video_key, template_key)
|
71
|
+
json = get_request({:method => 'create',
|
72
|
+
:video_key => video_key,
|
73
|
+
:template_key => template_key})
|
74
|
+
res = JSON.parse(json.body)
|
75
|
+
|
76
|
+
if json.status == 200
|
77
|
+
process_create_response(res)
|
78
|
+
else
|
79
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
80
|
+
end
|
81
|
+
|
82
|
+
return self
|
83
|
+
end
|
84
|
+
|
85
|
+
def delete
|
86
|
+
json = delete_request({:conversion_key => @key})
|
87
|
+
res = JSON.parse(json.body)
|
88
|
+
|
89
|
+
if json.status == 200
|
90
|
+
process_delete_response(res)
|
91
|
+
else
|
92
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
93
|
+
end
|
94
|
+
|
95
|
+
return self
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def process_create_response(body)
|
101
|
+
@last_status = body["status"]
|
102
|
+
@key = body["conversion"]["key"]
|
103
|
+
end
|
104
|
+
|
105
|
+
def process_delete_response(body)
|
106
|
+
@last_status = body["status"]
|
107
|
+
instance_variables.each do |param|
|
108
|
+
instance_variable_set(param, nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module BOTR
|
2
|
+
|
3
|
+
class VideoEngagement < BOTR::Object
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_reader :last_status
|
8
|
+
|
9
|
+
def call_class
|
10
|
+
"videos/engagement"
|
11
|
+
end
|
12
|
+
|
13
|
+
def show(key)
|
14
|
+
json = get_request({:method => 'show',
|
15
|
+
:video_key => key})
|
16
|
+
res = JSON.parse(json.body)
|
17
|
+
|
18
|
+
if json.status == 200
|
19
|
+
params = process_show_response(res)
|
20
|
+
else
|
21
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
22
|
+
end
|
23
|
+
|
24
|
+
return new(params)
|
25
|
+
end
|
26
|
+
|
27
|
+
alias :find :show
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def process_show_response(body)
|
32
|
+
@last_status = body["status"]
|
33
|
+
|
34
|
+
return body["video"]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :last_status, :key, :engagements
|
40
|
+
|
41
|
+
def initialize(params = {})
|
42
|
+
params.each do |key, val|
|
43
|
+
param = "@#{key.to_s}"
|
44
|
+
next unless methods.include? key.to_sym
|
45
|
+
instance_variable_set(param, val)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module BOTR
|
2
|
+
|
3
|
+
class VideoTag < BOTR::Object
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_reader :last_status
|
8
|
+
|
9
|
+
def list(**options)
|
10
|
+
json = get_request(options.merge(:method => 'list'))
|
11
|
+
res = JSON.parse(json.body)
|
12
|
+
|
13
|
+
if json.status == 200
|
14
|
+
results = process_list_response(res)
|
15
|
+
else
|
16
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
17
|
+
end
|
18
|
+
|
19
|
+
return results
|
20
|
+
end
|
21
|
+
|
22
|
+
def all
|
23
|
+
list({})
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def process_list_response(body)
|
29
|
+
res = []
|
30
|
+
|
31
|
+
body["tags"].each do |tag|
|
32
|
+
res << new(tag)
|
33
|
+
end
|
34
|
+
|
35
|
+
return res
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_reader :name ,:videos
|
41
|
+
|
42
|
+
def initialize(params = {})
|
43
|
+
params.each do |key, val|
|
44
|
+
param = "@#{key.to_s}"
|
45
|
+
next unless methods.include? key.to_sym
|
46
|
+
instance_variable_set(param, val)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module BOTR
|
2
|
+
|
3
|
+
class VideoThumbnail < BOTR::Object
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_reader :last_status
|
8
|
+
|
9
|
+
def show(key)
|
10
|
+
json = get_request({:method => 'show',
|
11
|
+
:video_key => key})
|
12
|
+
res = JSON.parse(json.body)
|
13
|
+
|
14
|
+
if json.status == 200
|
15
|
+
params = process_show_response(res)
|
16
|
+
else
|
17
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
18
|
+
end
|
19
|
+
|
20
|
+
return new(params)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :find :show
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def process_show_response(body)
|
28
|
+
@last_status = body["status"]
|
29
|
+
|
30
|
+
return body["thumbnail"]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :last_status, :key, :status, :strip_status, :link,
|
36
|
+
:error, :strip_error
|
37
|
+
|
38
|
+
def initialize(params = {})
|
39
|
+
params.each do |key, val|
|
40
|
+
param = "@#{key.to_s}"
|
41
|
+
next unless methods.include? key.to_sym
|
42
|
+
instance_variable_set(param, val)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def update(**options)
|
47
|
+
json = put_request(options.merge(:video_key => @key))
|
48
|
+
res = JSON.parse(json.body)
|
49
|
+
|
50
|
+
if json.status == 200
|
51
|
+
process_update_response(res)
|
52
|
+
else
|
53
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
54
|
+
end
|
55
|
+
|
56
|
+
return self
|
57
|
+
end
|
58
|
+
|
59
|
+
def upload(data_path, **options)
|
60
|
+
json = post_request(options, data_path)
|
61
|
+
res = JSON.parse(json.body)
|
62
|
+
|
63
|
+
if json.status == 200
|
64
|
+
process_upload_response(res)
|
65
|
+
else
|
66
|
+
raise "HTTP Error #{json.status}: #{json.body}"
|
67
|
+
end
|
68
|
+
|
69
|
+
return self
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def process_update_response(body)
|
75
|
+
@last_status = body["status"]
|
76
|
+
@key = body["media"]["key"]
|
77
|
+
@link = body["link"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def process_upload_response(body)
|
81
|
+
@last_status = body["status"]
|
82
|
+
@file = body["file"]
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|