2026-10-02 07:57:00 -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 07:57:00 -04:00
const OUT = '/home/zgaetano/media-command-guide/screenshots' ;
2026-10-06 09:41:27 -04:00
const COOKIE = process . env . DF _SESSION _COOKIE ;
2026-10-02 07:57:00 -04:00
const ASSET = process . argv [ 2 ] || '9b648563-2159-43af-9b02-40ae04821714' ;
const pause = p => p . evaluate ( ( ) => document . querySelectorAll ( 'video' ) . forEach ( v => { try { v . pause ( ) } catch ( e ) { } } ) ) ;
const clickText = ( p , re ) => p . evaluate ( s => { const r = new RegExp ( s ) ; const el = [ ... document . querySelectorAll ( 'button,[role=tab],a,div,span' ) ] . filter ( e => e . offsetHeight > 0 && e . children . length < 4 ) . find ( e => r . test ( e . innerText . trim ( ) ) ) ; if ( el ) { el . click ( ) ; return el . innerText . trim ( ) . slice ( 0 , 40 ) } return null } , re . source ) ;
( async ( ) => {
const b = await chromium . launch ( { args : [ '--no-sandbox' , '--autoplay-policy=no-user-gesture-required' ] } ) ;
const c = await b . newContext ( { viewport : { width : 1600 , height : 1000 } } ) ;
await c . addCookies ( [ { name : 'dragonflight.sid' , value : COOKIE , domain : 'mediacmdr.com' , path : '/' , httpOnly : true , secure : true } ] ) ;
const p = await c . newPage ( ) ;
await p . goto ( 'https://mediacmdr.com/analysis.html?asset=' + ASSET , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 6000 ) ; await pause ( p ) ;
await p . screenshot ( { path : ` ${ OUT } /42-ai-analysis-overview.png ` } ) ;
console . log ( 'overview:' , ( await p . evaluate ( ( ) => document . body . innerText . replace ( /\n+/g , ' | ' ) . slice ( 0 , 700 ) ) ) ) ;
const tabs = [ [ 'editorial' , /^Story & Editorial/ ] , [ 'clips' , /^Clips & Moments/ ] , [ 'faces' , /^People & Faces/ ] , [ 'visual' , /^In Picture/ ] , [ 'ask' , /^Ask AI/ ] ] ;
for ( const [ n , re ] of tabs ) { const k = await clickText ( p , re ) ; await p . waitForTimeout ( 3500 ) ; await pause ( p ) ; await p . screenshot ( { path : ` ${ OUT } /42-ai- ${ n } .png ` } ) ;
console . log ( n , k , '::' , ( await p . evaluate ( ( ) => document . body . innerText . replace ( /\n+/g , ' | ' ) . slice ( 0 , 400 ) ) ) ) ; }
await p . goto ( 'https://mediacmdr.com/reframe.html?asset=' + ASSET , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 7000 ) ; await pause ( p ) ;
await p . screenshot ( { path : ` ${ OUT } /41-reframe.png ` } ) ;
await p . screenshot ( { path : ` ${ OUT } /41b-reframe-full.png ` , fullPage : true } ) ;
console . log ( 'reframe:' , ( await p . evaluate ( ( ) => document . body . innerText . replace ( /\n+/g , ' | ' ) . slice ( 0 , 1500 ) ) ) ) ;
await b . close ( ) ; } ) ( ) ;