2026-10-02 00:47:49 -04:00
const { chromium } = require ( 'playwright' ) ;
2026-10-06 09:41:27 -04:00
if ( ! process . env . DF _SESSION _COOKIE ) { console . error ( 'DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.' ) ; process . exit ( 1 ) ; }
2026-10-02 00:47:49 -04:00
const fs = require ( 'fs' ) ;
const OUT = '/home/zgaetano/media-command-guide/screenshots' ;
const BMG = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f' ;
const routes = [
[ '02-dashboard-home' , 'home' ] , [ '05-live-recorders' , 'recorders' ] , [ '06-live-schedule' , 'schedule' ] ,
[ '07-live-graphics' , 'graphics' ] , [ '08-live-monitor-wall' , 'multiview' ] , [ '03-projects' , 'projects' ] ,
[ '09-media-library-bmg' , ` library?project= ${ BMG } ` ] , [ '10-media-upload' , 'upload' ] , [ '11-media-contribution' , 'contribution' ] ,
[ '12-media-youtube' , 'youtube' ] , [ '13-media-cloud-import' , 'cloud-import' ] , [ '14-ops-jobs' , 'jobs' ] ,
[ '15-ops-staging' , 'staging' ] , [ '16-ops-playout' , 'playout' ] , [ '17-ops-clip-server' , 'playout-tria' ] ,
[ '19-ops-engineering' , 'engineering' ] , [ '20-ops-applications' , 'applications' ] ,
[ '21-admin-users-groups' , 'users' ] , [ '22-admin-api-tokens' , 'tokens' ] , [ '23-admin-containers' , 'containers' ] ,
[ '24-admin-logs' , 'logs' ] , [ '25-admin-audit-log' , 'audit' ] , [ '26-admin-cluster' , 'cluster' ] ,
[ '27-admin-alerts' , 'alerts' ] , [ '28-admin-settings' , 'settings' ] ,
[ '29-playout-rundown' , 'rundown' ] , [ '30-playout-schedule' , 'playout-schedule' ] , [ '31-playout-ads' , 'playout-ads' ] ,
] ;
const pause = p => p . evaluate ( ( ) => document . querySelectorAll ( 'video' ) . forEach ( v => { try { v . pause ( ) } catch ( e ) { } } ) ) ;
const clickText = ( p , re ) => p . evaluate ( src => {
const re = new RegExp ( src , 'i' ) ;
const e = [ ... document . querySelectorAll ( 'button,[role=tab],a,[class*=card],[class*=tile],li,div' ) ]
. filter ( x => x . offsetHeight > 0 && x . children . length < 6 ) . find ( x => re . test ( ( x . innerText || '' ) . trim ( ) ) ) ;
if ( e ) { e . click ( ) ; return ( e . innerText || '' ) . slice ( 0 , 50 ) ; } return null ;
} , re . source ) ;
( 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 } } ) ;
2026-10-06 09:41:27 -04:00
await c . addCookies ( [ { name : 'dragonflight.sid' , value : process . env . DF _SESSION _COOKIE , domain : 'mediacmdr.com' , path : '/' , httpOnly : true , secure : true } ] ) ;
2026-10-02 00:47:49 -04:00
const p = await c . newPage ( ) ;
await p . goto ( 'https://mediacmdr.com/' , { waitUntil : 'networkidle' } ) ;
const log = { } ;
for ( const [ name , r ] of routes ) {
await p . evaluate ( h => { location . hash = h } , r ) ;
await p . waitForTimeout ( 4500 ) ;
await pause ( p ) ;
await p . screenshot ( { path : ` ${ OUT } / ${ name } .png ` } ) ;
log [ name ] = await p . evaluate ( ( ) => {
const h = [ ... document . querySelectorAll ( 'h1,h2,[class*=crumb]' ) ] . map ( e => e . innerText ) . filter ( Boolean ) . slice ( 0 , 2 ) . join ( ' / ' ) ;
return h . replace ( /\s+/g , ' ' ) . slice ( 0 , 90 ) + ' | ' + location . hash ;
} ) ;
console . log ( name , '=>' , log [ name ] ) ;
}
// Projects -> open BMG project card
await p . evaluate ( ( ) => { location . hash = 'projects' } ) ; await p . waitForTimeout ( 4000 ) ;
console . log ( 'bmg card:' , await clickText ( p , /^Broadcast Managment Group/ ) ) ;
await p . waitForTimeout ( 5000 ) ; await pause ( p ) ;
await p . screenshot ( { path : ` ${ OUT } /04-project-bmg-overview.png ` } ) ;
// BMG library -> asset detail
await p . evaluate ( h => { location . hash = h } , ` library?project= ${ BMG } ` ) ; await p . waitForTimeout ( 6000 ) ;
const hit = await p . evaluate ( ( ) => {
const el = [ ... document . querySelectorAll ( 'tr,[class*=card],[class*=tile],[class*=asset],[class*=row]' ) ]
. find ( e => / Sizzle | \ . ( mp4 | mov | mxf ) / i . test ( e . innerText || '' ) && e . offsetHeight > 30 && e . offsetHeight < 400 ) ;
if ( el ) { el . click ( ) ; el . dispatchEvent ( new MouseEvent ( 'dblclick' , { bubbles : true } ) ) ; return el . innerText . slice ( 0 , 60 ) } return null ;
} ) ;
console . log ( 'asset:' , hit ) ; await p . waitForTimeout ( 7000 ) ;
await p . evaluate ( async ( ) => {
const v = document . querySelector ( 'video' ) ; if ( ! v ) return ;
v . muted = true ; try { await v . play ( ) } catch ( e ) { }
await new Promise ( r => setTimeout ( r , 5000 ) ) ;
v . currentTime = Math . min ( 15 , ( v . duration || 30 ) / 3 ) ;
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 , new RegExp ( '^' + 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 ) ; }
}
// Editor standalone
await p . goto ( 'https://mediacmdr.com/editor.html' , { waitUntil : 'networkidle' } ) . catch ( ( ) => { } ) ;
await p . waitForTimeout ( 5000 ) ; await pause ( p ) ;
await p . screenshot ( { path : ` ${ OUT } /18-ops-editor.png ` } ) ;
console . log ( 'editor title:' , await p . title ( ) ) ;
// Downloads modal
await p . goto ( 'https://mediacmdr.com/#home' , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 3500 ) ;
console . log ( 'downloads:' , await clickText ( p , /^Downloads/ ) ) ;
await p . waitForTimeout ( 3000 ) ;
await p . screenshot ( { path : ` ${ OUT } /20b-downloads-modal.png ` } ) ;
fs . writeFileSync ( '/home/zgaetano/media-command-guide/capture-log.json' , JSON . stringify ( log , null , 1 ) ) ;
await b . close ( ) ;
} ) ( ) ;