Skip to content

Commit

Permalink
enable 'dot-notation' rule
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Sep 28, 2019
1 parent eb16793 commit 1b5de9d
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = {
'no-undefined': 1,
'no-global-assign': 2,
'prefer-const': 2,
'dot-notation': 0,
'dot-notation': 2,
'array-bracket-spacing': 2,
'quote-props': 2,
'no-void': 0,
Expand Down
28 changes: 14 additions & 14 deletions src/loader/m3u8-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export default class M3U8Parser {
level.height = resolution.height;
}
level.bitrate = attrs.decimalInteger('AVERAGE-BANDWIDTH') || attrs.decimalInteger('BANDWIDTH');
level.name = attrs['NAME'];
level.name = attrs.NAME;

setCodecs([].concat((attrs['CODECS'] || '').split(/[ ,]+/)), level);
setCodecs([].concat((attrs.CODECS || '').split(/[ ,]+/)), level);

if (level.videoCodec && level.videoCodec.indexOf('avc1') !== -1) {
level.videoCodec = M3U8Parser.convertAVC1ToAVCOTI(level.videoCodec);
Expand All @@ -114,21 +114,21 @@ export default class M3U8Parser {
MASTER_PLAYLIST_MEDIA_REGEX.lastIndex = 0;
while ((result = MASTER_PLAYLIST_MEDIA_REGEX.exec(string)) !== null) {
const attrs = new AttrList(result[1]);
if (attrs['TYPE'] === type) {
if (attrs.TYPE === type) {
const media: MediaPlaylist = {
id: id++,
groupId: attrs['GROUP-ID'],
instreamId: attrs['INSTREAM-ID'],
name: attrs['NAME'] || attrs['LANGUAGE'],
name: attrs.NAME || attrs.LANGUAGE,
type,
default: (attrs['DEFAULT'] === 'YES'),
autoselect: (attrs['AUTOSELECT'] === 'YES'),
forced: (attrs['FORCED'] === 'YES'),
lang: attrs['LANGUAGE']
default: (attrs.DEFAULT === 'YES'),
autoselect: (attrs.AUTOSELECT === 'YES'),
forced: (attrs.FORCED === 'YES'),
lang: attrs.LANGUAGE
};

if (attrs['URI']) {
media.url = M3U8Parser.resolve(attrs['URI'], baseurl);
if (attrs.URI) {
media.url = M3U8Parser.resolve(attrs.URI, baseurl);
}

if (audioGroups.length) {
Expand Down Expand Up @@ -283,7 +283,7 @@ export default class M3U8Parser {
const decryptparams = value1;
const keyAttrs = new AttrList(decryptparams);
const decryptmethod = keyAttrs.enumeratedString('METHOD');
const decrypturi = keyAttrs['URI'];
const decrypturi = keyAttrs.URI;
const decryptiv = keyAttrs.hexadecimalInteger('IV');

if (decryptmethod) {
Expand All @@ -308,9 +308,9 @@ export default class M3U8Parser {
}
case 'MAP': {
const mapAttrs = new AttrList(value1);
frag.relurl = mapAttrs['URI'];
if (mapAttrs['BYTERANGE']) {
frag.setByteRange(mapAttrs['BYTERANGE']);
frag.relurl = mapAttrs.URI;
if (mapAttrs.BYTERANGE) {
frag.setByteRange(mapAttrs.BYTERANGE);
}
frag.baseurl = baseurl;
frag.level = id;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/controller/buffer-controller-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('BufferController SourceBuffer operation queueing', function () {
expect(buffer.ended, `The ${name} buffer should not be marked as true if an append occurred`).to.be.false;
expect(buffer.appendBuffer, 'appendBuffer should have been called with the remuxed data').to.have.been.calledWith(segmentData);
expect(triggerSpy, 'BUFFER_APPENDED should be triggered upon completion of the operation')
.to.have.been.calledWith(Events.BUFFER_APPENDED, { parent: 'main', timeRanges: { audio: buffers['audio'].buffered, video: buffers['video'].buffered }, chunkMeta });
.to.have.been.calledWith(Events.BUFFER_APPENDED, { parent: 'main', timeRanges: { audio: buffers.audio.buffered, video: buffers.video.buffered }, chunkMeta });
expect(shiftAndExecuteNextSpy, 'The queue should have been cycled').to.have.callCount(i + 1);
});
});
Expand Down
32 changes: 16 additions & 16 deletions tests/unit/controller/fragment-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('FragmentTracker', function () {
]);

const timeRanges = {};
timeRanges['video'] = buffered;
timeRanges['audio'] = buffered;
timeRanges.video = buffered;
timeRanges.audio = buffered;
hls.trigger(Event.BUFFER_APPENDED, { timeRanges });

hls.trigger(Event.FRAG_BUFFERED, { stats: { aborted: true }, id: 'main', frag: fragment });
Expand Down Expand Up @@ -117,8 +117,8 @@ describe('FragmentTracker', function () {
]);

timeRanges = {};
timeRanges['video'] = buffered;
timeRanges['audio'] = buffered;
timeRanges.video = buffered;
timeRanges.audio = buffered;
hls.trigger(Event.BUFFER_APPENDED, { timeRanges });

hls.trigger(Event.FRAG_BUFFERED, { stats: { aborted: true }, id: 'main', frag: fragment });
Expand All @@ -135,8 +135,8 @@ describe('FragmentTracker', function () {
}
]);
timeRanges = {};
timeRanges['video'] = buffered;
timeRanges['audio'] = buffered;
timeRanges.video = buffered;
timeRanges.audio = buffered;
hls.trigger(Event.BUFFER_APPENDED, { timeRanges });

hls.trigger(Event.FRAG_BUFFERED, { stats: { aborted: true }, id: 'main', frag: fragment });
Expand All @@ -153,8 +153,8 @@ describe('FragmentTracker', function () {
}
]);
timeRanges = {};
timeRanges['video'] = buffered;
timeRanges['audio'] = buffered;
timeRanges.video = buffered;
timeRanges.audio = buffered;
hls.trigger(Event.BUFFER_APPENDED, { timeRanges });

hls.trigger(Event.FRAG_BUFFERED, { stats: { aborted: true }, id: 'main', frag: fragment });
Expand All @@ -169,8 +169,8 @@ describe('FragmentTracker', function () {
}
]);
timeRanges = {};
timeRanges['video'] = buffered;
timeRanges['audio'] = buffered;
timeRanges.video = buffered;
timeRanges.audio = buffered;
hls.trigger(Event.BUFFER_APPENDED, { timeRanges });

expect(fragmentTracker.getState(fragment)).to.equal(FragmentState.NOT_LOADED);
Expand Down Expand Up @@ -306,13 +306,13 @@ describe('FragmentTracker', function () {
hls.trigger(Event.FRAG_LOADED, { frag: fragment });

timeRanges = {};
timeRanges['video'] = createMockBuffer([
timeRanges.video = createMockBuffer([
{
startPTS: 0,
endPTS: 2
}
]);
timeRanges['audio'] = createMockBuffer([
timeRanges.audio = createMockBuffer([
{
startPTS: 0.5,
endPTS: 2
Expand All @@ -336,13 +336,13 @@ describe('FragmentTracker', function () {
hls.trigger(Event.FRAG_LOADED, { frag: fragment });

timeRanges = {};
timeRanges['video'] = createMockBuffer([
timeRanges.video = createMockBuffer([
{
startPTS: 0.5,
endPTS: 2
}
]);
timeRanges['audio'] = createMockBuffer([
timeRanges.audio = createMockBuffer([
{
startPTS: 0,
endPTS: 2
Expand All @@ -366,13 +366,13 @@ describe('FragmentTracker', function () {
hls.trigger(Event.FRAG_LOADED, { frag: fragment });

timeRanges = {};
timeRanges['video'] = createMockBuffer([
timeRanges.video = createMockBuffer([
{
startPTS: 0.5,
endPTS: 2
}
]);
timeRanges['audio'] = createMockBuffer([
timeRanges.audio = createMockBuffer([
{
startPTS: 0,
endPTS: 2
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/controller/timeline-controller-nonnative.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('Non-Native TimelineController functions', function () {
expect(track._id).to.equal('textTrack1');
expect(track.kind).to.equal('captions');
expect(track.default).to.equal(false);
expect(track.label).to.equal(timelineController.captionsProperties['textTrack1'].label);
expect(timelineController.captionsTracks['textTrack1']).to.equal(track);
expect(track.label).to.equal(timelineController.captionsProperties.textTrack1.label);
expect(timelineController.captionsTracks.textTrack1).to.equal(track);
done();
});

Expand Down
104 changes: 52 additions & 52 deletions tests/unit/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/

const result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result).to.have.lengthOf(1);
expect(result[0]['bitrate']).to.equal(836280);
expect(result[0]['audioCodec']).to.equal('mp4a.40.2');
expect(result[0]['videoCodec']).to.equal('avc1.64001f');
expect(result[0]['width']).to.equal(848);
expect(result[0]['height']).to.equal(360);
expect(result[0]['name']).to.equal('480');
expect(result[0]['url']).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
expect(result[0].bitrate).to.equal(836280);
expect(result[0].audioCodec).to.equal('mp4a.40.2');
expect(result[0].videoCodec).to.equal('avc1.64001f');
expect(result[0].width).to.equal(848);
expect(result[0].height).to.equal(360);
expect(result[0].name).to.equal('480');
expect(result[0].url).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
});

it('parses manifest without codecs', function () {
Expand All @@ -35,13 +35,13 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/

const result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result.length, 1);
expect(result[0]['bitrate']).to.equal(836280);
expect(result[0]['audioCodec']).to.not.exist;
expect(result[0]['videoCodec']).to.not.exist;
expect(result[0]['width']).to.equal(848);
expect(result[0]['height']).to.equal(360);
expect(result[0]['name']).to.equal('480');
expect(result[0]['url']).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
expect(result[0].bitrate).to.equal(836280);
expect(result[0].audioCodec).to.not.exist;
expect(result[0].videoCodec).to.not.exist;
expect(result[0].width).to.equal(848);
expect(result[0].height).to.equal(360);
expect(result[0].name).to.equal('480');
expect(result[0].url).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
});

it('does not care about the attribute order', function () {
Expand All @@ -51,41 +51,41 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/

let result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result.length, 1);
expect(result[0]['bitrate'], 836280);
expect(result[0]['audioCodec'], 'mp4a.40.2');
expect(result[0]['videoCodec'], 'avc1.64001f');
expect(result[0]['width'], 848);
expect(result[0]['height'], 360);
expect(result[0]['name'], '480');
expect(result[0]['url'], 'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
expect(result[0].bitrate, 836280);
expect(result[0].audioCodec, 'mp4a.40.2');
expect(result[0].videoCodec, 'avc1.64001f');
expect(result[0].width, 848);
expect(result[0].height, 360);
expect(result[0].name, '480');
expect(result[0].url, 'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');

manifest = `#EXTM3U
#EXT-X-STREAM-INF:NAME="480",RESOLUTION=848x360,PROGRAM-ID=1,BANDWIDTH=836280,CODECS="mp4a.40.2,avc1.64001f"
http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core`;

result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result.length, 1);
expect(result[0]['bitrate']).to.equal(836280);
expect(result[0]['audioCodec']).to.equal('mp4a.40.2');
expect(result[0]['videoCodec']).to.equal('avc1.64001f');
expect(result[0]['width']).to.equal(848);
expect(result[0]['height']).to.equal(360);
expect(result[0]['name']).to.equal('480');
expect(result[0]['url']).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
expect(result[0].bitrate).to.equal(836280);
expect(result[0].audioCodec).to.equal('mp4a.40.2');
expect(result[0].videoCodec).to.equal('avc1.64001f');
expect(result[0].width).to.equal(848);
expect(result[0].height).to.equal(360);
expect(result[0].name).to.equal('480');
expect(result[0].url).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');

manifest = `#EXTM3U
#EXT-X-STREAM-INF:CODECS="mp4a.40.2,avc1.64001f",NAME="480",RESOLUTION=848x360,PROGRAM-ID=1,BANDWIDTH=836280
http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core`;

result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result).to.have.lengthOf(1);
expect(result[0]['bitrate']).to.equal(836280);
expect(result[0]['audioCodec']).to.equal('mp4a.40.2');
expect(result[0]['videoCodec']).to.equal('avc1.64001f');
expect(result[0]['width']).to.equal(848);
expect(result[0]['height']).to.equal(360);
expect(result[0]['name']).to.equal('480');
expect(result[0]['url']).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
expect(result[0].bitrate).to.equal(836280);
expect(result[0].audioCodec).to.equal('mp4a.40.2');
expect(result[0].videoCodec).to.equal('avc1.64001f');
expect(result[0].width).to.equal(848);
expect(result[0].height).to.equal(360);
expect(result[0].name).to.equal('480');
expect(result[0].url).to.equal('http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core');
});

it('parses manifest with 10 levels', function () {
Expand Down Expand Up @@ -113,16 +113,16 @@ http://proxy-21.dailymotion.com/sec(2a991e17f08fcd94f95637a6dd718ddd)/video/107/

const result = M3U8Parser.parseMasterPlaylist(manifest, 'http://www.dailymotion.com');
expect(result.length, 10);
expect(result[0]['bitrate']).to.equal(836280);
expect(result[1]['bitrate']).to.equal(836280);
expect(result[2]['bitrate']).to.equal(246440);
expect(result[3]['bitrate']).to.equal(246440);
expect(result[4]['bitrate']).to.equal(460560);
expect(result[5]['bitrate']).to.equal(460560);
expect(result[6]['bitrate']).to.equal(2149280);
expect(result[7]['bitrate']).to.equal(2149280);
expect(result[8]['bitrate']).to.equal(6221600);
expect(result[9]['bitrate']).to.equal(6221600);
expect(result[0].bitrate).to.equal(836280);
expect(result[1].bitrate).to.equal(836280);
expect(result[2].bitrate).to.equal(246440);
expect(result[3].bitrate).to.equal(246440);
expect(result[4].bitrate).to.equal(460560);
expect(result[5].bitrate).to.equal(460560);
expect(result[6].bitrate).to.equal(2149280);
expect(result[7].bitrate).to.equal(2149280);
expect(result[8].bitrate).to.equal(6221600);
expect(result[9].bitrate).to.equal(6221600);
});

it('parses empty levels returns empty fragment array', function () {
Expand Down Expand Up @@ -495,13 +495,13 @@ lo007ts`;
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="600k",LANGUAGE="eng",NAME="Audio",AUTOSELECT=YES,DEFAULT=YES,URI="/videos/ZakEbrahim_2014/audio/600k.m3u8?qr=true&preroll=Blank",BANDWIDTH=614400`;
const result = M3U8Parser.parseMasterPlaylistMedia(manifest, 'https://hls.ted.com/', 'AUDIO');
expect(result.length, 1);
expect(result[0]['autoselect']).to.be.true;
expect(result[0]['default']).to.be.true;
expect(result[0]['forced']).to.be.false;
expect(result[0]['groupId']).to.equal('600k');
expect(result[0]['lang']).to.equal('eng');
expect(result[0]['name']).to.equal('Audio');
expect(result[0]['url']).to.equal('https://hls.ted.com/videos/ZakEbrahim_2014/audio/600k.m3u8?qr=true&preroll=Blank');
expect(result[0].autoselect).to.be.true;
expect(result[0].default).to.be.true;
expect(result[0].forced).to.be.false;
expect(result[0].groupId).to.equal('600k');
expect(result[0].lang).to.equal('eng');
expect(result[0].name).to.equal('Audio');
expect(result[0].url).to.equal('https://hls.ted.com/videos/ZakEbrahim_2014/audio/600k.m3u8?qr=true&preroll=Blank');
});
// issue #425 - first fragment has null url and no decryptdata if EXT-X-KEY follows EXTINF
it('parse level with #EXT-X-KEY after #EXTINF', function () {
Expand Down

0 comments on commit 1b5de9d

Please sign in to comment.