Fix fetch m3u failed when m3u file without extinf.

This commit is contained in:
Moon3r
2025-07-21 10:16:42 +08:00
parent 1c9b3b2553
commit 809422f702

View File

@@ -15,8 +15,8 @@ export const parseM3U = (m3uText: string): Channel[] => {
for (const line of lines) {
const trimmedLine = line.trim();
currentChannelInfo = { id: '', name: '', url: '', logo: '', group: '' };
if (trimmedLine.startsWith('#EXTINF:')) {
currentChannelInfo = { id: '', name: '', url: '', logo: '', group: '' };
const commaIndex = trimmedLine.indexOf(',');
if (commaIndex !== -1) {
currentChannelInfo.name = trimmedLine.substring(commaIndex + 1).trim();
@@ -32,7 +32,6 @@ export const parseM3U = (m3uText: string): Channel[] => {
currentChannelInfo.url = trimmedLine;
currentChannelInfo.id = currentChannelInfo.url; // Use URL as ID
parsedChannels.push(currentChannelInfo as Channel);
currentChannelInfo = null;
}
}
return parsedChannels;
@@ -67,4 +66,4 @@ export const getPlayableUrl = (originalUrl: string | null): string | null => {
}
// HTTPS streams can be played directly.
return originalUrl;
};
};