Skip to content

Commit 7ead9a9

Browse files
committed
upload full recitation segments too
1 parent bed2545 commit 7ead9a9

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/audio_segment/tarteel.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def export_gapless_recitation_segments(recitation, target_dir)
162162
.includes(:verse)
163163

164164
grouped = segments.group_by(&:chapter_id)
165+
all_segments = {}
166+
uploader = UploadToCdn.new
165167

166168
grouped.each do |chapter_id, segs|
167169
json_ayahs = []
@@ -204,12 +206,22 @@ def export_gapless_recitation_segments(recitation, target_dir)
204206
f.write(JSON.dump(json_ayahs))
205207
end
206208

207-
uploader = UploadToCdn.new
208-
key = "audio/gapless/#{recitation.get_resource_content.id}/segments.json"
209+
all_segments[chapter_id] = json_ayahs
210+
211+
key = "audio/gapless/#{recitation.get_resource_content.id}/#{chapter_id}.json"
209212
uploader.upload(json_path, key)
210213

211214
json_path
212215
end
216+
217+
full_segments_file_path = File.join(target_dir, "all_segments.json")
218+
219+
File.open(full_segments_file_path, "w") do |f|
220+
f.write(JSON.dump(all_segments))
221+
end
222+
223+
key = "audio/gapless/#{recitation.get_resource_content.id}/segments.json"
224+
uploader.upload(full_segments_file_path, key)
213225
end
214226

215227
def export_gapless_recitation_audio_files(recitation, target_dir)

lib/upload_to_cdn.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def upload(file_path, object_key, content_type: 'application/json')
33
bucket.object(object_key)
44
.upload_file(
55
file_path,
6-
content_type
6+
content_type: content_type
77
)
88

99
url = "#{content_cnd_host}/#{object_key}"

0 commit comments

Comments
 (0)