webvtt-ruby 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/webvtt.rb +2 -2
- data/lib/{parser.rb → webvtt/parser.rb} +13 -3
- data/lib/{segmenter.rb → webvtt/segmenter.rb} +0 -0
- data/tests/parser.rb +16 -1
- data/tests/subtitles/invalid_cue.srt +5 -0
- data/tests/subtitles/invalid_cue.vtt +6 -0
- data/tests/subtitles/test_from_srt.vtt +1 -1
- data/webvtt-ruby.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0ecae0ceefe5452aa14107dcb45c892ff9d02a6
|
4
|
+
data.tar.gz: 173216b97d99db10103bc59207916ac5474748d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 252d353160e8055adf98277d1c581cec2d13d975be165a8ec7108b10574606173e71946f670242c71def21e7f5a8eab7487834c0bcd06612f4f4b1c95d1b8c77
|
7
|
+
data.tar.gz: dcb306b34ac391d51bcdec9ad9677a7cef97c6aa699a3b4cbf620b699d213f05f1960f839bc811752d96fd25784960f7291633dbd02cdf0d43683834ee277b16
|
data/Gemfile.lock
CHANGED
data/lib/webvtt.rb
CHANGED
@@ -72,7 +72,7 @@ module WebVTT
|
|
72
72
|
|
73
73
|
@cues = []
|
74
74
|
cues.each do |cue|
|
75
|
-
cue_parsed = Cue.
|
75
|
+
cue_parsed = Cue.parse(cue.strip)
|
76
76
|
if !cue_parsed.text.nil?
|
77
77
|
@cues << cue_parsed
|
78
78
|
end
|
@@ -84,9 +84,15 @@ module WebVTT
|
|
84
84
|
class Cue
|
85
85
|
attr_accessor :identifier, :start, :end, :style, :text
|
86
86
|
|
87
|
-
def initialize(cue)
|
87
|
+
def initialize(cue = nil)
|
88
88
|
@content = cue
|
89
|
-
|
89
|
+
@style = {}
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.parse(cue)
|
93
|
+
cue = Cue.new(cue)
|
94
|
+
cue.parse
|
95
|
+
return cue
|
90
96
|
end
|
91
97
|
|
92
98
|
def to_webvtt
|
@@ -136,6 +142,10 @@ module WebVTT
|
|
136
142
|
lines.shift
|
137
143
|
end
|
138
144
|
|
145
|
+
if lines.empty?
|
146
|
+
return
|
147
|
+
end
|
148
|
+
|
139
149
|
if lines[0].match(/([0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}) -+> ([0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3})(.*)/)
|
140
150
|
@start = Timestamp.new $1
|
141
151
|
@end = Timestamp.new $2
|
File without changes
|
data/tests/parser.rb
CHANGED
@@ -156,7 +156,7 @@ The text should change)
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def test_cue_offset_by
|
159
|
-
cue = WebVTT::Cue.
|
159
|
+
cue = WebVTT::Cue.parse <<-CUE
|
160
160
|
00:00:01.000 --> 00:00:25.432
|
161
161
|
Test Cue
|
162
162
|
CUE
|
@@ -195,4 +195,19 @@ The text should change)
|
|
195
195
|
assert_equal "03:39:34.008", ts3.to_s
|
196
196
|
end
|
197
197
|
|
198
|
+
def test_build_cue
|
199
|
+
cue = WebVTT::Cue.new
|
200
|
+
cue.start = WebVTT::Timestamp.new 0
|
201
|
+
cue.end = WebVTT::Timestamp.new 12
|
202
|
+
cue.text = "Built from scratch"
|
203
|
+
output = ""
|
204
|
+
output << "00:00:00.000 --> 00:00:12.000\n"
|
205
|
+
output << "Built from scratch"
|
206
|
+
assert_equal output, cue.to_webvtt
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_invalid_cue
|
210
|
+
webvtt = WebVTT.convert_from_srt("tests/subtitles/invalid_cue.srt")
|
211
|
+
assert_equal 1, webvtt.cues.size
|
212
|
+
end
|
198
213
|
end
|
data/webvtt-ruby.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'webvtt-ruby'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.2'
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Celeste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-09 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).
|
@@ -24,13 +24,15 @@ files:
|
|
24
24
|
- LICENSE
|
25
25
|
- README.md
|
26
26
|
- bin/webvtt-segmenter
|
27
|
-
- lib/parser.rb
|
28
|
-
- lib/segmenter.rb
|
29
27
|
- lib/webvtt.rb
|
28
|
+
- lib/webvtt/parser.rb
|
29
|
+
- lib/webvtt/segmenter.rb
|
30
30
|
- tests/parser.rb
|
31
31
|
- tests/segmenter.rb
|
32
32
|
- tests/subtitles/big_srt.srt
|
33
33
|
- tests/subtitles/big_srt.vtt
|
34
|
+
- tests/subtitles/invalid_cue.srt
|
35
|
+
- tests/subtitles/invalid_cue.vtt
|
34
36
|
- tests/subtitles/no_text.vtt
|
35
37
|
- tests/subtitles/notvalid.vtt
|
36
38
|
- tests/subtitles/test.vtt
|