From b4211a7d5044f74ec8b72688f7a41f199beb7ea8 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 12 Mar 2026 08:52:22 +0100 Subject: [PATCH] fix: use getMediaSourceId() for exact window capture Instead of enumerating all sources and matching by title (which falls back to full screen capture), use BrowserWindow.getMediaSourceId() to get the exact media source ID for the app window. Co-Authored-By: Claude Opus 4.6 --- main.js | 9 +++++++-- package.json | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index be5d1a1..f51cf73 100644 --- a/main.js +++ b/main.js @@ -1090,11 +1090,16 @@ ipcMain.handle('remote:get-capture-source-id', async () => { debugLog('remote: capture source - mainWindow not available'); return null; } + // Use getMediaSourceId() for exact window capture without enumeration + const sourceId = mainWindow.getMediaSourceId(); + debugLog('remote: capture source - getMediaSourceId:', sourceId); + if (sourceId) return sourceId; + + // Fallback: enumerate sources const { desktopCapturer } = require('electron'); const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] }); const title = mainWindow.getTitle(); - debugLog('remote: capture source - looking for title:', title, 'available:', sources.map(s => s.name).join(', ')); - // Try exact title match first, then partial match, then fall back to first screen + debugLog('remote: capture source - fallback, looking for title:', title); let source = sources.find(s => s.name === title); if (!source) source = sources.find(s => s.name.includes('Multi-Hoster')); if (!source) source = sources.find(s => s.id.startsWith('screen:')); diff --git a/package.json b/package.json index 11e6889..28ae785 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "multi-hoster-uploader", - "version": "2.1.6", + "version": "2.1.7", "description": "Upload files to doodstream, voe, vidmoly, byse simultaneously", "main": "main.js", "scripts": {