// Name: yt-dlp Downloader // Description: Downloads a video from the active browser tab // Author: tayiorbeii import "@johnlindquist/kit" // Get the active browser tab const address = await getActiveTab() // Extract title, exit if not found let title = address?.title; if (!title) { await div("Could not get the current tab title"); exit(); } // Sanitize title for use as a filename title = title.replace(/[^a-z0-9\s]/gi, '').replace(/\s+/g, '-'); // Construct the downloads and video paths const downloadsPath = home('Downloads'); const videoPath = path.join(downloadsPath, title); // Ensure the video directory exists await ensureDir(videoPath); // Execute yt-dlp command in the video directory await term({ command: `yt-dlp ${address.url}`, cwd: videoPath, });