Skip to content

Commit

Permalink
Merge pull request #5766 from avalonmediasystem/caption_format
Browse files Browse the repository at this point in the history
Serialize captions to IIIF manifest with text/vtt as the format
  • Loading branch information
Jon Cameron authored Apr 4, 2024
2 parents 0b50bd9 + 2d53815 commit d98864d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ def manifest_attributes(quality, media_type)
def supplemental_attributes(file)
if file.is_a?(SupplementalFile)
label = file.tags.include?('machine_generated') ? file.label + ' (machine generated)' : file.label
format = file.file.content_type
format = if file.file.content_type == 'text/srt' && file.tags.include?('caption')
'text/vtt'
else
file.file.content_type
end
language = file.language || 'en'
filename = file.file.filename.to_s
else
Expand Down
10 changes: 10 additions & 0 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@
expect(subject.any? { |content| content.body_id =~ /master_files\/#{master_file.id}\/captions/ }).to eq false
end

context 'srt captions' do
let(:srt_caption_file) { FactoryBot.create(:supplemental_file, :with_caption_srt_file, :with_caption_tag) }
let(:supplemental_files) { [supplemental_file, transcript_file, caption_file, srt_caption_file] }
it 'sets format to "text/vtt"' do
captions = subject.select { |s| s.body_id.include?('captions') }
expect(captions.none? { |content| content.format == 'text/srt' }).to eq true
expect(captions.all? { |content| content.format == 'text/vtt' }).to eq true
end
end

context 'legacy master file captions' do
let(:master_file) { FactoryBot.create(:master_file, :with_waveform, :with_captions, supplemental_files_json: supplemental_files_json, media_object: media_object, derivatives: [derivative]) }

Expand Down

0 comments on commit d98864d

Please sign in to comment.