mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
Merge pull request #688 from 4gray/fix/playlist-use-file-basename-title
fix(playlist): use file basename as playlist title
This commit is contained in:
1 file changed
+6
-1
@@ -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.');
|
||||
|
||||
Reference in new issue
Block a user