diff --git a/electron/main.js b/electron/main.js index cd1c55f..bfeab92 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1475,6 +1475,28 @@ ipcMain.handle('get-youtube-stream', async (event, url) => { return getYouTubeStream(url); }); +// TikTok oEmbed. TikTok blocks the Electron user agent, so this runs in the main +// process with a plain browser UA and is not subject to CORS. +ipcMain.handle('tiktok:oembed', async (event, url) => { + try { + const response = await fetch(`https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`, { + headers: { + 'User-Agent': + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + Accept: 'application/json', + }, + }); + if (!response.ok) { + console.warn('[tiktok:oembed]', response.status, url); + return null; + } + return await response.json(); + } catch (error) { + console.warn('[tiktok:oembed] failed:', error?.message || error); + return null; + } +}); + // Background sync stubs (desktop doesn't need it) ipcMain.handle('start-background-sync', async () => { return { success: true }; diff --git a/electron/preload.js b/electron/preload.js index 32e2cd4..8b4ec64 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -124,6 +124,11 @@ contextBridge.exposeInMainWorld('electron', { youtube: { getStream: (url) => ipcRenderer.invoke('get-youtube-stream', url) }, + + // TikTok oEmbed (fetched in the main process) + tiktok: { + getOEmbed: (url) => ipcRenderer.invoke('tiktok:oembed', url) + }, // Background sync (stubs for desktop) sync: {