m3u8-file-parser
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -1,1 +0,1 @@ | ||
var M3U8FileParser=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t,r){"use strict";var n=r(1),a=/\"/g,s=r(17),i={YES:!0,NO:!0};function o(e){return e in i?i[e]:e}e.exports=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="",i="",c=arguments[2]||{},u=0;u<e.length;u++)switch(e[u].charCodeAt(0)){case n.SPACE:r="";continue;case n.EQUAL:i=r,r="";continue;case n.COMMA:(i=s(i))&&(c[i]=t?o(r):r),i="",r="";continue;case n.QUOTE:a.lastIndex=u+1;var E=a.exec(e),p=e.slice(u+1,E.index);i&&(c[s(i)]=p),u=E.index+1;continue;default:r+=e[u]}return r&&i&&(c[s(i)]=r),c}},function(e,t,r){"use strict";e.exports={SPACE:" ".charCodeAt(0),COLON:":".charCodeAt(0),COMMA:",".charCodeAt(0),EQUAL:"=".charCodeAt(0),QUOTE:'"'.charCodeAt(0),MINUS:"-".charCodeAt(0),PERIOD:".".charCodeAt(0),NEW_LINE_LF:"\n".charCodeAt(0),NEW_LINE_CR:"\r".charCodeAt(0),BACK_SLASH:"\\".charCodeAt(0),HASH:"#".charCodeAt(0),AT:"@".charCodeAt(0),NUMBER_START:"0".charCodeAt(0),NUMBER_STOP:"9".charCodeAt(0)}},function(e,t,r){"use strict";e.exports=function(e){var t=new Date(e.trim());return isNaN(t.getTime()),t}},function(e,t,r){"use strict";e.exports=function(e){var t={length:0,offset:0};t.length=parseInt(e);var r=e.lastIndexOf("@");return~r&&(t.offset=parseInt(e.slice(r+1))),t}},function(e,t,r){"use strict";e.exports={BASIC:"BASIC",MEDIA_SEGMENT:"MEDIA_SEGMENT",MEDIA_PLAYLIST:"MEDIA_PLAYLIST",MASTER_PLAYLIST:"MASTER_PLAYLIST",TRALING_MEDIA_SEGMENT:"TRAILING_MEDIA_SEGMENT",URL_SEGMENT_ENDING:"URL_SEGMENT_ENDING",GROUPING:"GROUPING"}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t=n(e,!0);return"timeOffset"in t&&(t.timeOffset=parseFloat(t.timeOffset)),t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t=n(e);return"bandwidth"in t&&(t.bandwidth=parseInt(t.bandwidth)),"averageBandwidth"in t&&(t.averageBandwidth=parseInt(t.averageBandwidth)),"resolution"in t&&(t.resolution=parseInt(t.resolution)),"frameRate"in t&&(t.frameRate=parseFloat(t.frameRate)),"codecs"in t&&(t.codecs=t.codecs.split(";")),t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t={groupId:"default"};return n(e,!0,t),t}},function(e,t,r){"use strict";e.exports=function(e){return e.trim()}},function(e,t,r){"use strict";e.exports=function(e,t){return t.segments.length+1}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||-1}},function(e,t,r){"use strict";var n=r(0),a=r(2);e.exports=function(e){var t=n(e);return t.startDate&&(t.startDate=a(t.startDate)),t.endDate&&(t.endDate=a(t.endDate)),t.duration&&(t.duration=parseFloat(t.duration)),t.plannedDuration&&(t.plannedDuration=parseFloat(t.plannedDuration)),t}},function(e,t,r){"use strict";var n=r(2);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";var n=r(3),a=r(0);e.exports=function(e){var t=a(e);return t.byterange&&(t.byterange=n(t.byterange)),t}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e){var t="";e=e.toLowerCase();for(var r=0;r<e.length;r++)e[r].charCodeAt(0)!==n.MINUS?t+=e[r]:t+=(e[++r]||"").toUpperCase();return t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";e.exports=function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e.trim())||0}},function(e,t,r){"use strict";var n=/\"/g,a=/\W/g,s=r(1);e.exports=function(e){var t="",r="",i={duration:"",title:""};n.lastIndex=0,a.lastIndex=0;for(var o=0,c=e[o].charCodeAt(0);c>=s.NUMBER_START&&c<=s.NUMBER_STOP||c===s.MINUS||c===s.PERIOD;)i.duration+=e[o],c=e[++o].charCodeAt(0);i.duration=i.duration&&parseFloat(i.duration)||-1;for(var u=o;u<e.length;u++)switch(e[u].charCodeAt(0)){case s.SPACE:r="";continue;case s.QUOTE:n.lastIndex=u+1;var E=n.exec(e);r=e.slice(u+1,E.index),u=E&&E.index||u,t&&(i[t]=r),r="",t="";continue;case s.EQUAL:if(t=r,r="",e[u+1].charCodeAt(0)===s.QUOTE)continue;a.lastIndex=u+1;var p=a.exec(e);r=e.slice(u+1,p.index),u=e[p.index].charCodeAt(0)===s.COMMA&&p.index-1||p&&p.index||u,t&&(i[t]=r),r="",t="";continue;case s.COMMA:i.title=e.slice(u+1,e.length).trimLeft(),u=e.length;continue;default:r+=e[u]}return i}},function(e,t,r){"use strict";var n=r(21),a=r(20),s=r(3),i=r(19),o=r(18),c=r(16),u=r(15),E=r(14),p=r(13),f=r(12),A=r(11),I=r(10),d=r(9),T=r(8),l=r(7),S=r(6),h=r(5),M=r(4),N={"#EXTM3U":{key:"isExtendedM3U",parser:function(){return!0},scope:M.BASIC},"#EXT-X-VERSION":{key:"version",parser:a,scope:M.BASIC},"#EXTINF":{key:"inf",parser:n,scope:M.MEDIA_SEGMENT},"#EXT-X-BYTERANGE":{key:"byteRange",parser:s,scope:M.MEDIA_SEGMENT},"#EXT-X-DISCONTINUITY":{key:"discontinuity",parser:i,scope:M.MEDIA_SEGMENT},"#EXT-X-KEY":{key:"key",parser:o,scope:M.TRALING_MEDIA_SEGMENT},"#EXT-X-MAP":{key:"map",parser:c,scope:M.TRALING_MEDIA_SEGMENT},"#EXT-X-PROGRAM-DATE-TIME":{key:"programDateTime",parser:u,scope:M.MEDIA_SEGMENT},"#EXT-X-DATERANGE":{key:"dateRange",parser:E,scope:M.MEDIA_SEGMENT},"#EXT-X-TARGETDURATION":{key:"targetDuration",parser:p,scope:M.MEDIA_PLAYLIST},"#EXT-X-MEDIA-SEQUENCE":{key:"mediaSequence",parser:f,scope:M.MEDIA_PLAYLIST},"#EXT-X-DISCONTINUITY-SEQUENCE":{key:"discontinuitySequence",parser:A,scope:M.MEDIA_PLAYLIST},"#EXT-X-ENDLIST":{key:"endList",parser:I,scope:M.MEDIA_PLAYLIST},"#EXT-X-PLAYLIST-TYPE":{key:"playlistType",parser:d,scope:M.MEDIA_PLAYLIST},"#EXT-X-I-FRAMES-ONLY":{key:"iFramesOnly",parser:function(){return!0},scope:M.MEDIA_PLAYLIST},"#EXT-X-MEDIA":{key:"media",parser:T,scope:M.GROUPING,group:{root:"media",path:["type","groupId","name"]}},"#EXT-X-STREAM-INF":{key:"streamInf",parser:l,scope:M.MASTER_PLAYLIST},"#EXT-X-I-FRAME-STREAM-INF":{key:"iFrameStreamInf",parser:l,scope:M.MASTER_PLAYLIST},"#EXT-X-SESSION-DATA":{key:"sessionData",parser:S,scope:M.GROUPING,group:{root:"sessionData",path:["dataId","language"]}},"#EXT-X-SESSION-KEY":{key:"sessionKey",parser:o,scope:M.MASTER_PLAYLIST},"#EXT-X-INDEPENDENT-SEGMENTS":{key:"independentSegments",parser:function(){return!0},scope:M.MEDIA_PLAYLIST},"#EXT-X-START":{key:"start",parser:h,scope:M.MEDIA_PLAYLIST},URL:{key:"url",parser:function(e){return e},scope:M.URL_SEGMENT_ENDING}};e.exports={get:function(e){return N[e]||null},set:function(e,t){N[e]=t},add:function(e,t){N[e]=t}}},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var a=r(4),s=(r(1),r(22)),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.default={isExtendedM3U:!1,segments:[]},this.trailingData={},this.currentSegmentData={},this.result=Object.assign({},this.default)}return n(e,[{key:"read",value:function(e){var t=e.length;e=e.trim();for(var r="",n=!1,a=!1,s=0,i=0,o=0,c="",u="",E=0;E<t;E++)s=(s=(i=e.indexOf("\n",E))>-1&&i||e.indexOf("\r",E))>-1&&s||t,c=u+e.slice(E,s).trim(),u="",E=s,a="#"===c[0],o=(n="#EXT"===c.slice(0,4))&&c.indexOf(":")||-1,(n&&c.lastIndexOf("\\")||-1)===c.length-1&&(u=c.slice(0,c.length-1),c=""),!(r=n&&~o&&c.slice(0,o))&&a&&(r=c),!u&&this.invokeParser(r,c.slice(o+1),a)}},{key:"invokeParser",value:function(e,t,r){if(e&&t){var n=s.get(e);return n?this.dataScope(n,n.parser(t,this.result)):void 0}if((!t||!r)&&t){var a=s.get("URL");this.dataScope(a,a.parser(t,this.result))}}},{key:"dataScope",value:function(e,t){switch(e.scope){case a.MASTER_PLAYLIST:this.currentSegmentData.isMasterPlaylist=!0;case a.MEDIA_SEGMENT:this.currentSegmentData[e.key]=t;break;case a.URL_SEGMENT_ENDING:this.currentSegmentData[e.key]=t,this.result.segments.push(this.currentSegmentData),this.currentSegmentData=Object.assign({},this.trailingData);break;case a.TRALING_MEDIA_SEGMENT:this.trailingData[e.key]=t,this.currentSegmentData=Object.assign(this.currentSegmentData,this.trailingData);break;case a.MEDIA_PLAYLIST:case a.BASIC:this.result[e.key]=t;break;case a.GROUPING:this.result[e.group.root]||(this.result[e.group.root]={});for(var r="",n=this.result[e.group.root],s=e.group.path.length,i=0;i<s-1;i++)n[t[r=e.group.path[i]]]||(n[t[r]]={}),n=n[t[r]];n[t[e.group.path[s-1]]]=t}}},{key:"getResult",value:function(){return this.result}},{key:"reset",value:function(){this.result=Object.assign({},this.default)}}]),e}();e.exports=i}]); | ||
var M3U8FileParser=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t,r){"use strict";var n=r(1),a=/\"/g,s=r(17),i={YES:!0,NO:!0};function o(e){return e in i?i[e]:e}e.exports=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="",i="",c=arguments[2]||{},u=0;u<e.length;u++)switch(e[u].charCodeAt(0)){case n.SPACE:r="";continue;case n.EQUAL:i=r,r="";continue;case n.COMMA:(i=s(i))&&(c[i]=t?o(r):r),i="",r="";continue;case n.QUOTE:a.lastIndex=u+1;var E=a.exec(e),p=e.slice(u+1,E.index);i&&(c[s(i)]=p),u=E.index+1;continue;default:r+=e[u]}return r&&i&&(c[s(i)]=r),c}},function(e,t,r){"use strict";e.exports={SPACE:" ".charCodeAt(0),COLON:":".charCodeAt(0),COMMA:",".charCodeAt(0),EQUAL:"=".charCodeAt(0),QUOTE:'"'.charCodeAt(0),MINUS:"-".charCodeAt(0),PERIOD:".".charCodeAt(0),NEW_LINE_LF:"\n".charCodeAt(0),NEW_LINE_CR:"\r".charCodeAt(0),BACK_SLASH:"\\".charCodeAt(0),HASH:"#".charCodeAt(0),AT:"@".charCodeAt(0),NUMBER_START:"0".charCodeAt(0),NUMBER_STOP:"9".charCodeAt(0)}},function(e,t,r){"use strict";e.exports=function(e){var t=new Date(e.trim());return isNaN(t.getTime()),t}},function(e,t,r){"use strict";e.exports=function(e){var t={length:0,offset:0};t.length=parseInt(e);var r=e.lastIndexOf("@");return~r&&(t.offset=parseInt(e.slice(r+1))),t}},function(e,t,r){"use strict";e.exports={BASIC:"BASIC",MEDIA_SEGMENT:"MEDIA_SEGMENT",MEDIA_PLAYLIST:"MEDIA_PLAYLIST",MASTER_PLAYLIST:"MASTER_PLAYLIST",TRALING_MEDIA_SEGMENT:"TRAILING_MEDIA_SEGMENT",URL_SEGMENT_ENDING:"URL_SEGMENT_ENDING",GROUPING:"GROUPING"}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t=n(e,!0);return"timeOffset"in t&&(t.timeOffset=parseFloat(t.timeOffset)),t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t=n(e);return"bandwidth"in t&&(t.bandwidth=parseInt(t.bandwidth)),"averageBandwidth"in t&&(t.averageBandwidth=parseInt(t.averageBandwidth)),"resolution"in t&&(t.resolution=parseInt(t.resolution)),"frameRate"in t&&(t.frameRate=parseFloat(t.frameRate)),"codecs"in t&&(t.codecs=t.codecs.split(";")),t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){var t={groupId:"default"};return n(e,!0,t),t}},function(e,t,r){"use strict";e.exports=function(e){return e.trim()}},function(e,t,r){"use strict";e.exports=function(e,t){return t.segments.length+1}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e)||-1}},function(e,t,r){"use strict";var n=r(0),a=r(2);e.exports=function(e){var t=n(e);return t.startDate&&(t.startDate=a(t.startDate)),t.endDate&&(t.endDate=a(t.endDate)),t.duration&&(t.duration=parseFloat(t.duration)),t.plannedDuration&&(t.plannedDuration=parseFloat(t.plannedDuration)),t}},function(e,t,r){"use strict";var n=r(2);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";var n=r(3),a=r(0);e.exports=function(e){var t=a(e);return t.byterange&&(t.byterange=n(t.byterange)),t}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e){var t="";e=e.toLowerCase();for(var r=0;r<e.length;r++)e[r].charCodeAt(0)!==n.MINUS?t+=e[r]:t+=(e[++r]||"").toUpperCase();return t}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e){return n(e)}},function(e,t,r){"use strict";e.exports=function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){return parseInt(e.trim())||0}},function(e,t,r){"use strict";var n=/\"/g,a=/\W/g,s=r(1);e.exports=function(e){var t="",r="",i={duration:"",title:""};n.lastIndex=0,a.lastIndex=0;for(var o=0,c=e[o].charCodeAt(0);c>=s.NUMBER_START&&c<=s.NUMBER_STOP||c===s.MINUS||c===s.PERIOD;)i.duration+=e[o],c=e[++o].charCodeAt(0);i.duration=i.duration&&parseFloat(i.duration)||-1;for(var u=o;u<e.length;u++)switch(e[u].charCodeAt(0)){case s.SPACE:r="";continue;case s.QUOTE:n.lastIndex=u+1;var E=n.exec(e);r=e.slice(u+1,E.index),u=E&&E.index||u,t&&(i[t]=r),r="",t="";continue;case s.EQUAL:if(t=r,r="",e[u+1].charCodeAt(0)===s.QUOTE)continue;a.lastIndex=u+1;var p=a.exec(e);r=e.slice(u+1,p.index),u=e[p.index].charCodeAt(0)===s.COMMA&&p.index-1||p&&p.index||u,t&&(i[t]=r),r="",t="";continue;case s.COMMA:i.title=e.slice(u+1,e.length).trimLeft(),u=e.length;continue;default:r+=e[u]}return i}},function(e,t,r){"use strict";var n=r(21),a=r(20),s=r(3),i=r(19),o=r(18),c=r(16),u=r(15),E=r(14),p=r(13),f=r(12),A=r(11),I=r(10),d=r(9),T=r(8),l=r(7),S=r(6),h=r(5),M=r(4),N={"#EXTM3U":{key:"isExtendedM3U",parser:function(){return!0},scope:M.BASIC},"#EXT-X-VERSION":{key:"version",parser:a,scope:M.BASIC},"#EXTINF":{key:"inf",parser:n,scope:M.MEDIA_SEGMENT},"#EXT-X-BYTERANGE":{key:"byteRange",parser:s,scope:M.MEDIA_SEGMENT},"#EXT-X-DISCONTINUITY":{key:"discontinuity",parser:i,scope:M.MEDIA_SEGMENT},"#EXT-X-KEY":{key:"key",parser:o,scope:M.TRALING_MEDIA_SEGMENT},"#EXT-X-MAP":{key:"map",parser:c,scope:M.TRALING_MEDIA_SEGMENT},"#EXT-X-PROGRAM-DATE-TIME":{key:"programDateTime",parser:u,scope:M.MEDIA_SEGMENT},"#EXT-X-DATERANGE":{key:"dateRange",parser:E,scope:M.MEDIA_SEGMENT},"#EXT-X-TARGETDURATION":{key:"targetDuration",parser:p,scope:M.MEDIA_PLAYLIST},"#EXT-X-MEDIA-SEQUENCE":{key:"mediaSequence",parser:f,scope:M.MEDIA_PLAYLIST},"#EXT-X-DISCONTINUITY-SEQUENCE":{key:"discontinuitySequence",parser:A,scope:M.MEDIA_PLAYLIST},"#EXT-X-ENDLIST":{key:"endList",parser:I,scope:M.MEDIA_PLAYLIST},"#EXT-X-PLAYLIST-TYPE":{key:"playlistType",parser:d,scope:M.MEDIA_PLAYLIST},"#EXT-X-I-FRAMES-ONLY":{key:"iFramesOnly",parser:function(){return!0},scope:M.MEDIA_PLAYLIST},"#EXT-X-MEDIA":{key:"media",parser:T,scope:M.GROUPING,group:{root:"media",path:["type","groupId","name"]}},"#EXT-X-STREAM-INF":{key:"streamInf",parser:l,scope:M.MASTER_PLAYLIST},"#EXT-X-I-FRAME-STREAM-INF":{key:"iFrameStreamInf",parser:l,scope:M.MASTER_PLAYLIST},"#EXT-X-SESSION-DATA":{key:"sessionData",parser:S,scope:M.GROUPING,group:{root:"sessionData",path:["dataId","language"]}},"#EXT-X-SESSION-KEY":{key:"sessionKey",parser:o,scope:M.MASTER_PLAYLIST},"#EXT-X-INDEPENDENT-SEGMENTS":{key:"independentSegments",parser:function(){return!0},scope:M.MEDIA_PLAYLIST},"#EXT-X-START":{key:"start",parser:h,scope:M.MEDIA_PLAYLIST},URL:{key:"url",parser:function(e){return e},scope:M.URL_SEGMENT_ENDING}};e.exports={get:function(e){return N[e]||null},set:function(e,t){N[e]=t},add:function(e,t){N[e]=t}}},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var a=r(4),s=(r(1),r(22)),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.default={isExtendedM3U:!1,segments:[]},this.trailingData={},this.currentSegmentData={},this.result=Object.assign({},this.default)}return n(e,[{key:"read",value:function(e){var t=e.length;e=e.trim();for(var r="",n=!1,a=!1,s=0,i=0,o=0,c="",u=0;u<t;u++)s=(s=(i=e.indexOf("\n",u))>-1&&i||e.indexOf("\r",u))>-1&&s||t,c=e.slice(u,s).trim(),u=s,a="#"===c[0],o=(n="#EXT"===c.slice(0,4))&&c.indexOf(":")||-1,!(r=n&&~o&&c.slice(0,o))&&a&&(r=c),this.invokeParser(r,c.slice(o+1),a)}},{key:"invokeParser",value:function(e,t,r){if(e&&t){var n=s.get(e);return n?this.dataScope(n,n.parser(t,this.result)):void 0}if((!t||!r)&&t){var a=s.get("URL");this.dataScope(a,a.parser(t,this.result))}}},{key:"dataScope",value:function(e,t){switch(e.scope){case a.MASTER_PLAYLIST:this.currentSegmentData.isMasterPlaylist=!0;case a.MEDIA_SEGMENT:this.currentSegmentData[e.key]=t;break;case a.URL_SEGMENT_ENDING:this.currentSegmentData[e.key]=t,this.result.segments.push(this.currentSegmentData),this.currentSegmentData=Object.assign({},this.trailingData);break;case a.TRALING_MEDIA_SEGMENT:this.trailingData[e.key]=t,this.currentSegmentData=Object.assign(this.currentSegmentData,this.trailingData);break;case a.MEDIA_PLAYLIST:case a.BASIC:this.result[e.key]=t;break;case a.GROUPING:this.result[e.group.root]||(this.result[e.group.root]={});for(var r="",n=this.result[e.group.root],s=e.group.path.length,i=0;i<s-1;i++)n[t[r=e.group.path[i]]]||(n[t[r]]={}),n=n[t[r]];n[t[e.group.path[s-1]]]=t}}},{key:"getResult",value:function(){return this.result}},{key:"reset",value:function(){this.result=Object.assign({},this.default)}}]),e}();e.exports=i}]); |
{ | ||
"name": "m3u8-file-parser", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A m3u8 file parser built against RFC8216", | ||
@@ -20,5 +20,3 @@ "main": "index.js", | ||
}, | ||
"dependencies": { | ||
}, | ||
"dependencies": {}, | ||
"repository": { | ||
@@ -25,0 +23,0 @@ "type": "git", |
# m3u8-file-parser | ||
A m3u/m3u8 file parser build against [RFC8219](https://tools.ietf.org/html/rfc8216) specs. | ||
A m3u/m3u8 file parser build against [RFC8216](https://tools.ietf.org/html/rfc8216) specs. | ||
@@ -131,3 +131,2 @@ ## Installation | ||
- Attributes in EXTINF, For example: `#EXTINF:10 example="hah", title` | ||
- '\' in EXT tags | ||
- Camel case conversion for attribute list | ||
@@ -392,2 +391,2 @@ | ||
MIT | ||
MIT |
@@ -0,0 +0,0 @@ const attrParser = require('./libs/attr') |
@@ -0,0 +0,0 @@ function mediaSequence(str) { |
@@ -0,0 +0,0 @@ function date(str) { |
@@ -35,6 +35,4 @@ const SCOPE = require('./parser/constants/scope'); | ||
let colonPosition = 0; | ||
let lineContinueSlashPosition = 0; | ||
let content = ''; | ||
let previousLine = ''; | ||
@@ -49,6 +47,4 @@ for (let pos = 0; pos < contentLength; pos++) { | ||
// should be the new line | ||
content = previousLine + str.slice(pos, crPosition).trim(); | ||
content = str.slice(pos, crPosition).trim(); | ||
previousLine = ''; | ||
pos = crPosition; | ||
@@ -61,8 +57,2 @@ | ||
// if is an EXT tag, allow \ and read the next line | ||
// as the same line | ||
lineContinueSlashPosition = (isExtTag && content.lastIndexOf('\\')) || -1; | ||
lineContinueSlashPosition === content.length - 1 && | ||
((previousLine = content.slice(0, content.length - 1)), (content = '')); | ||
tag = isExtTag && ~colonPosition && content.slice(0, colonPosition); | ||
@@ -72,4 +62,3 @@ !tag && isHashLeading && (tag = content); | ||
// invoke parser if read line finished | ||
!previousLine && | ||
this.invokeParser(tag, content.slice(colonPosition + 1), isHashLeading); | ||
this.invokeParser(tag, content.slice(colonPosition + 1), isHashLeading); | ||
} | ||
@@ -76,0 +65,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140254
36
627