Add TikTok player embed
Some checks failed
Build / increment-version (push) Successful in 13s
Build / prepare-release (push) Successful in 14s
Build / build-linux (push) Has been cancelled
Build / finalize-release (push) Has been cancelled
Build / build-windows (push) Has been cancelled

Use TikTok's supported iframe player and safely invoke yt-dlp for YouTube streams.
This commit is contained in:
2026-08-24 23:58:35 +10:00
parent 2cd9409e3d
commit 848283da42
2 changed files with 27 additions and 22 deletions

2
cinny

Submodule cinny updated: b16263b481...862307ee7d

View File

@@ -1425,49 +1425,54 @@ ipcMain.handle('play-notification-sound', async (event, soundType = 'message') =
} }
}); });
// Get YouTube stream using yt-dlp // Get a direct YouTube stream using yt-dlp.
ipcMain.handle('get-youtube-stream', async (event, url) => { async function getYouTubeStream(url) {
try { try {
// Check if yt-dlp is available
try { try {
await execAsync('yt-dlp --version'); await execFileAsync('yt-dlp', ['--version']);
} catch { } catch {
return { return {
success: false, success: false,
error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.' error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.',
}; };
} }
// Get title
let title = 'YouTube Video'; let title = 'YouTube Video';
try { 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(); title = titleResult.stdout.trim();
} catch (e) { } catch (e) {
console.warn('Failed to get video title:', e.message); console.warn('Failed to get video title:', e.message);
} }
// Get video URL const result = await execFileAsync('yt-dlp', [
const result = await execAsync( '--no-playlist',
`yt-dlp -g -f "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best" "${url}"` '-g',
); '-f',
'best[height<=1080]/bestvideo[height<=1080]+bestaudio/best',
url,
]);
const videoUrl = result.stdout.trim().split('\n')[0]; const videoUrl = result.stdout.trim().split('\n')[0];
if (!videoUrl) { if (!videoUrl) {
return { success: false, error: 'yt-dlp returned empty URL' }; return { success: false, error: 'yt-dlp returned empty URL' };
} }
return { return {
success: true, success: true,
data: { video_url: videoUrl, title } data: { video_url: videoUrl, title },
}; };
} catch (error) { } catch (error) {
return { return {
success: false, success: false,
error: `yt-dlp error: ${error.message}` 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) // Background sync stubs (desktop doesn't need it)