awslive-inputlooper 0.2.0 → 0.2.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a808cc52ee361a7bad8e992f5b986e1d6bd7ad9106d0a4a99983e4d75173ba62
|
4
|
+
data.tar.gz: 6afc3d0c102de956d418bd8a4e9ab0c732abc0d615d82f4a2499547ec5b6b376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76344f3ac9c93b5637fd0ec24aba60a7c1fc815eff27927957b7d3c0fcb39852de05f0bc2e738cd7ac0f8aa7a6c4b61eab7a0589975363fe2df7148c7cbcb3b0
|
7
|
+
data.tar.gz: 4abb1f5ac234ce5768b0bc7d12c64134988be068f8018db611425ef2165c6d4d85fa30370577698eb9a06de64fb47acce51cb06ebcf629359b98fd129cd7be67
|
@@ -32,6 +32,7 @@ module Awslive
|
|
32
32
|
@channel_id = channel_id
|
33
33
|
@playlist = playlist
|
34
34
|
@loop_thread = nil
|
35
|
+
set_log_flag(true)
|
35
36
|
end
|
36
37
|
|
37
38
|
def switch_and_loop_playlist(playlist, sleep_time = nil)
|
@@ -73,7 +74,7 @@ module Awslive
|
|
73
74
|
return playlist_loop_alive
|
74
75
|
end
|
75
76
|
|
76
|
-
def switch_input(force_immed = nil, exclude_query_param = nil)
|
77
|
+
def switch_input(force_immed = nil, exclude_query_param = nil, loopback = nil)
|
77
78
|
# Fetching the channel information every time to know the state of the channel and input in pipeline.
|
78
79
|
channel_info = get_channel_info
|
79
80
|
channel_state = channel_info[:state]
|
@@ -102,14 +103,20 @@ module Awslive
|
|
102
103
|
end
|
103
104
|
|
104
105
|
follow_schedule = @scheduler.get_follow_schedule(@channel_id, current_input_action_name)
|
106
|
+
log( "Follow Schedule => #{follow_schedule}")
|
105
107
|
current_url = @scheduler.get_action_url(@channel_id, current_input_action_name)
|
106
|
-
log(
|
108
|
+
log("Current URL => #{current_url}")
|
109
|
+
next_file = identify_next_input(current_url, exclude_query_param, loopback )
|
110
|
+
log("Next URL => #{next_file}")
|
111
|
+
if next_file.nil? && follow_schedule.nil? && !loopback
|
112
|
+
log ("end of playlist and loopback not enabled!!")
|
113
|
+
return
|
114
|
+
end
|
115
|
+
log( "current URL #{current_url} next URL #{next_file}")
|
107
116
|
unless follow_schedule.nil?
|
108
117
|
follow_url = @scheduler.get_follow_action_url(@channel_id, current_input_action_name)
|
109
118
|
log("Follow URL #{follow_url}")
|
110
|
-
next_file
|
111
|
-
log( "Next URL #{next_file}")
|
112
|
-
if !follow_url[0].nil? && next_file != follow_url[0]
|
119
|
+
if !follow_url[0].nil? && next_file.split('?')[0] != follow_url[0].split('?')[0]
|
113
120
|
log( "Playlist seems to be changed, hence aligning.")
|
114
121
|
@scheduler.delete( @channel_id,[ "#{follow_schedule[:action_name]}"])
|
115
122
|
next_input_name = dynamic_input[:input_attachment_name]
|
@@ -125,7 +132,7 @@ module Awslive
|
|
125
132
|
end
|
126
133
|
else
|
127
134
|
log("No follow Schedule!")
|
128
|
-
next_file = identify_next_input(current_url, exclude_query_param)
|
135
|
+
#next_file = identify_next_input(current_url, exclude_query_param)
|
129
136
|
unless next_file.nil?
|
130
137
|
next_input_name = dynamic_input[:input_attachment_name]
|
131
138
|
log( "Next input Name #{next_input_name} #{next_file}")
|
@@ -142,18 +149,59 @@ module Awslive
|
|
142
149
|
end
|
143
150
|
end
|
144
151
|
|
145
|
-
def
|
152
|
+
def is_url_duplicated(url)
|
153
|
+
match_count = 0
|
154
|
+
is_duplicated = false
|
155
|
+
@playlist.each_with_index do | playlist_file, index |
|
156
|
+
playlist_file = playlist_file.split('?')[0]
|
157
|
+
if playlist_file == url.split('?')[0]
|
158
|
+
match_count = match_count + 1
|
159
|
+
end
|
160
|
+
if match_count >= 2
|
161
|
+
is_duplicated = true
|
162
|
+
break
|
163
|
+
end
|
164
|
+
end
|
165
|
+
is_duplicated
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_order(url)
|
169
|
+
puts "URL => #{url}"
|
170
|
+
order = nil
|
171
|
+
if !url.nil?
|
172
|
+
uri = URI.parse(url) rescue nil
|
173
|
+
params = CGI.parse(uri.query) unless uri.nil?
|
174
|
+
if !params.nil?
|
175
|
+
order = params["order"].first rescue nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
order
|
179
|
+
end
|
180
|
+
|
181
|
+
def identify_next_input(file_url, exclude_query_param, loopback = true)
|
146
182
|
next_file = @playlist[0]
|
147
183
|
#puts " File Url #{file_url}"
|
148
184
|
if !file_url.nil? && !file_url[0].nil?
|
185
|
+
is_duplicated = is_url_duplicated(file_url[0])
|
186
|
+
log( "URL Duplicate => #{is_duplicated}")
|
149
187
|
@playlist.each_with_index do | playlist_file, index |
|
150
188
|
#puts "next file identification #{playlist_file} #{file_url[0]} #{index}"
|
151
|
-
if !exclude_query_param.nil?
|
189
|
+
if !exclude_query_param.nil? && !is_duplicated
|
152
190
|
playlist_file = playlist_file.split('?')[0]
|
153
191
|
file_url[0] = file_url[0].split('?')[0]
|
154
192
|
end
|
155
193
|
if playlist_file == file_url[0]
|
194
|
+
if is_duplicated
|
195
|
+
p_order = get_order(playlist_file)
|
196
|
+
c_order = get_order(file_url[0])
|
197
|
+
puts "playlist Order #{p_order} : current order #{c_order}"
|
198
|
+
end
|
199
|
+
next if is_duplicated && !p_order.nil? && !c_order.nil? && p_order != c_order
|
156
200
|
if index == (@playlist.length - 1)
|
201
|
+
if !loopback
|
202
|
+
next_file = nil
|
203
|
+
break
|
204
|
+
end
|
157
205
|
next_file = @playlist[0]
|
158
206
|
else
|
159
207
|
next_file = @playlist[index + 1]
|
@@ -41,7 +41,6 @@ module Awslive
|
|
41
41
|
def get_follow_schedule_action(follow_input, trigger_input, urlpath = nil)
|
42
42
|
action_hash = FOLLOW_HASH.clone
|
43
43
|
action_hash[:action_name] = "#{get_action_id}"
|
44
|
-
puts "action hash #{action_hash}"
|
45
44
|
action_hash[:schedule_action_start_settings][:follow_mode_schedule_action_start_settings][:reference_action_name] = "#{follow_input}"
|
46
45
|
action_hash[:schedule_action_settings][:input_switch_settings][:input_attachment_name_reference] = "#{trigger_input}"
|
47
46
|
action_hash[:schedule_action_settings][:input_switch_settings][:url_path] = [ urlpath ] unless urlpath.nil?
|
@@ -46,6 +46,7 @@ module Awslive
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_follow_schedule(channel_id, action_name)
|
49
|
+
puts "Follow for action Name : #{action_name}"
|
49
50
|
follow_schedule = nil
|
50
51
|
response = @mediaclient.describe_schedule({channel_id: "#{channel_id}", max_results: 100 } )
|
51
52
|
loop do
|
@@ -53,6 +54,11 @@ module Awslive
|
|
53
54
|
unless schedule_action[:schedule_action_start_settings][:follow_mode_schedule_action_start_settings].nil?
|
54
55
|
# This is follow action
|
55
56
|
if schedule_action[:schedule_action_start_settings][:follow_mode_schedule_action_start_settings][:reference_action_name] == action_name
|
57
|
+
# Identifying only the input switch follow action for right follow up! as it provides SCTE35 follow up as well.
|
58
|
+
puts "Scheduled Action #{schedule_action}"
|
59
|
+
if schedule_action[:schedule_action_settings][:input_switch_settings].nil?
|
60
|
+
next
|
61
|
+
end
|
56
62
|
follow_schedule = schedule_action
|
57
63
|
break
|
58
64
|
end
|
@@ -94,7 +100,7 @@ module Awslive
|
|
94
100
|
scheduled_action << @input_switch_schedule_action.get_follow_schedule_action(data[:follow_input], data[:trigger_input], data[:url_path])
|
95
101
|
type, duration = get_type_duration(data[:url_path])
|
96
102
|
if !type.nil? && !duration.nil? && type == "ad_marker"
|
97
|
-
puts "
|
103
|
+
puts "ad marker provisioned for duration => #{duration}"
|
98
104
|
ad_scheduled_action << @ad_marker_schedule_action.get_follow_schedule_action(data[:follow_input], duration.to_i)
|
99
105
|
end
|
100
106
|
end
|
@@ -148,7 +154,6 @@ module Awslive
|
|
148
154
|
def get_action_url(channel_id, action_name)
|
149
155
|
url = nil
|
150
156
|
follow_schedule = get_scheudle_action(channel_id, action_name)
|
151
|
-
puts "Follow Schedule #{follow_schedule}"
|
152
157
|
url = follow_schedule[:schedule_action_settings][:input_switch_settings][:url_path] unless follow_schedule.nil?
|
153
158
|
url
|
154
159
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awslive-inputlooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maheshwaran G
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|