优化m3u文件转换工具

This commit is contained in:
涵曦 2024-06-27 05:16:33 +00:00
parent 805b3c41c8
commit 4a234e8829

View File

@ -33,10 +33,11 @@ function convertToJSON() {
var musicsArray = []; var musicsArray = [];
var currentName = ''; var currentName = '';
lines.forEach(function(line) { lines.forEach(function(line) {
if (line.startsWith('#EXTINF:-1,')) { line = line.trim();
currentName = line.substring(11).trim(); if (line.startsWith('#EXTINF:')) {
currentName = line.replace(/.*,/g, '');
} else if (line.startsWith('http') && currentName !== '') { } else if (line.startsWith('http') && currentName !== '') {
musicsArray.push({"name": currentName, "type": "radio", "url": line.trim()}); musicsArray.push({"name": currentName, "type": "radio", "url": line});
currentName = ''; // Reset the name for the next entry currentName = ''; // Reset the name for the next entry
} }
}); });