Skip to content

Commit d391514

Browse files
authored
Merge pull request #688 from 4gray/fix/playlist-use-file-basename-title
fix(playlist): use file basename as playlist title
2 parents ebc085c + f10c8b5 commit d391514

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/electron-backend/src/app/events/playlist.events.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { dialog, ipcMain } from 'electron';
88
import { parse } from 'iptv-playlist-parser';
99
import { createPlaylistObject, getFilenameFromUrl } from 'm3u-utils';
1010
import { readFile, writeFile } from 'node:fs/promises';
11+
import { basename } from 'node:path';
1112
import { AUTO_UPDATE_PLAYLISTS } from 'shared-interfaces';
1213

1314
export default class PlaylistEvents {
@@ -110,7 +111,11 @@ ipcMain.handle('open-playlist-from-file', async () => {
110111
const filePath = filePaths[0];
111112

112113
try {
113-
return await fetchPlaylistFromFile(filePath, 'from file');
114+
// Extract filename from path and remove extension for a clean title
115+
const filename = basename(filePath);
116+
const title = filename.replace(/\.(m3u8?|pls|txt)$/i, '') || 'from file';
117+
118+
return await fetchPlaylistFromFile(filePath, title);
114119
} catch (error) {
115120
console.error('Error reading or parsing the file:', error);
116121
throw new Error('Failed to process the selected file.');

0 commit comments

Comments
 (0)