webvtt-ruby 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15bbe1e879056600fd02bf628d0b182d38e7a391
4
- data.tar.gz: 1502c8c4e85f67547b821143c7b0f6088025969a
3
+ metadata.gz: a60d420e7d42cd04d58877cc991c712883b43bd0
4
+ data.tar.gz: 229298792a3155b95e55bf367ceecff6777d5a9f
5
5
  SHA512:
6
- metadata.gz: c3e87c0819971ae9c28bb7b10d1bc6544a166cdfdc6aae0fa85d9142d0335fab15d91dd21072bfd46aa32bcbfbc31ee60378eb85d158d2716ab03fc41da1acdb
7
- data.tar.gz: c94bd323d9558d68e21c3619617d362227a6a408610f52aeaf71243a776b850f0a665ad9df2435bd091307cbfde846beb5f2a4f09bc42a892c6c1d684f4e32b7
6
+ metadata.gz: 6e1664360e303747834f789fe24b7cc23b52ce833ee68f258be9e552ea256196400de0cd6a8631dabae4de812878af1724d52a2dbe3be1798c5f7e3260b4fef6
7
+ data.tar.gz: 00eacc64841a13c34832de3d869980883c3598084260f3917211aa70a955b5cd9803c5cf637e210356f5f206f9b61247c89de06079a4799530ab10235bce2d03
data/README.md CHANGED
@@ -23,7 +23,7 @@ To parse a webvtt file:
23
23
  ```ruby
24
24
  require "webvtt"
25
25
 
26
- webvtt = WebVTT.read("path/sub.webvtt")
26
+ webvtt = WebVTT.read("path/sub.vtt")
27
27
  webvtt.cues.each do |cue|
28
28
  puts "identifier: #{cue.identifier}"
29
29
  puts "Start: #{cue.start}"
@@ -39,7 +39,7 @@ end
39
39
  You can also convert an SRT file to a standard WebVTT file:
40
40
 
41
41
  ```ruby
42
- webvtt = WebVTT.convert_from_srt("path/sub.srt", "path/sub.webvtt")
42
+ webvtt = WebVTT.convert_from_srt("path/sub.srt", "path/sub.vtt")
43
43
  puts webvtt.to_webvtt
44
44
  ```
45
45
 
@@ -48,7 +48,7 @@ puts webvtt.to_webvtt
48
48
  Segmenting is required to work with HLS videos.
49
49
 
50
50
  ```ruby
51
- WebVTT.segment("subtitles/en.webvtt", :length => 10, :output => "subtitles/en-%05d.webvtt", :playlist => "subtitles/en.m3u8")
51
+ WebVTT.segment("subtitles/en.vtt", :length => 10, :output => "subtitles/en-%05d.vtt", :playlist => "subtitles/en.m3u8")
52
52
  ```
53
53
 
54
54
  It will also generate the playlist in `m3u8`:
@@ -60,11 +60,11 @@ It will also generate the playlist in `m3u8`:
60
60
  #EXT-X-MEDIA-SEQUENCE:0
61
61
  #EXT-X-PLAYLIST-TYPE:VOD
62
62
  #EXTINF:13,
63
- en-00000.webvtt
63
+ en-00000.vtt
64
64
  #EXTINF:17,
65
- en-00001.webvtt
65
+ en-00001.vtt
66
66
  #EXTINF:12,
67
- en-00002.webvtt
67
+ en-00002.vtt
68
68
  #EXT-X-ENDLIST
69
69
  ```
70
70
 
@@ -87,7 +87,7 @@ demo-600000.m3u8
87
87
  You can also segment webvtt files using the command line `webvtt-segmenter`:
88
88
 
89
89
  ```
90
- $ webvtt-segmenter -i subtitles/en.webvtt -t 10 -m subtitles/en.m3u8 -o "subtitles/en-%05d.webvtt"
90
+ $ webvtt-segmenter -i subtitles/en.vtt -t 10 -m subtitles/en.m3u8 -o "subtitles/en-%05d.vtt"
91
91
  ```
92
92
 
93
93
  ```
@@ -96,7 +96,7 @@ Usage: bin/webvtt-segmenter [--arg]
96
96
  -i, --input [PATH] WebVTT or SRT file
97
97
  -b, --base-url [URL] Base URL
98
98
  -t, --target-duration [DUR] Duration of each segments. Default: 10
99
- -o, --output [PATH] Path where WebVTT segments will be saved. Default: fileSequence-%05d.webvtt
99
+ -o, --output [PATH] Path where WebVTT segments will be saved. Default: fileSequence-%05d.vtt
100
100
  -m, --playlist [PATH] Path where the playlist in m3u8 will be saved. Default: prog_index.m3u8
101
101
  ```
102
102
 
@@ -20,7 +20,7 @@ opts = OptionParser.new do |opts|
20
20
  @options[:length] = dur.to_i
21
21
  end
22
22
 
23
- opts.on("-o", "--output [PATH]", "Path where WebVTT segments will be saved. Default: fileSequence-%05d.webvtt") do |path|
23
+ opts.on("-o", "--output [PATH]", "Path where WebVTT segments will be saved. Default: fileSequence-%05d.vtt") do |path|
24
24
  @options[:output] = path
25
25
  end
26
26
 
@@ -10,7 +10,7 @@ module WebVTT
10
10
  end
11
11
 
12
12
  srt = ::File.read(srt_file)
13
- output ||= srt_file.gsub(".srt", ".webvtt")
13
+ output ||= srt_file.gsub(".srt", ".vtt")
14
14
 
15
15
  # convert timestamps and save the file
16
16
  srt.gsub!(/([0-9]{2}:[0-9]{2}:[0-9]{2})([,])([0-9]{3})/, '\1.\3')
@@ -51,7 +51,7 @@ module WebVTT
51
51
  end
52
52
 
53
53
  def save(output=nil)
54
- output ||= @path.gsub(".srt", ".webvtt")
54
+ output ||= @path.gsub(".srt", ".vtt")
55
55
 
56
56
  File.open(output, "w") {|f| f.write(to_webvtt)}
57
57
  return output
@@ -23,7 +23,7 @@ module WebVTT
23
23
  @webvtt = webvtt
24
24
  @options = options
25
25
  @options[:length] ||= 10
26
- @options[:output] ||= "fileSequence-%05d.webvtt"
26
+ @options[:output] ||= "fileSequence-%05d.vtt"
27
27
  @options[:playlist] ||= "prog_index.m3u8"
28
28
  end
29
29
 
@@ -5,31 +5,31 @@ require "webvtt"
5
5
  class ParserTest < Test::Unit::TestCase
6
6
  def test_can_read_webvtt
7
7
  assert_nothing_raised(WebVTT::InputError) {
8
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
9
- assert_equal "test.webvtt", webvtt.filename
8
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
9
+ assert_equal "test.vtt", webvtt.filename
10
10
  }
11
11
  end
12
12
 
13
13
  def test_cant_read_webvtt
14
14
  assert_raise(WebVTT::InputError) {
15
- webvtt = WebVTT.read("tests/subtitles/test_.webvtt")
15
+ webvtt = WebVTT.read("tests/subtitles/test_.vtt")
16
16
  }
17
17
  end
18
18
 
19
19
  def test_is_valid_webvtt
20
20
  assert_nothing_raised(WebVTT::MalformedFile) {
21
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
21
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
22
22
  }
23
23
  end
24
24
 
25
25
  def test_is_not_valid_webvtt
26
26
  assert_raise(WebVTT::MalformedFile) {
27
- webvtt = WebVTT.read("tests/subtitles/notvalid.webvtt")
27
+ webvtt = WebVTT.read("tests/subtitles/notvalid.vtt")
28
28
  }
29
29
  end
30
30
 
31
31
  def test_list_cues
32
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
32
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
33
33
  assert_instance_of Array, webvtt.cues
34
34
  assert !webvtt.cues.empty?, "Cues should not be empty"
35
35
  assert_instance_of WebVTT::Cue, webvtt.cues[0]
@@ -37,12 +37,12 @@ class ParserTest < Test::Unit::TestCase
37
37
  end
38
38
 
39
39
  def test_header
40
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
40
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
41
41
  assert_equal "WEBVTT\nX-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000", webvtt.header
42
42
  end
43
43
 
44
44
  def test_cue
45
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
45
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
46
46
  cue = webvtt.cues[0]
47
47
  assert_equal "00:00:29.000", cue.start
48
48
  assert_equal "00:00:31.000", cue.end
@@ -52,7 +52,7 @@ class ParserTest < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_cue_identifier
55
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
55
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
56
56
  cue = webvtt.cues[1]
57
57
  assert_equal "2", cue.identifier
58
58
  assert_equal "00:00:31.000", cue.start
@@ -63,7 +63,7 @@ class ParserTest < Test::Unit::TestCase
63
63
  end
64
64
 
65
65
  def test_ignore_if_note
66
- webvtt = WebVTT.read("tests/subtitles/withnote.webvtt")
66
+ webvtt = WebVTT.read("tests/subtitles/withnote.vtt")
67
67
  assert_equal 3, webvtt.cues.size
68
68
  # ignoring the first cue which is a NOTE
69
69
  assert_equal "1", webvtt.cues[0].identifier
@@ -76,22 +76,22 @@ class ParserTest < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  def test_total_length
79
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
79
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
80
80
  assert_equal 359, webvtt.total_length
81
81
  end
82
82
 
83
83
  def test_cue_length
84
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
84
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
85
85
  assert_equal 2.0, webvtt.cues[2].length
86
86
  end
87
87
 
88
88
  def test_file_to_webvtt
89
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
90
- assert_equal webvtt.to_webvtt, File.read("tests/subtitles/test.webvtt")
89
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
90
+ assert_equal webvtt.to_webvtt, File.read("tests/subtitles/test.vtt")
91
91
  end
92
92
 
93
93
  def test_cue_to_webvtt
94
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
94
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
95
95
  assert_equal webvtt.cues[0].to_webvtt, %(00:00:29.000 --> 00:00:31.000 line:75%
96
96
  English subtitle 15 -Forced- (00:00:27.000)
97
97
  line:75%)
@@ -102,7 +102,7 @@ align:start line:0%)
102
102
  end
103
103
 
104
104
  def test_updating_webvtt
105
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
105
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
106
106
  cue = webvtt.cues[0]
107
107
  cue.identifier = "1"
108
108
  cue.text = "The text should change"
@@ -120,7 +120,7 @@ The text should change)
120
120
 
121
121
  def test_reading_all_cues
122
122
  return
123
- webvtt = WebVTT.read("tests/subtitles/withnote.webvtt")
123
+ webvtt = WebVTT.read("tests/subtitles/withnote.vtt")
124
124
  webvtt.cues.each_with_index do |cue,i|
125
125
  puts "#{i}"
126
126
  puts "identifier: #{cue.identifier}"
@@ -139,7 +139,7 @@ The text should change)
139
139
 
140
140
  def test_parse_big_file
141
141
  return
142
- webvtt = WebVTT.read("tests/subtitles/big_srt.webvtt")
142
+ webvtt = WebVTT.read("tests/subtitles/big_srt.vtt")
143
143
  webvtt.cues.each_with_index do |cue,i|
144
144
  puts "*#{i}"
145
145
  puts "identifier: #{cue.identifier}"
@@ -151,7 +151,7 @@ The text should change)
151
151
  end
152
152
 
153
153
  def test_parse_cue_with_no_text
154
- webvtt = WebVTT.read("tests/subtitles/no_text.webvtt")
154
+ webvtt = WebVTT.read("tests/subtitles/no_text.vtt")
155
155
  assert_equal 2, webvtt.cues.size
156
156
  assert_equal "265", webvtt.cues[0].identifier
157
157
  assert_equal "00:08:57.409", webvtt.cues[0].start
@@ -6,7 +6,7 @@ require "fileutils"
6
6
  class ParserTest < Test::Unit::TestCase
7
7
 
8
8
  def test_segment_of_a_given_cue
9
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
9
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
10
10
  segmenter = WebVTT::Segmenter.new(webvtt, :length => 5)
11
11
  assert_equal [5, 6], segmenter.find_segments(webvtt.cues[0])
12
12
  assert_equal [6], segmenter.find_segments(webvtt.cues[1])
@@ -17,7 +17,7 @@ class ParserTest < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_segment_file_of_a_given_cue
20
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
20
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
21
21
  segmenter = WebVTT::Segmenter.new(webvtt, :length => 5)
22
22
  assert_equal [0, 1], segmenter.find_segment_files(webvtt.cues[0])
23
23
  assert_equal [1], segmenter.find_segment_files(webvtt.cues[1])
@@ -28,7 +28,7 @@ class ParserTest < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_split_to_files
31
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
31
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
32
32
  sub_webvtt_files = WebVTT::Segmenter.new(webvtt, :length => 5).split_to_files
33
33
  assert_equal 68, sub_webvtt_files.size
34
34
  assert_equal 31, sub_webvtt_files[0].total_length
@@ -38,7 +38,7 @@ class ParserTest < Test::Unit::TestCase
38
38
  end
39
39
 
40
40
  def test_generate_playlist
41
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
41
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
42
42
  segmenter = WebVTT::Segmenter.new(webvtt, :length => 5, :playlist => "test.m3u8")
43
43
  subs = segmenter.split_to_files
44
44
  segmenter.generate_playlist(subs)
@@ -50,7 +50,7 @@ class ParserTest < Test::Unit::TestCase
50
50
  end
51
51
 
52
52
  def test_shortcut_method
53
- res = WebVTT.segment("tests/subtitles/test.webvtt")
53
+ res = WebVTT.segment("tests/subtitles/test.vtt")
54
54
  assert_instance_of Array, res
55
55
  assert_equal 2, res.size
56
56
  assert_equal 35, res[1].size
@@ -61,7 +61,7 @@ class ParserTest < Test::Unit::TestCase
61
61
 
62
62
  def test_segment_to_webvtt_files
63
63
  return
64
- webvtt = WebVTT.read("tests/subtitles/test.webvtt")
64
+ webvtt = WebVTT.read("tests/subtitles/test.vtt")
65
65
  sub_webvtt_files = WebVTT::Segmenter.new(webvtt, :length => 5).split
66
66
  assert_equal 67, sub_webvtt_files.size
67
67
  puts
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'webvtt-ruby'
3
- s.version = '0.2.4'
3
+ s.version = '0.2.5'
4
4
  s.summary = "WebVTT parser and segmenter in ruby"
5
5
  s.description = "WebVTT parser and segmenter in ruby for HTML5 and HTTP Live Streaming (HLS)."
6
6
  s.authors = ["Bruno Celeste"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webvtt-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Celeste
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-30 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: WebVTT parser and segmenter in ruby for HTML5 and HTTP Live Streaming
14
14
  (HLS).
@@ -29,13 +29,13 @@ files:
29
29
  - tests/parser.rb
30
30
  - tests/segmenter.rb
31
31
  - tests/subtitles/big_srt.srt
32
- - tests/subtitles/big_srt.webvtt
33
- - tests/subtitles/no_text.webvtt
34
- - tests/subtitles/notvalid.webvtt
35
- - tests/subtitles/test.webvtt
32
+ - tests/subtitles/big_srt.vtt
33
+ - tests/subtitles/no_text.vtt
34
+ - tests/subtitles/notvalid.vtt
35
+ - tests/subtitles/test.vtt
36
36
  - tests/subtitles/test_from_srt.srt
37
- - tests/subtitles/test_from_srt.webvtt
38
- - tests/subtitles/withnote.webvtt
37
+ - tests/subtitles/test_from_srt.vtt
38
+ - tests/subtitles/withnote.vtt
39
39
  - webvtt-ruby.gemspecs
40
40
  homepage: https://github.com/HeyWatch/webvtt-ruby
41
41
  licenses:
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.2.2
60
+ rubygems_version: 2.4.3
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: WebVTT parser and segmenter in ruby