From f10c8b5990c2e9381721e640be9879729334a796 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 14 Dec 2025 17:53:54 +0100 Subject: [PATCH] fix(playlist): use file basename as playlist title Extract the file's basename and strip common playlist extensions before passing it as the playlist title when loading from a selected file. This replaces the previous hardcoded "from file" title with a cleaner, context-aware name derived from the file path. - import basename from node:path - compute filename and remove .m3u, .m3u8, .pls, .txt extensions - fall back to "from file" if resulting title is empty This improves UX by giving imported playlists meaningful names. --- apps/electron-backend/src/app/events/playlist.events.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/electron-backend/src/app/events/playlist.events.ts b/apps/electron-backend/src/app/events/playlist.events.ts index d858f2cf2..171ef5a84 100644 --- a/apps/electron-backend/src/app/events/playlist.events.ts +++ b/apps/electron-backend/src/app/events/playlist.events.ts @@ -8,6 +8,7 @@ import { dialog, ipcMain } from 'electron'; import { parse } from 'iptv-playlist-parser'; import { createPlaylistObject, getFilenameFromUrl } from 'm3u-utils'; import { readFile, writeFile } from 'node:fs/promises'; +import { basename } from 'node:path'; import { AUTO_UPDATE_PLAYLISTS } from 'shared-interfaces'; export default class PlaylistEvents { @@ -110,7 +111,11 @@ ipcMain.handle('open-playlist-from-file', async () => { const filePath = filePaths[0]; try { - return await fetchPlaylistFromFile(filePath, 'from file'); + // Extract filename from path and remove extension for a clean title + const filename = basename(filePath); + const title = filename.replace(/\.(m3u8?|pls|txt)$/i, '') || 'from file'; + + return await fetchPlaylistFromFile(filePath, title); } catch (error) { console.error('Error reading or parsing the file:', error); throw new Error('Failed to process the selected file.');