const { chromium } = require('playwright'); const OUT = '/home/zgaetano/media-command-guide/screenshots'; const BMG = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f'; const pause = p => p.evaluate(() => document.querySelectorAll('video').forEach(v => { try { v.pause() } catch (e) {} })); const clickText = (p, src) => p.evaluate(src => { const re = new RegExp(src, 'i'); const e = [...document.querySelectorAll('button,[role=tab],a,li,span,div')] .filter(x => x.offsetHeight > 0 && x.children.length < 4).find(x => re.test((x.innerText || '').trim())); if (e) { e.click(); return (e.innerText || '').slice(0, 50); } return null; }, src); (async () => { const b = await chromium.launch({ headless: true, args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] }); const c = await b.newContext({ viewport: { width: 1920, height: 1080 } }); await c.addCookies([{ name: 'dragonflight.sid', value: 'REDACTED', domain: 'mediacmdr.com', path: '/', httpOnly: true, secure: true }]); const p = await c.newPage(); await p.goto(`https://mediacmdr.com/#library?project=${BMG}`, { waitUntil: 'networkidle' }); await p.waitForTimeout(6000); // scroll the grid into view to show real thumbnails await p.evaluate(() => { const m = document.querySelector('main') || document.scrollingElement; m.scrollBy(0, 350); }); await p.waitForTimeout(2500); await p.screenshot({ path: `${OUT}/09a-library-grid-thumbnails.png` }); // find asset cards with images and a filename const cards = await p.evaluate(() => [...document.querySelectorAll('[class*=card],[class*=tile],[class*=asset],tr')] .filter(e => e.querySelector('img,video') && e.offsetHeight > 60 && e.offsetHeight < 500) .slice(0, 8).map(e => (e.innerText || '').replace(/\s+/g, ' ').slice(0, 70))); console.log('cards:', JSON.stringify(cards)); // Prefer a clip (has duration like 0:49 or 00:00) const opened = await p.evaluate(() => { const el = [...document.querySelectorAll('[class*=card],[class*=tile],[class*=asset],tr')] .filter(e => e.querySelector('img,video') && e.offsetHeight > 60 && e.offsetHeight < 500) .find(e => /\d+:\d\d/.test(e.innerText || '') && !/items?\b/i.test(e.innerText || '')); if (!el) return null; const t = el.querySelector('img') || el; t.click(); t.dispatchEvent(new MouseEvent('dblclick', { bubbles: true })); return el.innerText.replace(/\s+/g, ' ').slice(0, 70); }); console.log('opened:', opened, 'hash:', await p.evaluate(() => location.hash)); await p.waitForTimeout(7000); await p.evaluate(async () => { const v = document.querySelector('video'); if (!v) return 'novideo'; v.muted = true; try { await v.play() } catch (e) {} await new Promise(r => setTimeout(r, 6000)); try { v.currentTime = Math.min(15, (v.duration || 30) / 3) } catch (e) {} await new Promise(r => setTimeout(r, 3000)); v.pause(); }); await p.screenshot({ path: `${OUT}/09b-media-library-asset-inspector.png` }); for (const t of ['Metadata', 'Transcript', 'AI Analysis', 'Versions', 'Comments']) { const ok = await clickText(p, '^' + t); if (ok) { await p.waitForTimeout(3000); await pause(p); await p.screenshot({ path: `${OUT}/09c-asset-${t.split(' ')[0].toLowerCase()}.png` }); console.log('tab', t); } } // Downloads modal: Desktop apps tab await p.goto('https://mediacmdr.com/#home', { waitUntil: 'networkidle' }); await p.waitForTimeout(3500); console.log('dl:', await clickText(p, '^Downloads')); await p.waitForTimeout(2500); await p.screenshot({ path: `${OUT}/20b-downloads-modal.png` }); console.log('desktop tab:', await clickText(p, '^Desktop apps')); await p.waitForTimeout(2500); await p.screenshot({ path: `${OUT}/20c-downloads-desktop-apps.png` }); await b.close(); })();