@@ -17,18 +17,34 @@ import { LevelAttributes } from '../types/level';
1717 */
1818
1919// https://regex101.com is your friend
20- const MASTER_PLAYLIST_REGEX = / (?: # E X T - X - S T R E A M - I N F : ( [ ^ \n \r ] * ) [ \r \n ] + ( [ ^ \r \n ] + ) | # E X T - X - S E S S I O N - D A T A : ( [ ^ \n \r ] * ) [ \r \n ] + ) / g;
20+ const MASTER_PLAYLIST_REGEX = / # E X T - X - S T R E A M - I N F : ( [ ^ \n \r ] * ) [ \r \n ] + ( [ ^ \r \n ] + ) | # E X T - X - S E S S I O N - D A T A : ( [ ^ \n \r ] * ) [ \r \n ] + / g;
2121const MASTER_PLAYLIST_MEDIA_REGEX = / # E X T - X - M E D I A : ( .* ) / g;
2222
2323const LEVEL_PLAYLIST_REGEX_FAST = new RegExp ( [
2424 / # E X T I N F : \s * ( \d * (?: \. \d + ) ? ) (?: , ( .* ) \s + ) ? / . source , // duration (#EXTINF:<duration>,<title>), group 1 => duration, group 2 => title
25- / | (? ! # ) ( [ \S + ? ] + ) / . source , // segment URI, group 3 => the URI (note newline is not eaten)
26- / | # E X T - X - B Y T E R A N G E : * ( .+ ) / . source , // next segment's byterange, group 4 => range spec (x@y)
27- / | # E X T - X - P R O G R A M - D A T E - T I M E : ( .+ ) / . source , // next segment's program date/time group 5 => the datetime spec
28- / | # .* / . source // All other non-segment oriented tags will match with all groups empty
29- ] . join ( '' ) , 'g' ) ;
30-
31- const LEVEL_PLAYLIST_REGEX_SLOW = / (?: (?: # ( E X T M 3 U ) ) | (?: # E X T - X - ( P L A Y L I S T - T Y P E ) : ( .+ ) ) | (?: # E X T - X - ( M E D I A - S E Q U E N C E ) : * ( \d + ) ) | (?: # E X T - X - ( T A R G E T D U R A T I O N ) : * ( \d + ) ) | (?: # E X T - X - ( K E Y ) : ( .+ ) ) | (?: # E X T - X - ( S T A R T ) : ( .+ ) ) | (?: # E X T - X - ( E N D L I S T ) ) | (?: # E X T - X - ( D I S C O N T I N U I T Y - S E Q ) U E N C E : * ( \d + ) ) | (?: # E X T - X - ( D I S ) C O N T I N U I T Y ) ) | (?: # E X T - X - ( P R E F E T C H - D I S ) C O N T I N U I T Y ) | (?: # E X T - X - ( P R E F E T C H ) : ( .+ ) ) | (?: # E X T - X - ( V E R S I O N ) : ( \d + ) ) | (?: # E X T - X - ( M A P ) : ( .+ ) ) | (?: ( # ) ( [ ^ : ] * ) : ( .* ) ) | (?: ( # ) ( .* ) ) (?: .* ) \r ? \n ? / ;
25+ / (? ! # ) ( [ \S + ? ] + ) / . source , // segment URI, group 3 => the URI (note newline is not eaten)
26+ / # E X T - X - B Y T E R A N G E : * ( .+ ) / . source , // next segment's byterange, group 4 => range spec (x@y)
27+ / # E X T - X - P R O G R A M - D A T E - T I M E : ( .+ ) / . source , // next segment's program date/time group 5 => the datetime spec
28+ / # .* / . source // All other non-segment oriented tags will match with all groups empty
29+ ] . join ( '|' ) , 'g' ) ;
30+
31+ const LEVEL_PLAYLIST_REGEX_SLOW = new RegExp ( [
32+ / # ( E X T M 3 U ) / . source ,
33+ / # E X T - X - ( P L A Y L I S T - T Y P E ) : ( .+ ) / . source ,
34+ / # E X T - X - ( M E D I A - S E Q U E N C E ) : * ( \d + ) / . source ,
35+ / # E X T - X - ( T A R G E T D U R A T I O N ) : * ( \d + ) / . source ,
36+ / # E X T - X - ( K E Y ) : ( .+ ) / . source ,
37+ / # E X T - X - ( S T A R T ) : ( .+ ) / . source ,
38+ / # E X T - X - ( E N D L I S T ) / . source ,
39+ / # E X T - X - ( D I S C O N T I N U I T Y - S E Q ) U E N C E : * ( \d + ) / . source ,
40+ / # E X T - X - ( D I S ) C O N T I N U I T Y / . source ,
41+ / # E X T - X - ( P R E F E T C H - D I S ) C O N T I N U I T Y / . source , // TODO: deprecate LHLS
42+ / # E X T - X - ( P R E F E T C H ) : ( .+ ) / . source , // TODO: deprecate LHLS
43+ / # E X T - X - ( V E R S I O N ) : ( \d + ) / . source ,
44+ / # E X T - X - ( M A P ) : ( .+ ) / . source ,
45+ / ( # ) ( [ ^ : ] * ) : ( .* ) / . source ,
46+ / ( # ) ( .* ) (?: .* ) \r ? \n ? / . source
47+ ] . join ( '|' ) ) ;
3248
3349const MP4_REGEX_SUFFIX = / \. ( m p 4 | m 4 s | m 4 v | m 4 a ) $ / i;
3450
0 commit comments