From 7761406fb55a2334cf7e24885da559a4c704a693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9Frul=20Topuz?= Date: Tue, 7 Sep 2021 20:14:11 +0300 Subject: [PATCH] EXT-X-DISCONTINUITY-SEQUENCE and EXT-X-PROGRAM-DATE-TIME properties --- m3u.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/m3u.js b/m3u.js index 7c18a9e..e326bb6 100644 --- a/m3u.js +++ b/m3u.js @@ -96,7 +96,7 @@ M3U.prototype.toString = function toString() { var tagKey = propertyMap.findByKey(key); var tag = tagKey ? tagKey.tag : key; - if (dataTypes[key] == 'boolean') { + if (dataTypes[key] === 'boolean') { output.push('#' + tag); } else { output.push('#' + tag + ':' + self.get(key)); @@ -161,25 +161,32 @@ var coerce = { }, unknown: function coerceUnknown(value) { return value; + }, + datetime: function coerceDatetime(value) { + return new Date(value); } }; var dataTypes = { - iframesOnly : 'boolean', - independentSegments : 'boolean', - targetDuration : 'integer', - mediaSequence : 'integer', - version : 'integer' + iframesOnly : 'boolean', + independentSegments : 'boolean', + targetDuration : 'integer', + mediaSequence : 'integer', + version : 'integer', + discontinuitySequence : 'integer', + programDateTime : 'datetime' }; var propertyMap = [ - { tag: 'EXT-X-ALLOW-CACHE', key: 'allowCache' }, - { tag: 'EXT-X-I-FRAMES-ONLY', key: 'iframesOnly' }, - { tag: 'EXT-X-INDEPENDENT-SEGMENTS', key: 'independentSegments' }, - { tag: 'EXT-X-MEDIA-SEQUENCE', key: 'mediaSequence' }, - { tag: 'EXT-X-PLAYLIST-TYPE', key: 'playlistType' }, - { tag: 'EXT-X-TARGETDURATION', key: 'targetDuration' }, - { tag: 'EXT-X-VERSION', key: 'version' } + { tag: 'EXT-X-ALLOW-CACHE', key: 'allowCache' }, + { tag: 'EXT-X-I-FRAMES-ONLY', key: 'iframesOnly' }, + { tag: 'EXT-X-INDEPENDENT-SEGMENTS', key: 'independentSegments' }, + { tag: 'EXT-X-MEDIA-SEQUENCE', key: 'mediaSequence' }, + { tag: 'EXT-X-PLAYLIST-TYPE', key: 'playlistType' }, + { tag: 'EXT-X-TARGETDURATION', key: 'targetDuration' }, + { tag: 'EXT-X-VERSION', key: 'version' }, + { tag: 'EXT-X-DISCONTINUITY-SEQUENCE', key: 'discontinuitySequence' }, + { tag: 'EXT-X-PROGRAM-DATE-TIME', key: 'programDateTime' } ]; propertyMap.findByTag = function findByTag(tag) {