bbc_redux 0.4.0.pre
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.
- data/AUTHORS +8 -0
- data/COPYING +212 -0
- data/Gemfile +3 -0
- data/README.md +174 -0
- data/Rakefile +47 -0
- data/bbc_redux.gemspec +61 -0
- data/lib/bbc/redux/asset.rb +119 -0
- data/lib/bbc/redux/channel.rb +45 -0
- data/lib/bbc/redux/channel_category.rb +36 -0
- data/lib/bbc/redux/client.rb +302 -0
- data/lib/bbc/redux/end_points.rb +78 -0
- data/lib/bbc/redux/key.rb +73 -0
- data/lib/bbc/redux/media_url.rb +123 -0
- data/lib/bbc/redux/search_results.rb +82 -0
- data/lib/bbc/redux/serializers.rb +101 -0
- data/lib/bbc/redux/user.rb +107 -0
- data/lib/bbc/redux/version.rb +8 -0
- data/lib/bbc/redux.rb +10 -0
- data/spec/bbc/redux/asset_spec.rb +45 -0
- data/spec/bbc/redux/channel_category_spec.rb +23 -0
- data/spec/bbc/redux/channel_spec.rb +24 -0
- data/spec/bbc/redux/client_spec.rb +279 -0
- data/spec/bbc/redux/key_spec.rb +66 -0
- data/spec/bbc/redux/media_url_spec.rb +151 -0
- data/spec/bbc/redux/search_results_spec.rb +69 -0
- data/spec/bbc/redux/user_spec.rb +37 -0
- data/spec/fixtures/asset.json +24 -0
- data/spec/fixtures/channel_categories.json +28 -0
- data/spec/fixtures/channels.json +51 -0
- data/spec/fixtures/search_results.json +172 -0
- data/spec/fixtures/user.json +22 -0
- data/spec/integration/bbc_redux_spec.rb +78 -0
- data/spec/spec_helper.rb +24 -0
- metadata +227 -0
data/AUTHORS
ADDED
data/COPYING
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
(c) 2013 British Broadcasting Corporation and contributors
|
2
|
+
|
3
|
+
See "AUTHORS" file for full details.
|
4
|
+
|
5
|
+
All code here, except where otherwise indicated, is licensed under
|
6
|
+
the Apache Licence version 2.0.
|
7
|
+
|
8
|
+
----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
Apache License
|
11
|
+
Version 2.0, January 2004
|
12
|
+
http://www.apache.org/licenses/
|
13
|
+
|
14
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
15
|
+
|
16
|
+
1. Definitions.
|
17
|
+
|
18
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
19
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
20
|
+
|
21
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
22
|
+
the copyright owner that is granting the License.
|
23
|
+
|
24
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
25
|
+
other entities that control, are controlled by, or are under common
|
26
|
+
control with that entity. For the purposes of this definition,
|
27
|
+
"control" means (i) the power, direct or indirect, to cause the
|
28
|
+
direction or management of such entity, whether by contract or
|
29
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
30
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
31
|
+
|
32
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
33
|
+
exercising permissions granted by this License.
|
34
|
+
|
35
|
+
"Source" form shall mean the preferred form for making modifications,
|
36
|
+
including but not limited to software source code, documentation
|
37
|
+
source, and configuration files.
|
38
|
+
|
39
|
+
"Object" form shall mean any form resulting from mechanical
|
40
|
+
transformation or translation of a Source form, including but
|
41
|
+
not limited to compiled object code, generated documentation,
|
42
|
+
and conversions to other media types.
|
43
|
+
|
44
|
+
"Work" shall mean the work of authorship, whether in Source or
|
45
|
+
Object form, made available under the License, as indicated by a
|
46
|
+
copyright notice that is included in or attached to the work
|
47
|
+
(an example is provided in the Appendix below).
|
48
|
+
|
49
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
50
|
+
form, that is based on (or derived from) the Work and for which the
|
51
|
+
editorial revisions, annotations, elaborations, or other modifications
|
52
|
+
represent, as a whole, an original work of authorship. For the
|
53
|
+
purposes
|
54
|
+
of this License, Derivative Works shall not include works that remain
|
55
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
56
|
+
the Work and Derivative Works thereof.
|
57
|
+
|
58
|
+
"Contribution" shall mean any work of authorship, including
|
59
|
+
the original version of the Work and any modifications or additions
|
60
|
+
to that Work or Derivative Works thereof, that is intentionally
|
61
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
62
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
63
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
64
|
+
means any form of electronic, verbal, or written communication sent
|
65
|
+
to the Licensor or its representatives, including but not limited to
|
66
|
+
communication on electronic mailing lists, source code control
|
67
|
+
systems,
|
68
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
69
|
+
Licensor for the purpose of discussing and improving the Work, but
|
70
|
+
excluding communication that is conspicuously marked or otherwise
|
71
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
72
|
+
|
73
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
74
|
+
on behalf of whom a Contribution has been received by Licensor and
|
75
|
+
subsequently incorporated within the Work.
|
76
|
+
|
77
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
80
|
+
copyright license to reproduce, prepare Derivative Works of,
|
81
|
+
publicly display, publicly perform, sublicense, and distribute the
|
82
|
+
Work and such Derivative Works in Source or Object form.
|
83
|
+
|
84
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
85
|
+
this License, each Contributor hereby grants to You a perpetual,
|
86
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
87
|
+
(except as stated in this section) patent license to make, have made,
|
88
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
89
|
+
where such license applies only to those patent claims licensable
|
90
|
+
by such Contributor that are necessarily infringed by their
|
91
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
92
|
+
with the Work to which such Contribution(s) was submitted. If You
|
93
|
+
institute patent litigation against any entity (including a
|
94
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
95
|
+
or a Contribution incorporated within the Work constitutes direct
|
96
|
+
or contributory patent infringement, then any patent licenses
|
97
|
+
granted to You under this License for that Work shall terminate
|
98
|
+
as of the date such litigation is filed.
|
99
|
+
|
100
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
101
|
+
Work or Derivative Works thereof in any medium, with or without
|
102
|
+
modifications, and in Source or Object form, provided that You
|
103
|
+
meet the following conditions:
|
104
|
+
|
105
|
+
(a) You must give any other recipients of the Work or
|
106
|
+
Derivative Works a copy of this License; and
|
107
|
+
|
108
|
+
(b) You must cause any modified files to carry prominent notices
|
109
|
+
stating that You changed the files; and
|
110
|
+
|
111
|
+
(c) You must retain, in the Source form of any Derivative Works
|
112
|
+
that You distribute, all copyright, patent, trademark, and
|
113
|
+
attribution notices from the Source form of the Work,
|
114
|
+
excluding those notices that do not pertain to any part of
|
115
|
+
the Derivative Works; and
|
116
|
+
|
117
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
118
|
+
distribution, then any Derivative Works that You distribute must
|
119
|
+
include a readable copy of the attribution notices contained
|
120
|
+
within such NOTICE file, excluding those notices that do not
|
121
|
+
pertain to any part of the Derivative Works, in at least one
|
122
|
+
of the following places: within a NOTICE text file distributed
|
123
|
+
as part of the Derivative Works; within the Source form or
|
124
|
+
documentation, if provided along with the Derivative Works; or,
|
125
|
+
within a display generated by the Derivative Works, if and
|
126
|
+
wherever such third-party notices normally appear. The contents
|
127
|
+
of the NOTICE file are for informational purposes only and
|
128
|
+
do not modify the License. You may add Your own attribution
|
129
|
+
notices within Derivative Works that You distribute, alongside
|
130
|
+
or as an addendum to the NOTICE text from the Work, provided
|
131
|
+
that such additional attribution notices cannot be construed
|
132
|
+
as modifying the License.
|
133
|
+
|
134
|
+
You may add Your own copyright statement to Your modifications and
|
135
|
+
may provide additional or different license terms and conditions
|
136
|
+
for use, reproduction, or distribution of Your modifications, or
|
137
|
+
for any such Derivative Works as a whole, provided Your use,
|
138
|
+
reproduction, and distribution of the Work otherwise complies with
|
139
|
+
the conditions stated in this License.
|
140
|
+
|
141
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
142
|
+
any Contribution intentionally submitted for inclusion in the Work
|
143
|
+
by You to the Licensor shall be under the terms and conditions of
|
144
|
+
this License, without any additional terms or conditions.
|
145
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
146
|
+
the terms of any separate license agreement you may have executed
|
147
|
+
with Licensor regarding such Contributions.
|
148
|
+
|
149
|
+
6. Trademarks. This License does not grant permission to use the trade
|
150
|
+
names, trademarks, service marks, or product names of the Licensor,
|
151
|
+
except as required for reasonable and customary use in describing the
|
152
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
153
|
+
|
154
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
155
|
+
agreed to in writing, Licensor provides the Work (and each
|
156
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
157
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
158
|
+
implied, including, without limitation, any warranties or conditions
|
159
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
160
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
161
|
+
appropriateness of using or redistributing the Work and assume any
|
162
|
+
risks associated with Your exercise of permissions under this License.
|
163
|
+
|
164
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
165
|
+
whether in tort (including negligence), contract, or otherwise,
|
166
|
+
unless required by applicable law (such as deliberate and grossly
|
167
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
168
|
+
liable to You for damages, including any direct, indirect, special,
|
169
|
+
incidental, or consequential damages of any character arising as a
|
170
|
+
result of this License or out of the use or inability to use the
|
171
|
+
Work (including but not limited to damages for loss of goodwill,
|
172
|
+
work stoppage, computer failure or malfunction, or any and all
|
173
|
+
other commercial damages or losses), even if such Contributor
|
174
|
+
has been advised of the possibility of such damages.
|
175
|
+
|
176
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
177
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
178
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
179
|
+
or other liability obligations and/or rights consistent with this
|
180
|
+
License. However, in accepting such obligations, You may act only
|
181
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
182
|
+
of any other Contributor, and only if You agree to indemnify,
|
183
|
+
defend, and hold each Contributor harmless for any liability
|
184
|
+
incurred by, or claims asserted against, such Contributor by reason
|
185
|
+
of your accepting any such warranty or additional liability.
|
186
|
+
|
187
|
+
END OF TERMS AND CONDITIONS
|
188
|
+
|
189
|
+
APPENDIX: How to apply the Apache License to your work.
|
190
|
+
|
191
|
+
To apply the Apache License to your work, attach the following
|
192
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
193
|
+
replaced with your own identifying information. (Don't include
|
194
|
+
the brackets!) The text should be enclosed in the appropriate
|
195
|
+
comment syntax for the file format. We also recommend that a
|
196
|
+
file or class name and description of purpose be included on the
|
197
|
+
same "printed page" as the copyright notice for easier
|
198
|
+
identification within third-party archives.
|
199
|
+
|
200
|
+
Copyright [yyyy] [name of copyright owner]
|
201
|
+
|
202
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
203
|
+
you may not use this file except in compliance with the License.
|
204
|
+
You may obtain a copy of the License at
|
205
|
+
|
206
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
207
|
+
|
208
|
+
Unless required by applicable law or agreed to in writing, software
|
209
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
210
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
211
|
+
See the License for the specific language governing permissions and
|
212
|
+
limitations under the License.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# Redux
|
2
|
+
|
3
|
+
A gem to help navigate the Redux API's and to screen scrape where an API does
|
4
|
+
not exist.
|
5
|
+
|
6
|
+
If you're reading this and you're not a BBC developer or authorised contractor
|
7
|
+
then it probably won't make much sense.
|
8
|
+
|
9
|
+
BBC Snippets and BBC Redux are tools designed to allow BBC staff to develop new
|
10
|
+
ways to view and navigate content. As such, they're not open to the public.
|
11
|
+
|
12
|
+
If you've been contracted by the BBC to do work in this area please feel free
|
13
|
+
to message us.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
### Bundler
|
18
|
+
|
19
|
+
gem 'bbc_redux'
|
20
|
+
|
21
|
+
### RubyGems
|
22
|
+
|
23
|
+
gem install bbc_redux
|
24
|
+
|
25
|
+
## Quick Start
|
26
|
+
|
27
|
+
require 'bbc/redux'
|
28
|
+
|
29
|
+
# Login
|
30
|
+
|
31
|
+
client = BBC::Redux::Client.new({
|
32
|
+
:username => 'username',
|
33
|
+
:password => 'password',
|
34
|
+
})
|
35
|
+
|
36
|
+
# User data
|
37
|
+
|
38
|
+
user = client.user
|
39
|
+
|
40
|
+
user.can_invite? #=> Boolean
|
41
|
+
user.created #=> DateTime
|
42
|
+
user.email #=> String
|
43
|
+
user.first_name #=> String
|
44
|
+
user.id #=> Integer
|
45
|
+
user.last_name #=> String
|
46
|
+
user.username #=> String
|
47
|
+
user.uuid #=> String
|
48
|
+
|
49
|
+
# Available Channels
|
50
|
+
|
51
|
+
client.channels #=> Array<BBC::Redux::Channel>
|
52
|
+
|
53
|
+
# Asset data
|
54
|
+
|
55
|
+
asset = client.asset('5966413090093319525')
|
56
|
+
|
57
|
+
asset.channel #=> BBC::Redux::Channel
|
58
|
+
asset.description #=> String
|
59
|
+
asset.duration #=> Integer
|
60
|
+
asset.key #=> BBC::Redux::Key
|
61
|
+
asset.name #=> String
|
62
|
+
asset.reference #=> String
|
63
|
+
asset.start #=> DateTime
|
64
|
+
asset.uuid #=> String
|
65
|
+
|
66
|
+
# Media file urls ...
|
67
|
+
|
68
|
+
# These are wrappers around an http url, each url is valid for 24 hours and
|
69
|
+
# can be used without a session token
|
70
|
+
|
71
|
+
asset.dvbsubs_url #=> BBC::Redux::MediaUrl
|
72
|
+
asset.flv_url #=> BBC::Redux::MediaUrl
|
73
|
+
asset.h264_hi_url #=> BBC::Redux::MediaUrl
|
74
|
+
asset.h264_lo_url #=> BBC::Redux::MediaUrl
|
75
|
+
asset.mp3_url #=> BBC::Redux::MediaUrl
|
76
|
+
asset.ts_url #=> BBC::Redux::MediaUrl
|
77
|
+
asset.ts_stripped_url #=> BBC::Redux::MediaUrl
|
78
|
+
|
79
|
+
# URL helper methods
|
80
|
+
|
81
|
+
url = asset.mp3_url
|
82
|
+
|
83
|
+
url.expired? #=> Boolean
|
84
|
+
url.expires_at #=> DateTime
|
85
|
+
url.live? #=> Boolean
|
86
|
+
url.ttl #=> Integer
|
87
|
+
url.end_point #=> String
|
88
|
+
|
89
|
+
# Generate an HTTP URL with a different filename
|
90
|
+
|
91
|
+
url.end_point('myfile.mp3') #=> String
|
92
|
+
|
93
|
+
# Download a file
|
94
|
+
response = redux.http.get(url.end_point)
|
95
|
+
|
96
|
+
# Do something with response
|
97
|
+
response.code # 200 (you can but hope!)
|
98
|
+
response.headers # Hash
|
99
|
+
response.body # Your file or string
|
100
|
+
|
101
|
+
# Get schedule
|
102
|
+
client.schedule(Date.today).each do |asset|
|
103
|
+
p asset.reference
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get a schedule for specific channels
|
107
|
+
schedule = client.schedule(Date.today, [ 'bbcone', 'bbctwo' ])
|
108
|
+
|
109
|
+
# Search
|
110
|
+
|
111
|
+
results = client.search(:name => 'Pingu')
|
112
|
+
|
113
|
+
results.created_at #=> DateTime
|
114
|
+
results.query #=> Hash
|
115
|
+
results.query_time #=> Float
|
116
|
+
results.assets #=> Array<BBC::Redux::Asset>
|
117
|
+
results.total #=> Integer
|
118
|
+
results.total_returned #=> Integer
|
119
|
+
results.has_more? #=> Boolean
|
120
|
+
|
121
|
+
# Iterating all search results
|
122
|
+
|
123
|
+
results = redux_client.search(:name => 'Pingu', :offset => 0)
|
124
|
+
|
125
|
+
while true do
|
126
|
+
results.assets.each do |asset|
|
127
|
+
puts asset.name
|
128
|
+
end
|
129
|
+
|
130
|
+
if results.has_more?
|
131
|
+
next_query = results.query.merge({
|
132
|
+
:offset => results.query[:offset] + 10
|
133
|
+
})
|
134
|
+
|
135
|
+
results = redux_client.search(next_query)
|
136
|
+
else
|
137
|
+
break
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Remembering to logout whe your done
|
142
|
+
|
143
|
+
client.logout
|
144
|
+
|
145
|
+
## Documentation
|
146
|
+
|
147
|
+
Please see the ruby docs for full project documentation:
|
148
|
+
|
149
|
+
http://rubydoc.info/github/bbcsnippets/redux-client-ruby/version-4/frames
|
150
|
+
|
151
|
+
## Caveats / Known Issues
|
152
|
+
|
153
|
+
### Using a proxy server
|
154
|
+
|
155
|
+
The client uses [Typhoeus](https://github.com/dbalatero/typhoeus) which
|
156
|
+
respects the `http_proxy` environment variable
|
157
|
+
|
158
|
+
### "Your account has been comprimised"
|
159
|
+
|
160
|
+
You might get your account locked if you repeatedly login, especially from
|
161
|
+
multiple IP's. To be on the safe side you should reuse the `token` assigned to
|
162
|
+
a client.
|
163
|
+
|
164
|
+
Also, always remember to use `client.logout` when you are finished.
|
165
|
+
|
166
|
+
## Development
|
167
|
+
|
168
|
+
Please send new code in the form of a pull requests with tests. Run the current
|
169
|
+
test suite with ...
|
170
|
+
|
171
|
+
rake coverage # Generate code coverage report
|
172
|
+
rake doc # Gennerate docs
|
173
|
+
rake integration # Runs spec/integration/*_spec.rb - actually connects to redux
|
174
|
+
rake spec # Runs spec/**/*_spec.rb
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Test Tasks
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.pattern = FileList['spec/bbc/**/*_spec.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Run integration tests (requires redux login)'
|
13
|
+
RSpec::Core::RakeTask.new(:integration) do |spec|
|
14
|
+
spec.pattern = FileList['spec/integration/**/*_spec.rb']
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Open coverage report'
|
18
|
+
task :coverage do
|
19
|
+
sh 'open coverage/index.html'
|
20
|
+
end
|
21
|
+
|
22
|
+
################################################################################
|
23
|
+
# Documentation Tasks
|
24
|
+
|
25
|
+
require 'yard'
|
26
|
+
|
27
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
28
|
+
t.files = [ 'lib/bbc/**/*.rb' ]
|
29
|
+
t.options = [
|
30
|
+
'--no-private',
|
31
|
+
'--output-dir', 'docs/yard',
|
32
|
+
'--readme', 'README.md'
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
################################################################################
|
37
|
+
# Gem building Tasks
|
38
|
+
|
39
|
+
namespace :gem do
|
40
|
+
|
41
|
+
desc 'Build gem file'
|
42
|
+
task :build do
|
43
|
+
sh 'bundle exec gem build bbc_redux.gemspec'
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
data/bbc_redux.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$: << File.join( File.dirname(__FILE__), 'lib' )
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
require 'bbc/redux/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
|
10
|
+
# Meta data
|
11
|
+
|
12
|
+
gem.name = 'bbc_redux'
|
13
|
+
gem.version = BBC::Redux::VERSION
|
14
|
+
gem.summary = 'A Ruby client for BBC Redux',
|
15
|
+
gem.description = 'A gem to help navigate the BBC Redux API'
|
16
|
+
gem.homepage = 'https://www.bbcredux.com'
|
17
|
+
gem.license = 'Apache'
|
18
|
+
|
19
|
+
gem.authors = [
|
20
|
+
'JamesHarrison',
|
21
|
+
'andhapp',
|
22
|
+
'matth'
|
23
|
+
]
|
24
|
+
|
25
|
+
gem.email = [
|
26
|
+
'james.harrison@bbc.co.uk',
|
27
|
+
'matt.haynes@bbc.co.uk'
|
28
|
+
]
|
29
|
+
|
30
|
+
# Files / paths
|
31
|
+
|
32
|
+
gem.files = FileList[
|
33
|
+
'AUTHORS',
|
34
|
+
'COPYING',
|
35
|
+
'Gemfile',
|
36
|
+
'README.md',
|
37
|
+
'Rakefile',
|
38
|
+
'bbc_redux.gemspec',
|
39
|
+
'lib/**/*'
|
40
|
+
]
|
41
|
+
|
42
|
+
gem.test_files = FileList[ 'spec/**/*' ]
|
43
|
+
|
44
|
+
gem.require_paths = [ 'lib' ]
|
45
|
+
|
46
|
+
# Development dependencies
|
47
|
+
|
48
|
+
gem.add_development_dependency 'rspec'
|
49
|
+
gem.add_development_dependency 'rspec-its'
|
50
|
+
gem.add_development_dependency 'simplecov', '>= 0.8.2'
|
51
|
+
gem.add_development_dependency 'yard'
|
52
|
+
|
53
|
+
# Runtime dependencies
|
54
|
+
|
55
|
+
gem.add_dependency 'nokogiri'
|
56
|
+
gem.add_dependency 'representable'
|
57
|
+
gem.add_dependency 'typhoeus', '>= 0.6.8'
|
58
|
+
gem.add_dependency 'virtus', '>= 0.5.0'
|
59
|
+
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
require_relative 'channel'
|
3
|
+
require_relative 'key'
|
4
|
+
require_relative 'media_url'
|
5
|
+
|
6
|
+
module BBC
|
7
|
+
module Redux
|
8
|
+
|
9
|
+
# Redux API Asset Object
|
10
|
+
#
|
11
|
+
# @example Properties of the asset object
|
12
|
+
#
|
13
|
+
# asset = redux_client.asset('5966413090093319525')
|
14
|
+
#
|
15
|
+
# asset.channel #=> BBC::Redux::Channel
|
16
|
+
# asset.description #=> String
|
17
|
+
# asset.duration #=> Integer
|
18
|
+
# asset.key #=> BBC::Redux::Key
|
19
|
+
# asset.name #=> String
|
20
|
+
# asset.reference #=> String
|
21
|
+
# asset.start #=> DateTime
|
22
|
+
# asset.uuid #=> String
|
23
|
+
#
|
24
|
+
# @example Generating urls for the asset's associated media files
|
25
|
+
#
|
26
|
+
# asset.dvbsubs_url #=> BBC::Redux::MediaUrl
|
27
|
+
# asset.flv_url #=> BBC::Redux::MediaUrl
|
28
|
+
# asset.h264_hi_url #=> BBC::Redux::MediaUrl
|
29
|
+
# asset.h264_lo_url #=> BBC::Redux::MediaUrl
|
30
|
+
# asset.mp3_url #=> BBC::Redux::MediaUrl
|
31
|
+
# asset.ts_url #=> BBC::Redux::MediaUrl
|
32
|
+
# asset.ts_stripped_url #=> BBC::Redux::MediaUrl
|
33
|
+
#
|
34
|
+
# @author Matt Haynes <matt.haynes@bbc.co.uk>
|
35
|
+
class Asset
|
36
|
+
|
37
|
+
include Virtus.value_object
|
38
|
+
|
39
|
+
# @!attribute [r] channel
|
40
|
+
# @return [Channel] the asset's channel
|
41
|
+
attribute :channel, BBC::Redux::Channel
|
42
|
+
|
43
|
+
# @!attribute [r] description
|
44
|
+
# @return [String] the asset's description
|
45
|
+
attribute :description, String
|
46
|
+
|
47
|
+
# @!attribute [r] duration
|
48
|
+
# @return [Integer] the asset's duration in seconds
|
49
|
+
attribute :duration, Integer
|
50
|
+
|
51
|
+
# @private
|
52
|
+
# @!attribute [r] access_key
|
53
|
+
# @return [String] the asset's access key
|
54
|
+
attribute :access_key, String
|
55
|
+
|
56
|
+
# @!attribute [r] start
|
57
|
+
# @return [DateTime] the asset's start date / time. Generally schedule
|
58
|
+
# time
|
59
|
+
attribute :start, DateTime
|
60
|
+
|
61
|
+
# @!attribute [r] reference
|
62
|
+
# @return [String] the asset's disk reference
|
63
|
+
attribute :reference, String
|
64
|
+
|
65
|
+
alias :disk_reference :reference
|
66
|
+
|
67
|
+
# @!attribute [r] name
|
68
|
+
# @return [String] the asset's name / title
|
69
|
+
attribute :name, String
|
70
|
+
|
71
|
+
alias :title :name
|
72
|
+
|
73
|
+
# @!attribute [r] uuid
|
74
|
+
# @return [String] the user's uuid
|
75
|
+
attribute :uuid, String
|
76
|
+
|
77
|
+
# @!attribute [r] key
|
78
|
+
# @return [Key] the asset's access key object
|
79
|
+
def key
|
80
|
+
@key ||= Key.new(access_key)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def self.has_media_url(type)
|
86
|
+
define_method(:"#{type}_url") do
|
87
|
+
MediaUrl.new(reference, type, key)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
public
|
92
|
+
|
93
|
+
# @!macro [new] has_media_url
|
94
|
+
# @!attribute [r] $1_url
|
95
|
+
# @return [BBC::Redux::MediaUrl] a media url for the $1 file
|
96
|
+
has_media_url :dvbsubs
|
97
|
+
|
98
|
+
# @macro has_media_url
|
99
|
+
has_media_url :flv
|
100
|
+
|
101
|
+
# @macro has_media_url
|
102
|
+
has_media_url :h264_hi
|
103
|
+
|
104
|
+
# @macro has_media_url
|
105
|
+
has_media_url :h264_lo
|
106
|
+
|
107
|
+
# @macro has_media_url
|
108
|
+
has_media_url :mp3
|
109
|
+
|
110
|
+
# @macro has_media_url
|
111
|
+
has_media_url :ts
|
112
|
+
|
113
|
+
# @macro has_media_url
|
114
|
+
has_media_url :ts_stripped
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
3
|
+
module BBC
|
4
|
+
module Redux
|
5
|
+
|
6
|
+
# Redux API Channel Object
|
7
|
+
#
|
8
|
+
# @example Properties of the channel object
|
9
|
+
#
|
10
|
+
# channel = redux_client.channels.first
|
11
|
+
#
|
12
|
+
# channel.category_id #=> Integer
|
13
|
+
# channel.display_name #=> String
|
14
|
+
# channel.name #=> String
|
15
|
+
# channel.sort_order #=> Integer
|
16
|
+
#
|
17
|
+
# @author Matt Haynes <matt.haynes@bbc.co.uk>
|
18
|
+
class Channel
|
19
|
+
|
20
|
+
include Virtus.value_object
|
21
|
+
|
22
|
+
# @!attribute [r] category_id
|
23
|
+
# @return [Integer] channel's category id
|
24
|
+
attribute :category_id, Integer
|
25
|
+
|
26
|
+
# @!attribute [r] display_name
|
27
|
+
# @return [String] channel display name, e.g. 'BBC One'
|
28
|
+
attribute :display_name, String
|
29
|
+
|
30
|
+
alias :longname :display_name
|
31
|
+
|
32
|
+
# @!attribute [r] name
|
33
|
+
# @return [String] channel short name, e.g. 'bbcone'
|
34
|
+
attribute :name, String
|
35
|
+
|
36
|
+
# @!attribute [r] sortorder
|
37
|
+
# @return [Integer] channel's suggested sort order in list views
|
38
|
+
attribute :sortorder, Integer
|
39
|
+
|
40
|
+
alias :sort_order :sortorder
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|