// Name: Video Study Notes Generator // Description: Records screen, transcribes content, and generates structured study notes // Author: johnlindquist // Twitter: @johnlindquist import '@johnlindquist/kit' // Setup recording directory const recordingsPath = createPathResolver(kenvPath('study-recordings')) await ensureDir(recordingsPath()) // Get study topic from user const studyTopic = await arg('What are you studying today?') // Create timestamp for file naming const timestamp = formatDate(new Date(), 'yyyy-MM-dd-HH-mm-ss') const baseFileName = `${studyTopic.replace(/[^a-zA-Z0-9]/g, '-')}-${timestamp}` // Start screen recording with AppleScript await div({ html: md(`# Starting screen recording for: ${studyTopic} Press **Record** when the screen capture UI appears. Recording will automatically stop after 30 seconds.`), onInit: async () => { await wait(3000) submit('continue') } }) await applescript(` tell application "System Events" to tell process "Screen Shot" repeat until exists button "Record" of its front window delay 0.1 end repeat click button "Record" of its front window end tell `) // Show countdown and recording status let countdown = 30 const countdownWidget = await widget(` <div class="p-8 text-center bg-red-500 text-white"> <h1 class="text-4xl font-bold">RECORDING</h1> <div class="text-6xl font-mono mt-4">{{time}}</div> <p class="text-xl mt-4">{{topic}}</p> </div> `, { state: { time: countdown, topic: studyTopic }, alwaysOnTop: true, frame: false, transparent: true, width: 300, height: 200 }) const timer = setInterval(() => { countdown-- countdownWidget.setState({ time: countdown, topic: studyTopic }) if (countdown <= 0) { clearInterval(timer) countdownWidget.close() } }, 1000) // Wait for recording duration await wait(30000) // Stop recording await applescript(` tell application "System Events" to ¬ click menu bar item 1 ¬ of menu bar 1 ¬ of application process "screencaptureui" `) await wait(2000) // Get the most recent screen recording from Desktop const desktopPath = home('Desktop') const desktopFiles = await readdir(desktopPath) const screenRecordings = desktopFiles .filter(file => file.includes('Screen Recording') && file.endsWith('.mov')) .map(file => ({ name: file, path: path.join(desktopPath, file), stats: require('fs').statSync(path.join(desktopPath, file)) })) .sort((a, b) => b.stats.mtime - a.stats.mtime) if (screenRecordings.length === 0) { await div(md('# No screen recording found on Desktop!')) exit() } const recordingPath = screenRecordings[0].path const finalRecordingPath = recordingsPath(`${baseFileName}.mov`) // Move recording to our recordings folder await move(recordingPath, finalRecordingPath) // Generate comprehensive study notes const notesContent = await editor({ value: `# ${studyTopic} - Study Session Notes *Generated on: ${formatDate(new Date(), 'MMMM do, yyyy')}* ## Key Concepts - ## Important Details - ## Questions for Review - ## Action Items - ## Summary Write a brief summary of what you learned... --- **Recording Location:** ${finalRecordingPath} **Duration:** 30 seconds `, language: 'markdown', shortcuts: [ { name: 'Play Recording', key: `${cmd}+p`, onPress: async () => { await exec(`open "${finalRecordingPath}"`) }, bar: 'right' }, { name: 'Save & Exit', key: `${cmd}+s`, onPress: (input) => { submit(input) }, bar: 'right' } ] }) // Save notes to file const notesPath = recordingsPath(`${baseFileName}-notes.md`) await writeFile(notesPath, notesContent) // Create a study session summary widget await widget(` <div class="p-6 bg-gradient-to-br from-blue-500 to-purple-600 text-white"> <h2 class="text-2xl font-bold mb-4">Study Session Complete!</h2> <div class="space-y-2"> <p><strong>Topic:</strong> ${studyTopic}</p> <p><strong>Duration:</strong> 30 seconds</p> <p><strong>Files Created:</strong></p> <ul class="list-disc list-inside text-sm"> <li>Recording: ${baseFileName}.mov</li> <li>Notes: ${baseFileName}-notes.md</li> </ul> </div> <button onclick="window.close()" class="mt-4 bg-white bg-opacity-20 px-4 py-2 rounded hover:bg-opacity-30"> Close </button> </div> `, { width: 400, height: 300, center: true }) // Copy the study topic to clipboard for easy follow-up await copy(studyTopic) await notify({ title: 'Study Session Complete', body: `Notes saved for: ${studyTopic}` })