Skip to content

Commit 4613ccb

Browse files
authored
Merge pull request #6283 from avalonmediasystem/mp3_download
Provide download path for side-loaded mp3 derivatives with nginx streaming
2 parents f31b935 + 25e85d6 commit 4613ccb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/avalon/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def construct_download_path
4848
when :generic, :adobe
4949
url.gsub(/(?:#{Regexp.escape(http_base)}\/)(?:audio-only\/)?(.*)(?:\.m3u8)/, '\1')
5050
when :nginx
51-
url.gsub(/(?:#{Regexp.escape(Settings.streaming.http_base)}\/)(.*)(?:\/index\.m3u8)/, '\1')
51+
url.gsub(/(?:#{Regexp.escape(Settings.streaming.http_base)}\/)(.*(mp4|mp3))(?:\/index\.m3u8|$)/, '\1')
5252
when :wowza
5353
# Wowza HLS urls include the extension between the base and relative path.
5454
# "http_base/extension:path/filename.extension/playlist.m3u8"

spec/models/derivative_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@
153153
allow(Settings.streaming).to receive(:server).and_return(:nginx)
154154
expect(subject.download_path).to eq "file://6f69c008-06a4-4bad-bb60-26297f0b4c06/35bddaa0-fbb4-404f-ab76-58f22921529c/warning.mp4"
155155
end
156+
157+
context "with mp3 derivative" do
158+
let(:hls_url) { "http://localhost:3000/streams/6f69c008-06a4-4bad-bb60-26297f0b4c06/35bddaa0-fbb4-404f-ab76-58f22921529c/warning.mp3" }
159+
160+
it "provides a file path" do
161+
allow(Settings.streaming).to receive(:server).and_return(:nginx)
162+
expect(subject.download_path).to eq "file://6f69c008-06a4-4bad-bb60-26297f0b4c06/35bddaa0-fbb4-404f-ab76-58f22921529c/warning.mp3"
163+
end
164+
end
156165
end
157166

158167
describe "s3" do

0 commit comments

Comments
 (0)