m3u8 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/lib/m3u8.rb +1 -0
- data/lib/m3u8/playlist_item.rb +23 -2
- data/lib/m3u8/version.rb +1 -1
- data/spec/lib/m3u8/playlist_item_spec.rb +9 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e96c846721a2a84feb5682879e7e3bfcb3f3e0dd
|
4
|
+
data.tar.gz: 438952587f84fa55401e22ba4c2f5c089de14af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62a05705eefa8c3929c9db56f65be2f2137f90c1e3fecd8e228a840c7285a9a5f20b7c2a59055ba462e55329d54214bee41497c5d0aef3b965cd6deef784d3f4
|
7
|
+
data.tar.gz: 3a34c9d4e231f2d37030b4a8357accc486d1cb88d67b238abe1183f1f1e87e8e7d2a0d8b45bd0bfb51ff682c664c78c7c34a43f166f4c77d2a85695763479289
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#### 0.6.
|
1
|
+
#### 0.6.4 (2/21/2016) - Merged pull requests #8, #9, and #10 from [jviney](https://github.com/jviney). Adds FRAME-RATE attribute to PlayListItem, fixes NONE option for CLOSED-CAPTIONS attribute.
|
2
|
+
|
3
|
+
#### 0.6.3 (2/17/2016) - Merged pull request #7 from [jviney](https://github.com/jviney), fixing bug with require order.
|
2
4
|
|
3
5
|
#### 0.6.2 (2/16/2016) - Added support for EXT-X-SESSION-KEY tags. Merged pulled request #6 from [jviney](https://github.com/jviney), fixing bug with codec string value.
|
4
6
|
|
data/lib/m3u8.rb
CHANGED
data/lib/m3u8/playlist_item.rb
CHANGED
@@ -5,7 +5,8 @@ module M3u8
|
|
5
5
|
extend M3u8
|
6
6
|
attr_accessor :program_id, :width, :height, :codecs, :bandwidth,
|
7
7
|
:audio_codec, :level, :profile, :video, :audio, :uri,
|
8
|
-
:average_bandwidth, :subtitles, :closed_captions, :iframe
|
8
|
+
:average_bandwidth, :subtitles, :closed_captions, :iframe,
|
9
|
+
:frame_rate
|
9
10
|
MISSING_CODEC_MESSAGE = 'Audio or video codec info should be provided.'
|
10
11
|
|
11
12
|
def initialize(params = {})
|
@@ -19,12 +20,14 @@ module M3u8
|
|
19
20
|
attributes = parse_attributes text
|
20
21
|
resolution = parse_resolution attributes['RESOLUTION']
|
21
22
|
average = parse_average_bandwidth attributes['AVERAGE-BANDWIDTH']
|
23
|
+
frame_rate = parse_frame_rate attributes['FRAME-RATE']
|
22
24
|
options = { program_id: attributes['PROGRAM-ID'],
|
23
25
|
codecs: attributes['CODECS'],
|
24
26
|
width: resolution[:width],
|
25
27
|
height: resolution[:height],
|
26
28
|
bandwidth: attributes['BANDWIDTH'].to_i,
|
27
29
|
average_bandwidth: average,
|
30
|
+
frame_rate: frame_rate,
|
28
31
|
video: attributes['VIDEO'], audio: attributes['AUDIO'],
|
29
32
|
uri: attributes['URI'], subtitles: attributes['SUBTITLES'],
|
30
33
|
closed_captions: attributes['CLOSED-CAPTIONS'] }
|
@@ -73,6 +76,13 @@ module M3u8
|
|
73
76
|
{ width: width, height: height }
|
74
77
|
end
|
75
78
|
|
79
|
+
def self.parse_frame_rate(frame_rate)
|
80
|
+
return if frame_rate.nil?
|
81
|
+
|
82
|
+
value = BigDecimal(frame_rate)
|
83
|
+
value if value > 0
|
84
|
+
end
|
85
|
+
|
76
86
|
def validate
|
77
87
|
fail MissingCodecError, MISSING_CODEC_MESSAGE if codecs.nil?
|
78
88
|
end
|
@@ -89,6 +99,7 @@ module M3u8
|
|
89
99
|
codecs_format,
|
90
100
|
bandwidth_format,
|
91
101
|
average_bandwidth_format,
|
102
|
+
frame_rate_format,
|
92
103
|
audio_format,
|
93
104
|
video_format,
|
94
105
|
subtitles_format,
|
@@ -105,6 +116,11 @@ module M3u8
|
|
105
116
|
"RESOLUTION=#{resolution}"
|
106
117
|
end
|
107
118
|
|
119
|
+
def frame_rate_format
|
120
|
+
return if frame_rate.nil?
|
121
|
+
"FRAME-RATE=#{format('%.3f', frame_rate)}"
|
122
|
+
end
|
123
|
+
|
108
124
|
def codecs_format
|
109
125
|
%(CODECS="#{codecs}")
|
110
126
|
end
|
@@ -135,7 +151,12 @@ module M3u8
|
|
135
151
|
|
136
152
|
def closed_captions_format
|
137
153
|
return if closed_captions.nil?
|
138
|
-
|
154
|
+
|
155
|
+
if closed_captions == 'NONE'
|
156
|
+
%(CLOSED-CAPTIONS=NONE)
|
157
|
+
else
|
158
|
+
%(CLOSED-CAPTIONS="#{closed_captions}")
|
159
|
+
end
|
139
160
|
end
|
140
161
|
|
141
162
|
def audio_codec
|
data/lib/m3u8/version.rb
CHANGED
@@ -17,7 +17,7 @@ describe M3u8::PlaylistItem do
|
|
17
17
|
|
18
18
|
it 'should parse m3u8 text into instance' do
|
19
19
|
format = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
|
20
|
-
%(PROGRAM-ID=1,RESOLUTION=1920x1080,) +
|
20
|
+
%(PROGRAM-ID=1,RESOLUTION=1920x1080,FRAME-RATE=23.976,) +
|
21
21
|
%(AVERAGE-BANDWIDTH=550,AUDIO="test",VIDEO="test2",) +
|
22
22
|
%(SUBTITLES="subs",CLOSED-CAPTIONS="caps",URI="test.url")
|
23
23
|
item = M3u8::PlaylistItem.parse(format)
|
@@ -27,6 +27,7 @@ describe M3u8::PlaylistItem do
|
|
27
27
|
expect(item.average_bandwidth).to eq 550
|
28
28
|
expect(item.width).to eq 1920
|
29
29
|
expect(item.height).to eq 1080
|
30
|
+
expect(item.frame_rate).to eq BigDecimal('23.976')
|
30
31
|
expect(item.audio).to eq 'test'
|
31
32
|
expect(item.video).to eq 'test2'
|
32
33
|
expect(item.subtitles).to eq 'subs'
|
@@ -52,11 +53,11 @@ describe M3u8::PlaylistItem do
|
|
52
53
|
|
53
54
|
it 'should provide m3u8 format representation' do
|
54
55
|
hash = { program_id: 1, width: 1920, height: 1080, codecs: 'avc',
|
55
|
-
bandwidth: 540, uri: 'test.url' }
|
56
|
+
bandwidth: 540, uri: 'test.url', closed_captions: 'NONE' }
|
56
57
|
item = M3u8::PlaylistItem.new(hash)
|
57
58
|
output = item.to_s
|
58
59
|
expected = '#EXT-X-STREAM-INF:PROGRAM-ID=1,RESOLUTION=1920x1080,' +
|
59
|
-
%(CODECS="avc",BANDWIDTH=540\ntest.url)
|
60
|
+
%(CODECS="avc",BANDWIDTH=540,CLOSED-CAPTIONS=NONE\ntest.url)
|
60
61
|
expect(output).to eq expected
|
61
62
|
|
62
63
|
hash = { program_id: 1, codecs: 'avc', bandwidth: 540,
|
@@ -68,13 +69,14 @@ describe M3u8::PlaylistItem do
|
|
68
69
|
expect(output).to eq expected
|
69
70
|
|
70
71
|
hash = { codecs: 'avc', bandwidth: 540, uri: 'test.url', audio: 'test',
|
71
|
-
video: 'test2', average_bandwidth:
|
72
|
-
closed_captions: 'caps' }
|
72
|
+
video: 'test2', average_bandwidth: 500, subtitles: 'subs',
|
73
|
+
frame_rate: 30, closed_captions: 'caps' }
|
73
74
|
item = M3u8::PlaylistItem.new(hash)
|
74
75
|
output = item.to_s
|
75
76
|
expected = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
|
76
|
-
%(AVERAGE-BANDWIDTH=
|
77
|
-
%(
|
77
|
+
%(AVERAGE-BANDWIDTH=500,FRAME-RATE=30.000,) +
|
78
|
+
%(AUDIO="test",VIDEO="test2",SUBTITLES="subs",) +
|
79
|
+
%(CLOSED-CAPTIONS="caps"\ntest.url)
|
78
80
|
expect(output).to eq expected
|
79
81
|
end
|
80
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m3u8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Deckard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|