From 848283da42948519157dc0bc498fbedceebedb25 Mon Sep 17 00:00:00 2001 From: litruv Date: Mon, 24 Aug 2026 23:58:35 +1000 Subject: [PATCH] Add TikTok player embed Use TikTok's supported iframe player and safely invoke yt-dlp for YouTube streams. --- cinny | 2 +- electron/main.js | 47 ++++++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/cinny b/cinny index b16263b..862307e 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit b16263b481c9b8314e3eaf040341d3b831287ef7 +Subproject commit 862307ee7deba48770e8db141ecc807053a8836e diff --git a/electron/main.js b/electron/main.js index 64b4cdc..12461f4 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1425,49 +1425,54 @@ ipcMain.handle('play-notification-sound', async (event, soundType = 'message') = } }); -// Get YouTube stream using yt-dlp -ipcMain.handle('get-youtube-stream', async (event, url) => { +// Get a direct YouTube stream using yt-dlp. +async function getYouTubeStream(url) { try { - // Check if yt-dlp is available try { - await execAsync('yt-dlp --version'); + await execFileAsync('yt-dlp', ['--version']); } catch { - return { - success: false, - error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.' + return { + success: false, + error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.', }; } - // Get title let title = 'YouTube Video'; try { - const titleResult = await execAsync(`yt-dlp --get-title "${url}"`); + const titleResult = await execFileAsync('yt-dlp', ['--no-playlist', '--get-title', url]); title = titleResult.stdout.trim(); } catch (e) { console.warn('Failed to get video title:', e.message); } - // Get video URL - const result = await execAsync( - `yt-dlp -g -f "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best" "${url}"` - ); - + const result = await execFileAsync('yt-dlp', [ + '--no-playlist', + '-g', + '-f', + 'best[height<=1080]/bestvideo[height<=1080]+bestaudio/best', + url, + ]); const videoUrl = result.stdout.trim().split('\n')[0]; - + if (!videoUrl) { return { success: false, error: 'yt-dlp returned empty URL' }; } - return { - success: true, - data: { video_url: videoUrl, title } + return { + success: true, + data: { video_url: videoUrl, title }, }; } catch (error) { - return { - success: false, - error: `yt-dlp error: ${error.message}` + return { + success: false, + error: `yt-dlp error: ${error.message}`, }; } +} + +// Get YouTube stream using yt-dlp +ipcMain.handle('get-youtube-stream', async (event, url) => { + return getYouTubeStream(url); }); // Background sync stubs (desktop doesn't need it)