I have a M3U playlist file and I want to output the whole file as text using javascript. I found an example but it doesnt seem to work and im not sure its right for what I want to do, heres what im using. The m3u playlist is this http://siptv.app/lists/example.m3u
<div id="text"></div>
var playlist = 'http://siptv.app/lists/example.m3u';
function convertInto2KOM(m3u) {
return m3u
.replace('#EXTM3U', '')
.split('#EXTINF:0,')
.slice(1)
.map(function(str, index) {
var channel = str.split('\n').slice(0,-1);
return {
"id": index + 1,
"number": index + 1,
"caption": channel[0],
"icon_url": "",
"tv_categories": [2],
"streaming_url": channel[1],
"announce": "",
"volume_shift": 0
};
});
}
var parseM3U = convertInto2KOM(playlist);
console.log(parseM3U);
$('#text').append(parseM3U);