wcc-media-client 0.4.8 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/wcc/media/cacheable.rb +9 -0
- data/lib/wcc/media/client.rb +6 -3
- data/lib/wcc/media/client/response.rb +1 -1
- data/lib/wcc/media/engine.rb +12 -4
- data/lib/wcc/media/live_stream.rb +48 -0
- data/lib/wcc/media/message.rb +15 -1
- data/lib/wcc/media/series.rb +1 -0
- data/lib/wcc/media/version.rb +1 -1
- data/wcc-media-client.gemspec +1 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5267da3904b4c03dcd2806653a5416dc8c2be9b
|
4
|
+
data.tar.gz: a8ff4629d184ecdcfe7a946df52ab1b4ced3e92b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5bbf278905e91d9f8937a83ebd9af3a18de8ae7a8b7078675b505d1e76403feddb648316db8f8f8f50cd593f10aec7847bd5ef4988f28b8a1e13b971f184534
|
7
|
+
data.tar.gz: 1b857617295dfb1e684ae58f8a7fcd4f7f6616ad785c0b3b810fa7769e7db5e64e1eb24e1bff336fb2b906e004e0110fff437a2314b6f9f5a19b23b98c27a68e
|
data/.rubocop.yml
CHANGED
data/lib/wcc/media/cacheable.rb
CHANGED
@@ -10,6 +10,15 @@ module WCC
|
|
10
10
|
@cache_key = "#{self.class.name}/#{key}"
|
11
11
|
end
|
12
12
|
|
13
|
+
def last_modified
|
14
|
+
return @last_modified if @last_modified
|
15
|
+
|
16
|
+
last_modified =
|
17
|
+
(headers&.fetch('Last-Modified', nil) if respond_to?(:headers))
|
18
|
+
@last_modified = Time.parse(last_modified) if last_modified && /\S/.match(last_modified)
|
19
|
+
end
|
20
|
+
alias_method :updated_at, :last_modified
|
21
|
+
|
13
22
|
def self.hash_cache_key(hash)
|
14
23
|
Digest::SHA1.hexdigest(Marshal.dump(hash))
|
15
24
|
end
|
data/lib/wcc/media/client.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'series'
|
|
4
4
|
require_relative 'speaker'
|
5
5
|
require_relative 'tag'
|
6
6
|
require_relative 'playlist'
|
7
|
+
require_relative 'live_stream'
|
7
8
|
require_relative 'client/response'
|
8
9
|
|
9
10
|
module WCC
|
@@ -35,7 +36,8 @@ module WCC
|
|
35
36
|
'series' => WCC::Media::Series,
|
36
37
|
'speakers' => WCC::Media::Speaker,
|
37
38
|
'tags' => WCC::Media::Tag,
|
38
|
-
'playlists' => WCC::Media::Playlist
|
39
|
+
'playlists' => WCC::Media::Playlist,
|
40
|
+
'streams' => WCC::Media::LiveStream
|
39
41
|
}.freeze
|
40
42
|
attr_reader(*RESOURCES.keys)
|
41
43
|
|
@@ -44,7 +46,8 @@ module WCC
|
|
44
46
|
def initialize(**options)
|
45
47
|
options = {
|
46
48
|
api_url: 'https://media.watermark.org/api/v1/',
|
47
|
-
response_class: Response
|
49
|
+
response_class: Response,
|
50
|
+
adapter: :typhoeus
|
48
51
|
}.merge!(options)
|
49
52
|
super(**options)
|
50
53
|
|
@@ -60,7 +63,7 @@ module WCC
|
|
60
63
|
|
61
64
|
resp = client.get(
|
62
65
|
"#{model.endpoint}/#{id}",
|
63
|
-
default_params('target').merge(params)
|
66
|
+
default_params('target').merge(params),
|
64
67
|
)
|
65
68
|
resp.assert_ok!
|
66
69
|
model.new(resp.body[model.key], resp.headers.freeze)
|
data/lib/wcc/media/engine.rb
CHANGED
@@ -59,10 +59,18 @@ class WCC::Media::Engine < ::Rails::Engine
|
|
59
59
|
|
60
60
|
initializer 'configure WCC::Media Toots' do
|
61
61
|
ActiveSupport::Notifications.subscribe 'routes_loaded.engine.media.wcc' do
|
62
|
-
::Toot.config.callback_url ||=
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
::Toot.config.callback_url ||=
|
63
|
+
begin
|
64
|
+
Rails.application.routes.url_helpers.wcc_media_url + '/callbacks'
|
65
|
+
rescue ArgumentError => ex
|
66
|
+
raise unless ex.message =~ /^Missing host to link to/
|
67
|
+
end
|
68
|
+
|
69
|
+
if ::Toot.config.callback_url.nil?
|
70
|
+
Rails.logger.error "Toot.config.callback_url not set! Media webhooks will not be subscribed."
|
71
|
+
else
|
72
|
+
WCC::Media::Engine.register_subscriptions
|
73
|
+
end
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class WCC::Media::LiveStream < WCC::Media::Base
|
4
|
+
active_record_shim do
|
5
|
+
endpoint 'streams'
|
6
|
+
key 'stream'
|
7
|
+
filters %w[
|
8
|
+
].freeze
|
9
|
+
end
|
10
|
+
|
11
|
+
%w[
|
12
|
+
title
|
13
|
+
description
|
14
|
+
].each do |att|
|
15
|
+
define_method att do
|
16
|
+
raw[att]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
%w[
|
21
|
+
current_event
|
22
|
+
next_event
|
23
|
+
].each do |att|
|
24
|
+
define_method att do
|
25
|
+
Event.new(raw[att]) if raw[att]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def active?
|
30
|
+
current_event.present?
|
31
|
+
end
|
32
|
+
|
33
|
+
class Event < WCC::Media::Base
|
34
|
+
%w[
|
35
|
+
title
|
36
|
+
description
|
37
|
+
embed_code
|
38
|
+
stream_url
|
39
|
+
starts_at
|
40
|
+
ends_at
|
41
|
+
duration
|
42
|
+
].each do |att|
|
43
|
+
define_method att do
|
44
|
+
raw[att]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/wcc/media/message.rb
CHANGED
@@ -8,6 +8,7 @@ class WCC::Media::Message < WCC::Media::Base
|
|
8
8
|
on_or_after_date
|
9
9
|
on_or_before_date
|
10
10
|
tag_id
|
11
|
+
playlist_id
|
11
12
|
speaker_id
|
12
13
|
scripture_book_id
|
13
14
|
series_id
|
@@ -37,6 +38,10 @@ class WCC::Media::Message < WCC::Media::Base
|
|
37
38
|
(raw['speakers'] || []).map { |val| WCC::Media::Speaker.new(val) }
|
38
39
|
end
|
39
40
|
|
41
|
+
def playlists
|
42
|
+
(raw['playlists'] || []).map { |val| WCC::Media::Playlist.new(val) }
|
43
|
+
end
|
44
|
+
|
40
45
|
def tags
|
41
46
|
(raw['tags'] || []).map { |val| WCC::Media::Tag.new(val) }
|
42
47
|
end
|
@@ -76,12 +81,21 @@ class WCC::Media::Message < WCC::Media::Base
|
|
76
81
|
.any? { |k, v| /video/.match(k) && v && !v.empty? }
|
77
82
|
end
|
78
83
|
|
84
|
+
def has_audio? # rubocop:disable Naming/PredicateName
|
85
|
+
assets.each_pair
|
86
|
+
.any? { |k, v| /^audio/.match(k) && v && !v.empty? }
|
87
|
+
end
|
88
|
+
|
79
89
|
def to_param
|
80
90
|
"#{id}-#{slug}"
|
81
91
|
end
|
82
92
|
|
83
93
|
WCC::Media::TagGroup.all.each do |tag_group|
|
84
|
-
|
94
|
+
method_name = tag_group.name.downcase.to_sym
|
95
|
+
# except :meta (different definition above)
|
96
|
+
next if instance_methods.include?(method_name)
|
97
|
+
|
98
|
+
define_method(method_name) do
|
85
99
|
tags.select { |t| t.tag_group == tag_group }
|
86
100
|
end
|
87
101
|
end
|
data/lib/wcc/media/series.rb
CHANGED
data/lib/wcc/media/version.rb
CHANGED
data/wcc-media-client.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'guard-rubocop', '~> 1.3'
|
36
36
|
spec.add_development_dependency 'http', '> 1.0', '< 3.0'
|
37
37
|
spec.add_development_dependency 'httplog', '~> 1.0'
|
38
|
+
spec.add_development_dependency 'nio4r', '2.5.2'
|
38
39
|
spec.add_development_dependency 'rails', '~> 5.0'
|
39
40
|
spec.add_development_dependency 'rake', '~> 12.3'
|
40
41
|
spec.add_development_dependency 'responders', '< 3.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-media-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wcc-api
|
@@ -156,6 +156,20 @@ dependencies:
|
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '1.0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: nio4r
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 2.5.2
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - '='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 2.5.2
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: rails
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -357,6 +371,7 @@ files:
|
|
357
371
|
- lib/wcc/media/client.rb
|
358
372
|
- lib/wcc/media/client/response.rb
|
359
373
|
- lib/wcc/media/engine.rb
|
374
|
+
- lib/wcc/media/live_stream.rb
|
360
375
|
- lib/wcc/media/message.rb
|
361
376
|
- lib/wcc/media/playlist.rb
|
362
377
|
- lib/wcc/media/rails.rb
|
@@ -371,7 +386,7 @@ homepage: https://github.com/watermarkchurch/media/wcc-media-client
|
|
371
386
|
licenses:
|
372
387
|
- MIT
|
373
388
|
metadata: {}
|
374
|
-
post_install_message:
|
389
|
+
post_install_message:
|
375
390
|
rdoc_options: []
|
376
391
|
require_paths:
|
377
392
|
- lib
|
@@ -386,9 +401,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
401
|
- !ruby/object:Gem::Version
|
387
402
|
version: '0'
|
388
403
|
requirements: []
|
389
|
-
rubyforge_project:
|
404
|
+
rubyforge_project:
|
390
405
|
rubygems_version: 2.5.2
|
391
|
-
signing_key:
|
406
|
+
signing_key:
|
392
407
|
specification_version: 4
|
393
408
|
summary: ''
|
394
409
|
test_files: []
|