File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
apps/electron-backend/src/app/events Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { dialog, ipcMain } from 'electron';
88import { parse } from 'iptv-playlist-parser' ;
99import { createPlaylistObject , getFilenameFromUrl } from 'm3u-utils' ;
1010import { readFile , writeFile } from 'node:fs/promises' ;
11+ import { basename } from 'node:path' ;
1112import { AUTO_UPDATE_PLAYLISTS } from 'shared-interfaces' ;
1213
1314export 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 ( / \. ( m 3 u 8 ? | p l s | t x t ) $ / 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.' ) ;
You can’t perform that action at this time.
0 commit comments