botr 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +191 -149
- data/bin/botr +8 -0
- data/botr.gemspec +2 -0
- data/lib/botr.rb +1 -0
- data/lib/botr/cli.rb +67 -0
- data/lib/botr/version.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0e34c44fecc55872d65243f45755214beeff7a
|
4
|
+
data.tar.gz: aba50853754c0a898cc7849ba8c2e114bc23c576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb5513746ee5b1c2185045e0f9df5502709d756a51222c14b1c97e376398dc49a0af1b28fb33cfe3f45751082cc60eb037cc05a62ee787b704600e4e318001e
|
7
|
+
data.tar.gz: 54c8e031503c4ef403f7f4c91c1382595677205deef61ff376d627402196febf4918430493c0ab9b4f4503dd7c1bc61b23c44ed0334fed5c53fb1ed9a20297a7
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# botr (BitsOnTheRun)
|
1
|
+
# botr (BitsOnTheRun) [](http://badge.fury.io/rb/botr) [](https://gemnasium.com/bertrandk/botr) [](https://codeclimate.com/github/bertrandk/botr)
|
2
2
|
|
3
3
|
## Requirements
|
4
4
|
|
@@ -12,7 +12,8 @@
|
|
12
12
|
|
13
13
|
## Description
|
14
14
|
|
15
|
-
A ruby API kit that manages the authentication, serialization and sending of API
|
15
|
+
A ruby API kit that manages the authentication, serialization and sending of API
|
16
|
+
calls to the Bits on the Run online video platform.
|
16
17
|
|
17
18
|
## Features
|
18
19
|
|
@@ -22,242 +23,283 @@ The botr gem includes support for the following Bits on the Run API classes:
|
|
22
23
|
* channels (video playlists)
|
23
24
|
* players (based on JW Player)
|
24
25
|
|
26
|
+
## Command-line Usage
|
27
|
+
|
28
|
+
$ gem install botr
|
29
|
+
$ botr upload /path/to/video.mp4 -k <API_KEY> -s <API_SECRET>
|
30
|
+
|
31
|
+
See `botr help` or `botr help upload` for more information.
|
32
|
+
|
25
33
|
## Examples
|
26
34
|
|
27
35
|
require 'botr'
|
28
36
|
|
29
37
|
### Configuration
|
30
|
-
BOTR.configure do |config|
|
31
|
-
config.api_key = "<botr_api_key>"
|
32
|
-
config.secret_key = "<botr_secret_key>"
|
33
|
-
end
|
34
38
|
|
35
|
-
|
39
|
+
```ruby
|
40
|
+
BOTR.configure do |config|
|
41
|
+
config.api_key = "<botr_api_key>"
|
42
|
+
config.secret_key = "<botr_secret_key>"
|
43
|
+
end
|
44
|
+
|
45
|
+
# NOTE: It is recommended to set the api key and the secret key as environment
|
46
|
+
# variables and reference them using the `ENV` hash (e.g. config.api_key = ENV["BOTR_API_KEY"]).
|
47
|
+
```
|
36
48
|
|
37
49
|
### Videos
|
38
50
|
|
39
|
-
|
40
|
-
|
41
|
-
|
51
|
+
```ruby
|
52
|
+
# create a new video metadata container
|
53
|
+
vid = BOTR::Video.new
|
54
|
+
vid.create(title: "My cat video", author: "Me")
|
42
55
|
|
43
|
-
|
44
|
-
|
56
|
+
# upload actual video file
|
57
|
+
vid.upload("/Users/Me/Movies/grumpy_kitty.mov")
|
45
58
|
|
46
|
-
|
47
|
-
|
59
|
+
# update the properties of a video
|
60
|
+
vid.update(title: "My super awesome cat video", description: "Mr. Snicker
|
61
|
+
apparently doesn't like being filmed.")
|
48
62
|
|
49
|
-
|
50
|
-
|
63
|
+
# delete a given video and all its conversions
|
64
|
+
vid.delete
|
51
65
|
|
52
|
-
|
53
|
-
|
66
|
+
# list all videos
|
67
|
+
BOTR::Video.all # => [#<BOTR::Video>, #<BOTR::Video>, ...]
|
54
68
|
|
55
|
-
|
56
|
-
|
69
|
+
# list only certain videos
|
70
|
+
BOTR::Video.list(search: "cat", order_by: "date")
|
57
71
|
|
58
|
-
|
59
|
-
|
72
|
+
# find a certain video by video key
|
73
|
+
cat_vid = BOTR::Video.show("<video_key>") # => #<BOTR::Video @key="[video_key]">
|
74
|
+
```
|
60
75
|
|
61
76
|
### Video Conversions
|
62
77
|
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
```ruby
|
79
|
+
# create a new video conversion
|
80
|
+
480p_vid = BOTR::VideoConversion.new
|
81
|
+
480p_vid.create("<video_key>", "<template_key>")
|
66
82
|
|
67
|
-
|
68
|
-
|
83
|
+
# delete a given video conversion from the CDN
|
84
|
+
480p_vid.delete
|
69
85
|
|
70
|
-
|
71
|
-
|
86
|
+
# list all video conversions for a given video
|
87
|
+
BOTR::VideoConversion.list("<video_key>", result_limit: 5)
|
72
88
|
|
73
|
-
|
74
|
-
|
89
|
+
# find a given video conversion by its conversion key
|
90
|
+
aac_vid = BOTR::VideoConversion.show("<conversion_key>")
|
91
|
+
```
|
75
92
|
|
76
93
|
### Video Thumbnails
|
77
94
|
|
78
|
-
|
79
|
-
|
95
|
+
```ruby
|
96
|
+
# find a video thumbnail
|
97
|
+
thumb = BOTR::VideoThumbnail.show("<video_key>")
|
80
98
|
|
81
|
-
|
82
|
-
|
99
|
+
# update a video's thumbnail
|
100
|
+
thumb.update(position: 7.25) # updates the video's thumbnail to the image at
|
101
|
+
7.25 seconds
|
83
102
|
|
84
|
-
|
85
|
-
|
103
|
+
# upload a new video thumbnail
|
104
|
+
thumb.upload("/Users/Me/Pictures/snicker_smiles.png")
|
105
|
+
```
|
86
106
|
|
87
107
|
### Video Captions
|
88
108
|
|
89
|
-
|
90
|
-
|
91
|
-
|
109
|
+
```ruby
|
110
|
+
# create a new video caption
|
111
|
+
espanol = BOTR::VideoCaption.new
|
112
|
+
espanol.create(label: "esp")
|
92
113
|
|
93
|
-
|
94
|
-
|
114
|
+
# upload the actual caption file
|
115
|
+
espanol.upload("/Users/Me/Documents/grunon_gata.txt")
|
95
116
|
|
96
|
-
|
97
|
-
|
117
|
+
# update the video caption
|
118
|
+
espanol.update(label: "Spanish")
|
98
119
|
|
99
|
-
|
100
|
-
|
120
|
+
# delete a video caption
|
121
|
+
espanol.delete("<caption_key>")
|
101
122
|
|
102
|
-
|
103
|
-
|
123
|
+
# list the captions for a video
|
124
|
+
BOTR::VideoCaption.list("<video_key>", order_by: "label:asc")
|
104
125
|
|
105
|
-
|
106
|
-
|
126
|
+
# get the caption information for a video
|
127
|
+
cap = BOTR::VideoCaption.show("<video_key>")
|
128
|
+
```
|
107
129
|
|
108
130
|
### Video Tags
|
109
131
|
|
110
|
-
|
111
|
-
|
132
|
+
```ruby
|
133
|
+
# list a video's tags
|
134
|
+
BOTR::VideoTag.all
|
112
135
|
|
113
|
-
|
114
|
-
|
136
|
+
# search for video tags matching a certain criteria
|
137
|
+
BOTR::VideoTag.list(search: "kitty")
|
138
|
+
```
|
115
139
|
|
116
140
|
### Video Views
|
117
|
-
|
118
|
-
date = Time.new(2002, 10, 31)
|
119
|
-
unix_timestamp = date.to_i
|
120
141
|
|
121
|
-
|
122
|
-
|
142
|
+
```ruby
|
143
|
+
date = Time.new(2002, 10, 31)
|
144
|
+
unix_timestamp = date.to_i
|
145
|
+
|
146
|
+
# list view statistics by video
|
147
|
+
BOTR::VideoView.list(start_date: unix_timestamp)
|
123
148
|
|
124
|
-
|
125
|
-
|
149
|
+
# list view statistics by day
|
150
|
+
BOTR::VideoView.list(list_by: "day", group_days: false)
|
126
151
|
|
127
|
-
|
128
|
-
|
152
|
+
# list view statistics, grouping by day
|
153
|
+
BOTR::VideoView.list(list_by: "day", group_days: true)
|
129
154
|
|
130
|
-
|
131
|
-
|
155
|
+
# list view statistics in aggregate
|
156
|
+
BOTR::VideoView.list(list_by: "day", aggregate: true)
|
132
157
|
|
133
|
-
|
134
|
-
|
158
|
+
# find a video's statistics
|
159
|
+
BOTR::VideoView.show("<video_key>")
|
160
|
+
```
|
135
161
|
|
136
162
|
### Video Engagements
|
137
|
-
|
138
|
-
|
139
|
-
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
# display engagement analytics for a single video
|
166
|
+
BOTR::VideoEngagement.show("<video_key>")
|
167
|
+
```
|
140
168
|
|
141
169
|
### Channels (Playlists)
|
142
|
-
|
143
|
-
# create a manual playlist
|
144
|
-
my_picks = BOTR::Channel.new
|
145
|
-
my_picks.create(title: "My Picks", type: "manual")
|
146
170
|
|
147
|
-
|
148
|
-
|
149
|
-
|
171
|
+
```ruby
|
172
|
+
# create a manual playlist
|
173
|
+
my_picks = BOTR::Channel.new
|
174
|
+
my_picks.create(title: "My Picks", type: "manual")
|
175
|
+
|
176
|
+
# create a dynamic playlist
|
177
|
+
top_picks = BOTR::Channel.new
|
178
|
+
top_picks.create(title: "Trending", type: "automatic")
|
150
179
|
|
151
|
-
|
152
|
-
|
180
|
+
# add videos to a dynamic playlist
|
181
|
+
top_picks.update(description: "Top 10 videos", tags: "kitty",
|
182
|
+
sort_order: "views-desc", videos_max: 10)
|
153
183
|
|
154
|
-
|
155
|
-
|
184
|
+
# delete a channel
|
185
|
+
top_picks.delete
|
156
186
|
|
157
|
-
|
158
|
-
|
187
|
+
# get a list of all channels
|
188
|
+
BOTR::Channel.all
|
159
189
|
|
160
|
-
|
161
|
-
|
190
|
+
# get a list of all dynamic "picks" channels
|
191
|
+
BOTR::Channel.list(types_filter: "dynamic", search: "top")
|
162
192
|
|
163
|
-
|
164
|
-
|
193
|
+
# get a specific channel
|
194
|
+
my_ch = BOTR::Channel.show("<channel_key>")
|
195
|
+
```
|
165
196
|
|
166
197
|
### Channel Videos
|
167
|
-
|
168
|
-
# get a list of videos in a channel
|
169
|
-
BOTR::ChannelVideo.list(top_picks.key)
|
170
198
|
|
171
|
-
|
172
|
-
|
199
|
+
```ruby
|
200
|
+
# get a list of videos in a channel
|
201
|
+
BOTR::ChannelVideo.list(top_picks.key)
|
202
|
+
|
203
|
+
# get video info. from a channel
|
204
|
+
second_vid = BOTR::ChannelVideo.show(my_picks.key, position: 2)
|
173
205
|
|
174
|
-
|
175
|
-
|
206
|
+
# remove a video from a manual channel
|
207
|
+
second_vid.delete
|
176
208
|
|
177
|
-
|
178
|
-
|
179
|
-
|
209
|
+
# add a video to a manual channel
|
210
|
+
snicker_falls = BOTR::ChannelVideo.new({key: "<video_key>"})
|
211
|
+
snicker_falls.create(my_picks.key)
|
180
212
|
|
181
|
-
|
182
|
-
|
213
|
+
# move a video to a different position in a manual channel
|
214
|
+
BOTR::ChannelVideo.update(my_picks.key, position_from: 10, position_to: 2)
|
215
|
+
```
|
183
216
|
|
184
217
|
### Channel Thumbnails
|
185
218
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
219
|
+
```ruby
|
220
|
+
# update a channel's thumbnail
|
221
|
+
new_tumb = BOTR::ChannelThumbnail.new({key: "<channel_key>"})
|
222
|
+
new_thumb.update
|
223
|
+
new_thumb.upload("/Users/Me/Pictures/splash.png")
|
190
224
|
|
191
|
-
|
192
|
-
|
193
|
-
|
225
|
+
# get the status of a video thumbnail creation (it takes about 10 seconds
|
226
|
+
before a new thumbnail is ready to show)
|
227
|
+
thumb_stat = BOTR::ChannelThumbnail.show("<channel_key>")
|
228
|
+
thumb_stat.status # => "ready"
|
229
|
+
```
|
194
230
|
|
195
231
|
### Channel Views
|
196
232
|
|
197
|
-
|
198
|
-
|
233
|
+
```ruby
|
234
|
+
# get view stats by channel
|
235
|
+
BOTR::ChannelView.list(list_by: "channel")
|
199
236
|
|
200
|
-
|
201
|
-
|
237
|
+
# get channel view stats by day
|
238
|
+
BOTR::ChannelView.list(list_by: "day", group_days: false)
|
202
239
|
|
203
|
-
|
204
|
-
|
240
|
+
# get channel view stats by grouped days (i.e. in months and years)
|
241
|
+
BOTR::ChannelView.list(list_by: "day", group_days: true)
|
205
242
|
|
206
|
-
|
207
|
-
|
243
|
+
# get aggregate channel view stats
|
244
|
+
BOTR::ChannelView.list(aggregate: true)
|
208
245
|
|
209
|
-
|
210
|
-
|
246
|
+
# get view stats for a specific channel
|
247
|
+
ch_stats = BOTR::ChannelView.show("<channel_key>", group_days: false)
|
211
248
|
|
212
|
-
|
213
|
-
|
249
|
+
# get view stats for a specific channel in months and years
|
250
|
+
ch_group_stats = BOTR::ChannelView.show("<channel_key>", group_days: true)
|
214
251
|
|
215
|
-
|
216
|
-
|
252
|
+
# get aggregate view stats for a specific channel
|
253
|
+
ch_report = BOTR::ChannelView.show("<channel_key>", aggregate: true)
|
254
|
+
```
|
217
255
|
|
218
256
|
### Players
|
219
|
-
|
220
|
-
# create a JW Player
|
221
|
-
new_player = BOTR::Player.new
|
222
|
-
new_player.create("Awesome Player", "<sharing_player_key>", autostart: false)
|
223
257
|
|
224
|
-
|
225
|
-
|
258
|
+
```ruby
|
259
|
+
# create a JW Player
|
260
|
+
new_player = BOTR::Player.new
|
261
|
+
new_player.create("Awesome Player", "<sharing_player_key>", autostart: false)
|
226
262
|
|
227
|
-
|
228
|
-
|
263
|
+
# update a player's settings
|
264
|
+
new_player.update(controlbar: bottom, repeat: always)
|
229
265
|
|
230
|
-
|
231
|
-
|
266
|
+
# delete a player
|
267
|
+
new_player.delete
|
232
268
|
|
233
|
-
|
234
|
-
|
269
|
+
# get a list of all players
|
270
|
+
BOTR::Player.all
|
235
271
|
|
236
|
-
|
237
|
-
|
272
|
+
# list only certain players
|
273
|
+
BOTR::Player.list(search: "awesome")
|
274
|
+
|
275
|
+
# get a specific player
|
276
|
+
my_player = BOTR::Player.show("<player_key>")
|
277
|
+
```
|
238
278
|
|
239
279
|
### Player Views
|
240
|
-
|
241
|
-
# get views by player
|
242
|
-
BOTR::PlayerView.list(list_by: "player")
|
243
280
|
|
244
|
-
|
245
|
-
|
281
|
+
```ruby
|
282
|
+
# get views by player
|
283
|
+
BOTR::PlayerView.list(list_by: "player")
|
284
|
+
|
285
|
+
# get views by day
|
286
|
+
BOTR::PlayerView.list(list_by: "day", group_days: flase, include_empty_days: true)
|
246
287
|
|
247
|
-
|
248
|
-
|
288
|
+
# get views by month and year
|
289
|
+
BOTR::PlayerView.list(list_by: "day", group_days: true)
|
249
290
|
|
250
|
-
|
251
|
-
|
291
|
+
# get aggregate player view
|
292
|
+
BOTR::PlayerView.list(aggregate: true)
|
252
293
|
|
253
|
-
|
254
|
-
|
294
|
+
# get view stats for a specific player
|
295
|
+
player_stats = BOTR::PlayerView.show("<player_key>", group_days: false)
|
255
296
|
|
256
|
-
|
257
|
-
|
297
|
+
# get view stats for a specific player in months and years
|
298
|
+
player_group_stats = BOTR::PlayerView.show("<player_key>", group_days: true)
|
258
299
|
|
259
|
-
|
260
|
-
|
300
|
+
# get aggregate view stats for a specific player
|
301
|
+
player_report = BOTR::PlayerView.show("<player_key>", aggregate: true)
|
302
|
+
```
|
261
303
|
|
262
304
|
## Todo
|
263
305
|
|
data/bin/botr
ADDED
data/botr.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
+
gem.add_dependency 'thor', '~> 0.18.1'
|
21
|
+
|
20
22
|
gem.add_development_dependency 'rspec', '~> 2.4'
|
21
23
|
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
22
24
|
gem.add_development_dependency 'watchr', '~> 0.7'
|
data/lib/botr.rb
CHANGED
data/lib/botr/cli.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module BOTR
|
4
|
+
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "upload VIDEO_PATH", "Uploads the video specified by VIDEO_PATH"
|
8
|
+
long_desc <<-LONGDESC
|
9
|
+
Uploads the video specified by VIDEO_PATH. You must also provide an api KEY and an api SECRET.
|
10
|
+
|
11
|
+
With -t option, you may specify the title of the video.
|
12
|
+
|
13
|
+
With -g option, you may specify tags for the video; multiple tags should be comma-separated.
|
14
|
+
|
15
|
+
With -d option, you may specify a description for the video.
|
16
|
+
|
17
|
+
With -a option, you may specify the author of the video.
|
18
|
+
|
19
|
+
With -d option, you may specify the video creation date; the date must be in Unix timestamp format.
|
20
|
+
|
21
|
+
With -l option, you may specify the URL of the web page where this video will be published.
|
22
|
+
LONGDESC
|
23
|
+
option :key, :aliases => :k, :type => :string, :required => true
|
24
|
+
option :secret, :aliases => :s, :type => :string, :required => true
|
25
|
+
option :title, :aliases => :t, :type => :string
|
26
|
+
option :tags, :aliases => :g, :type => :string
|
27
|
+
option :description, :aliases => :d, :type => :string
|
28
|
+
option :author, :aliases => :a, :type => :string
|
29
|
+
option :date, :aliases => :d, :type => :numeric
|
30
|
+
option :link, :aliases => :l, :type => :string
|
31
|
+
def upload(video_path)
|
32
|
+
_options = clean_options(options)
|
33
|
+
set_configurations(_options[:key], _options[:secret])
|
34
|
+
|
35
|
+
puts "\nStarting upload.\n\n"
|
36
|
+
prepare_video_container(_options)
|
37
|
+
|
38
|
+
puts "Uploading....\n\n"
|
39
|
+
upload_video(video_path)
|
40
|
+
|
41
|
+
puts "Upload Complete.\n\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def clean_options(opt)
|
47
|
+
opt.reject { |k, v| v.nil? }
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_configurations(key, secret)
|
51
|
+
BOTR.configure do |config|
|
52
|
+
config.api_key = key
|
53
|
+
config.secret_key = secret
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def prepare_video_container(opt)
|
58
|
+
@video = BOTR::Video.new(opt)
|
59
|
+
@video.create
|
60
|
+
end
|
61
|
+
|
62
|
+
def upload_video(video_path)
|
63
|
+
@video.upload(video_path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/lib/botr/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bertrandk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,7 +83,8 @@ dependencies:
|
|
69
83
|
description: A ruby API kit that manages the authentication, serialization and sending
|
70
84
|
of API calls to the Bits on the Run online video platform.
|
71
85
|
email: b.karerangabo@gmail.com
|
72
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- botr
|
73
88
|
extensions: []
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
@@ -81,6 +96,7 @@ files:
|
|
81
96
|
- LICENSE.txt
|
82
97
|
- README.md
|
83
98
|
- Rakefile
|
99
|
+
- bin/botr
|
84
100
|
- botr.gemspec
|
85
101
|
- botr.watchr
|
86
102
|
- certs/cacert.pem
|
@@ -92,6 +108,7 @@ files:
|
|
92
108
|
- lib/botr/channels/channel_thumbnail.rb
|
93
109
|
- lib/botr/channels/channel_video.rb
|
94
110
|
- lib/botr/channels/channel_view.rb
|
111
|
+
- lib/botr/cli.rb
|
95
112
|
- lib/botr/common/logger.rb
|
96
113
|
- lib/botr/configuration.rb
|
97
114
|
- lib/botr/http/http.rb
|