Closed PhamMinhKha closed 11 months ago
Hi friend, can you provide please some m3u example for this?
http://gg.gg/phimiptv but you need set user agent is "OTT Navigator/1.6.8.3 (Linux;Android ANDVER; vn; HASH)'" or you can see raw file is here https://raw.githubusercontent.com/PhamMinhKha/m3u-parser-generator/main/test.m3u8 Thank you so much
Can you copy the desired line from that file and paste it here, please?
i know this m3u8 file has an error somewhere but i don't know and i hope i can ignore that error line
I added ignoreErrors
argument for parsing. It is released now under v1.4.0.
See documentation: https://m3u-parser-generator.netlify.app/classes/m3uparser#parse
Thanks for adding the option to ignore errors. But still error
TypeError: Cannot read properties of undefined (reading 'replace')
at /Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:27:42
at Array.forEach (<anonymous>)
at M3uParser.getAttributes (/Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:22:28)
at M3uParser.processMedia (/Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:46:33)
at M3uParser.processDirective (/Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:62:22)
at /Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:87:22
at Array.forEach (<anonymous>)
at M3uParser.getPlaylist (/Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:85:15)
at M3uParser.parse (/Users/phamkha/Desktop/apptv/node_modules/m3u-parser-generator/dist/m3u-parser.js:136:21)
at eval (webpack-internal:///./src/pages/xemphim/index.tsx:59:82)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
i change your code like that it work
static getAttributes(attributesString, ignoreErrors) {
const attributes = new m3u_playlist_1.M3uAttributes();
if (!attributesString) {
return attributes;
}
const attributeValuePair = attributesString.split('" ');
attributeValuePair.forEach((item) => {
const [key, value] = item.split('="');
try {
if (!ignoreErrors && value == null) {
throw new Error(`Attribute value can't be null!`);
}
attributes[key] = value.replace('"', '');
} catch (error) {
if (ignoreErrors) {
console.warn(error);
} else {
throw new Error(`Attribute value can't be null!`);
}
}
});
return attributes;
}
@PhamMinhKha that is the reason why I needed an example. You can reopen issue, if you need and I can try fix it again, or you can fix it and open PR.
@PhamMinhKha I released v1.4.1 which should be really able to parse also invalid playlists.
Thank you. Your project is awesome
please add option skip error "throw new Error(
Attribute value can't be null!
);"