hlspider 0.5.0 → 0.6.0

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.
@@ -166,14 +166,14 @@ module HLSpider
166
166
  @variable_playlist = true
167
167
 
168
168
  @file.each_line do |line|
169
- @playlists << line[/([^ "]+.m3u8)/].strip if has_playlist?(line)
169
+ @playlists << line[/([^ "]+.m3u8[^ "]*)/].strip if has_playlist?(line)
170
170
  end
171
171
  elsif has_segment?(@file) && !has_playlist?(@file)
172
172
  @segment_playlist = true
173
173
 
174
174
  @file.each_line do |line|
175
175
  if has_segment?(line)
176
- @segments << filename(line.strip)
176
+ @segments << line[/([^ "]+.(ts|aac)[^ "]*)/].strip
177
177
  elsif duration_line?(line)
178
178
  @target_duration = parse_duration(line.strip)
179
179
  elsif media_sequence_line?(line)
@@ -15,7 +15,7 @@ module HLSpider
15
15
  #
16
16
  # Returns Boolean.
17
17
  def has_segment?(str)
18
- !!( str[/.*.ts(\z|\?|$)/] )
18
+ !!( str[/.*.(ts|aac)(\z|\?|$)/] )
19
19
  end
20
20
 
21
21
  # Internal: Checks if String str contains links to .m3u8 file extensions.
@@ -73,23 +73,6 @@ module HLSpider
73
73
  end
74
74
  end
75
75
 
76
- # Internal: Parses String video segment filename out of String str.
77
- #
78
- # str - String to be parsed
79
- #
80
- # Examples
81
- #
82
- # filename("/media/video_01.ts?query_string=22")
83
- # #=> 'video_01.ts'
84
- #
85
- # filename("arandomsring")
86
- # #=> nil
87
- #
88
- # Returns String or nil.
89
- def filename(str)
90
- str.slice(/\w{1,}(.ts)/)
91
- end
92
-
93
76
  # Internal: Parses string and returns whether or not it is an absolute url.
94
77
  #
95
78
  # str - String to be parsed
@@ -142,4 +125,4 @@ module HLSpider
142
125
  end
143
126
  end
144
127
  end
145
- end
128
+ end
@@ -1,3 +1,3 @@
1
1
  module HLSpider
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -49,12 +49,6 @@ describe HLSpider::PlaylistLine do
49
49
  end
50
50
  end
51
51
 
52
- describe "#filename" do
53
- it "returns String with filename on String with filename" do
54
- PlaylistLine.filename(@segment_line).must_equal("video_123123023030.ts")
55
- end
56
- end
57
-
58
52
  describe "#absolute_url?" do
59
53
  it "returns true for full url" do
60
54
  PlaylistLine.absolute_url?("http://www.google.com/gmail/").must_equal(true)
@@ -85,4 +79,3 @@ describe HLSpider::PlaylistLine do
85
79
  end
86
80
  end
87
81
  end
88
-
@@ -30,6 +30,33 @@ web.m3u8
30
30
  #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=401437,CODECS="mp4a.40.2,avc1.4d401e",AUDIO="aac"
31
31
  iphone.m3u8
32
32
  }
33
+
34
+ @querystring_playlist = %q{#EXTM3U
35
+ #EXT-X-VERSION:3
36
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=500000
37
+ chunklist-b500000.m3u8?wowzasessionid=2030032484
38
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1000000
39
+ chunklist-b1000000.m3u8?wowzasessionid=2030032484
40
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1400000
41
+ chunklist-b1400000.m3u8?wowzasessionid=2030032484
42
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=96000
43
+ chunklist-b96000.m3u8?wowzasessionid=2030032484&wowzaaudioonly
44
+ }
45
+
46
+ @audioonly_playlist = %q{#EXTM3U
47
+ #EXT-X-VERSION:3
48
+ #EXT-X-ALLOW-CACHE:NO
49
+ #EXT-X-TARGETDURATION:11
50
+ #EXT-X-MEDIA-SEQUENCE:35
51
+ #EXTINF:9.0,
52
+ media-b96000_35.aac?wowzasessionid=1332469433&wowzaaudioonly
53
+ #EXTINF:9.0,
54
+ media-b96000_36.aac?wowzasessionid=1332469433&wowzaaudioonly
55
+ #EXTINF:9.0,
56
+ media-b96000_37.aac?wowzasessionid=1332469433&wowzaaudioonly
57
+ #EXTINF:9.0,
58
+ media-b96000_38.aac?wowzasessionid=1332469433&wowzaaudioonly
59
+ }
33
60
  end
34
61
 
35
62
  it "should identify if it is a segments playlist" do
@@ -68,4 +95,24 @@ iphone.m3u8
68
95
  "http://host.com/main/iphone.m3u8"
69
96
  ])
70
97
  end
98
+
99
+ it "should accept urls with querystings on playlists" do
100
+ playlist = HLSpider::Playlist.new(@querystring_playlist, "http://host.com/main/playlist.m3u8")
101
+ playlist.playlists.must_equal([
102
+ "http://host.com/main/chunklist-b500000.m3u8?wowzasessionid=2030032484",
103
+ "http://host.com/main/chunklist-b1000000.m3u8?wowzasessionid=2030032484",
104
+ "http://host.com/main/chunklist-b1400000.m3u8?wowzasessionid=2030032484",
105
+ "http://host.com/main/chunklist-b96000.m3u8?wowzasessionid=2030032484&wowzaaudioonly"
106
+ ])
107
+ end
108
+
109
+ it "should accept audio only segments" do
110
+ playlist = HLSpider::Playlist.new(@audioonly_playlist, "http://host.com/main/playlist.m3u8")
111
+ playlist.segments.must_equal([
112
+ "media-b96000_35.aac?wowzasessionid=1332469433&wowzaaudioonly",
113
+ "media-b96000_36.aac?wowzasessionid=1332469433&wowzaaudioonly",
114
+ "media-b96000_37.aac?wowzasessionid=1332469433&wowzaaudioonly",
115
+ "media-b96000_38.aac?wowzasessionid=1332469433&wowzaaudioonly"
116
+ ])
117
+ end
71
118
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hlspider
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - brookemckim
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-05-09 00:00:00 Z
18
+ date: 2013-06-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest