File tree 2 files changed +27
-15
lines changed
2 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,23 @@ M3U.prototype.toString = function toString() {
104
104
} ) ;
105
105
106
106
if ( this . items . PlaylistItem . length ) {
107
+ let cuedInterstitial = false ;
108
+ let final_interstitial_item = null ;
109
+ if ( this . items . PlaylistItem [ this . items . PlaylistItem . length - 1 ] . get ( "daterange" ) &&
110
+ this . items . PlaylistItem [ this . items . PlaylistItem . length - 1 ] . get ( "daterange" ) [ "CLASS" ] == "com.apple.hls.interstitial" &&
111
+ this . items . PlaylistItem [ this . items . PlaylistItem . length - 1 ] . get ( "daterange" ) [ "CUE" ]
112
+ ) {
113
+ cuedInterstitial = true ;
114
+ }
115
+ if ( cuedInterstitial ) {
116
+ final_interstitial_item = this . items . PlaylistItem . pop ( )
117
+ }
107
118
output . push ( this . items . PlaylistItem . map ( itemToString ) . join ( '\n' ) ) ;
108
-
109
119
if ( this . get ( 'playlistType' ) === 'VOD' ) {
110
120
output . push ( '#EXT-X-ENDLIST' ) ;
121
+ if ( final_interstitial_item ) {
122
+ output . push ( final_interstitial_item . toString ( ) ) ;
123
+ }
111
124
}
112
125
} else {
113
126
if ( this . items . StreamItem . length ) {
Original file line number Diff line number Diff line change @@ -142,6 +142,18 @@ function parseQuotedString(value) {
142
142
}
143
143
}
144
144
145
+ function parseAttributeStringToDict ( inputString ) {
146
+ const data = { } ;
147
+ const regex = / ( [ \w - ] + ) = ( " .* ?" | [ ^ , ] + ) / g;
148
+ let match ;
149
+ while ( ( match = regex . exec ( inputString ) ) !== null ) {
150
+ const key = match [ 1 ] ;
151
+ const value = match [ 2 ] . replace ( / ^ " | " $ / g, '' ) ;
152
+ data [ key ] = value ;
153
+ }
154
+ return data ;
155
+ }
156
+
145
157
var parse = {
146
158
'boolean' : function parseBoolean ( value ) {
147
159
return typeof value == 'boolean'
@@ -161,20 +173,7 @@ var parse = {
161
173
'quoted-string' : parseQuotedString ,
162
174
'closed-captions' : parseQuotedString ,
163
175
'quoted-string-array' : function parseQuotedStringArray ( value ) {
164
- var data = { } ;
165
- value . split ( ',' ) . map ( function ( kv ) {
166
- var s = kv . split ( '=' ) ;
167
- var unquoted = "" ;
168
- if ( s [ 1 ] ) {
169
- if ( s [ 1 ] . indexOf ( '"' ) === 0 && s [ 1 ] . lastIndexOf ( '"' ) == s [ 1 ] . length - 1 ) {
170
- unquoted = s [ 1 ] . slice ( 1 , - 1 ) ;
171
- } else {
172
- unquoted = s [ 1 ] ;
173
- }
174
- data [ s [ 0 ] ] = unquoted ;
175
- }
176
- } ) ;
177
- return data ;
176
+ return parseAttributeStringToDict ( value ) ;
178
177
} ,
179
178
'hexadecimal-sequence' : function parseHexadecimalSequence ( value ) {
180
179
return value ;
You can’t perform that action at this time.
0 commit comments