2026-10-01 23:40:12 -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-01 23:40:12 -04:00
const path = require ( 'path' ) ;
const OUT _DIR = '/home/zgaetano/media-command-guide/screenshots' ;
2026-10-06 09:41:27 -04:00
const COOKIE _VAL = process . env . DF _SESSION _COOKIE ;
2026-10-01 23:40:12 -04:00
( async ( ) => {
const browser = await chromium . launch ( {
headless : true ,
args : [ '--no-sandbox' , '--disable-setuid-sandbox' , '--disable-dev-shm-usage' , '--disable-gpu' ]
} ) ;
const context = await browser . newContext ( {
viewport : { width : 1920 , height : 1080 } ,
deviceScaleFactor : 1
} ) ;
await context . addCookies ( [ {
name : 'dragonflight.sid' ,
value : COOKIE _VAL ,
domain : 'mediacmdr.com' ,
path : '/' ,
httpOnly : true ,
secure : true
} ] ) ;
const page = await context . newPage ( ) ;
// 1. Go to Library and select Broadcast Management Group
await page . goto ( 'https://mediacmdr.com/' , { waitUntil : 'networkidle' } ) ;
await page . waitForTimeout ( 2000 ) ;
// Click Library
await page . evaluate ( ( ) => {
const items = Array . from ( document . querySelectorAll ( '.nav-item' ) ) ;
const target = items . find ( i => i . innerText . trim ( ) . startsWith ( 'Library' ) ) ;
if ( target ) target . click ( ) ;
} ) ;
await page . waitForTimeout ( 3000 ) ;
// Select BMG project from dropdown
await page . evaluate ( ( ) => {
const sel = document . querySelector ( '.library-project-select, select' ) ;
if ( sel ) {
sel . value = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f' ;
sel . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
}
} ) ;
await page . waitForTimeout ( 4000 ) ;
// Pause videos and snap
await page . evaluate ( ( ) => document . querySelectorAll ( 'video' ) . forEach ( v => { try { v . pause ( ) ; } catch ( e ) { } } ) ) ;
await page . screenshot ( { path : path . join ( OUT _DIR , '09-media-library-bmg.png' ) , fullPage : false } ) ;
console . log ( 'Saved: 09-media-library-bmg.png' ) ;
// 2. Click on the first asset to open Asset Detail / Inspector
const clickedAsset = await page . evaluate ( ( ) => {
const rows = Array . from ( document . querySelectorAll ( 'tbody tr, .asset-card, .grid-item, [role="row"]' ) ) ;
// Find a row with asset name
for ( const r of rows ) {
if ( r . innerText && ( r . innerText . includes ( '.mov' ) || r . innerText . includes ( '.mp4' ) || r . innerText . includes ( '.mxf' ) || r . innerText . includes ( '7H' ) || r . innerText . includes ( 'KB' ) || r . innerText . includes ( 'MB' ) || r . innerText . includes ( 'GB' ) ) ) {
r . click ( ) ;
return r . innerText . slice ( 0 , 80 ) ;
}
}
return null ;
} ) ;
console . log ( 'Clicked asset:' , clickedAsset ) ;
await page . waitForTimeout ( 4000 ) ;
await page . evaluate ( ( ) => document . querySelectorAll ( 'video' ) . forEach ( v => { try { v . pause ( ) ; } catch ( e ) { } } ) ) ;
await page . screenshot ( { path : path . join ( OUT _DIR , '09b-media-library-asset-inspector.png' ) , fullPage : false } ) ;
console . log ( 'Saved: 09b-media-library-asset-inspector.png' ) ;
// 3. Open Downloads modal from Home
await page . evaluate ( ( ) => {
const items = Array . from ( document . querySelectorAll ( '.nav-item' ) ) ;
const target = items . find ( i => i . innerText . trim ( ) . startsWith ( 'Home' ) ) ;
if ( target ) target . click ( ) ;
} ) ;
await page . waitForTimeout ( 2000 ) ;
// Click Downloads card
await page . evaluate ( ( ) => {
const cards = Array . from ( document . querySelectorAll ( '*' ) ) ;
const dlCard = cards . find ( el => el . innerText && el . innerText . includes ( 'Downloads' ) && el . innerText . includes ( 'Plugin · Dragon-ISO' ) ) ;
if ( dlCard ) dlCard . click ( ) ;
} ) ;
await page . waitForTimeout ( 2000 ) ;
await page . screenshot ( { path : path . join ( OUT _DIR , '20b-downloads-modal.png' ) , fullPage : false } ) ;
console . log ( 'Saved: 20b-downloads-modal.png' ) ;
await browser . close ( ) ;
} ) ( ) ;