17 lines
478 B
JavaScript
17 lines
478 B
JavaScript
|
|
import { readdirSync } from 'fs'
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Elenca i video .mp4 presenti nella cartella spot.
|
||
|
|
* Ritorna i filename ordinati alfabeticamente (sequenza prevedibile),
|
||
|
|
* oppure un array vuoto se la cartella non esiste o non è leggibile.
|
||
|
|
*/
|
||
|
|
export function listSpotVideos(spotDir) {
|
||
|
|
try {
|
||
|
|
return readdirSync(spotDir)
|
||
|
|
.filter(name => name.toLowerCase().endsWith('.mp4'))
|
||
|
|
.sort((a, b) => a.localeCompare(b))
|
||
|
|
} catch {
|
||
|
|
return []
|
||
|
|
}
|
||
|
|
}
|