forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes COMMS-1971 Test Plan: ** DO THESE BEFORE CHECKING OUT THE PS - With notorious running create a bunch of videos with the rce or submission contents - while watching the video click on the cc button on the video - add a bunch of closed captions of SRT type (or media tracks as they are stored in the db) - notice that the cc play on the video CHECK OUT THE PS - migrate your db - notice the column on MediaTracks that you added called webvtt_content is now populated - upload another srt file to a video - notice it still plays Change-Id: Iba0004ace0a248d8ed28ffe3015dbf5c5d3ddeee Reviewed-on: https://gerrit.instructure.com/188126 Reviewed-by: Landon Gilbert-Bland <[email protected]> QA-Review: Landon Gilbert-Bland <[email protected]> Tested-by: Jenkins Product-Review: Steven Burnett <[email protected]>
- Loading branch information
Showing
5 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright (C) 2019 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
class AddColumnToMediaTrack < ActiveRecord::Migration[5.1] | ||
tag :predeploy | ||
|
||
def change | ||
add_column :media_tracks, :webvtt_content, :text | ||
end | ||
end |
29 changes: 29 additions & 0 deletions
29
db/migrate/20190405134013_populate_media_tracks_web_vtt_content.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Copyright (C) 2019 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
class PopulateMediaTracksWebVttContent < ActiveRecord::Migration[5.1] | ||
tag :postdeploy | ||
|
||
def change | ||
DataFixup::PopulateMediaTracksWebVttContent.send_later_if_production_enqueue_args( | ||
:run, | ||
priority: Delayed::LOW_PRIORITY, | ||
max_attempts: 1, | ||
n_strand: "DataFixup::PopulateMediaTracksWebVttContent:#{Shard.current.database_server.id}" | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Copyright (C) 2019 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
module DataFixup::PopulateMediaTracksWebVttContent | ||
def self.run | ||
MediaTrack.find_each do |mt| | ||
mt.convert_srt_to_wvtt | ||
mt.save if mt.changed? | ||
end | ||
end | ||
end |
74 changes: 74 additions & 0 deletions
74
spec/migrations/data_fixup/populate_media_tracks_web_vtt_content_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# | ||
# Copyright (C) 2019 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
require_relative '../../spec_helper' | ||
|
||
RSpec.describe DataFixup::PopulateMediaTracksWebVttContent do | ||
def webvtt_content | ||
<<-HEREDOC | ||
WEBVTT | ||
00:01.000 --> 00:04.000 | ||
Never drink liquid nitrogen. | ||
00:05.000 --> 00:09.000 | ||
- It will perforate your stomach. | ||
- You could die. | ||
end | ||
HEREDOC | ||
end | ||
|
||
def srt_content | ||
<<-HEREDOC | ||
1 | ||
00:00:01,600 --> 00:00:04,200 | ||
English (US) | ||
2 | ||
00:00:05,900 --> 00:00:07,999 | ||
This is a subtitle in American English | ||
3 | ||
00:00:10,000 --> 00:00:14,000 | ||
Adding subtitles is very easy to do | ||
HEREDOC | ||
end | ||
|
||
it 'converts content of type srt to web_vtt' do | ||
mo = MediaObject.create!(media_id: 'm1234') | ||
mt = MediaTrack.create!(content: srt_content, media_object: mo) | ||
DataFixup::PopulateMediaTracksWebVttContent.run | ||
expect(mt.read_attribute(:webvtt_content)).not_to be_nil | ||
expect(mt.read_attribute(:webvtt_content)).to include('WEBVTT') | ||
end | ||
|
||
it 'will not convert content if already webvtt' do | ||
mo = MediaObject.create!(media_id: 'm1234') | ||
mt = MediaTrack.create!(content: webvtt_content, media_object: mo) | ||
DataFixup::PopulateMediaTracksWebVttContent.run | ||
expect(mt.read_attribute(:webvtt_content)).to be_nil | ||
expect(mt.read_attribute(:content)).to include('WEBVTT') | ||
end | ||
|
||
it 'will attempt to convert bad formatted srt' do | ||
mo = MediaObject.create!(media_id: 'm1234') | ||
mt = MediaTrack.create!(content: '123$%blah#badmanbad', media_object: mo) | ||
DataFixup::PopulateMediaTracksWebVttContent.run | ||
expect(mt.read_attribute(:webvtt_content)).not_to be_nil | ||
expect(mt.read_attribute(:webvtt_content)).to include('WEBVTT') | ||
end | ||
end |