Check if list exists before reading

main
hazy 11 months ago
parent 2f6400b477
commit f2f239991c

@ -5,7 +5,8 @@ const app = express()
const playerHtml = fs.readFileSync('site.html', 'utf-8')
const port = process.env.PORT??3500
let list = fs.readFileSync('videolist', 'utf-8').split('\n')
let list = []
if (fs.existsSync('videolist')) list = fs.readFileSync('videolist', 'utf-8').split('\n')
app.get('/', (req, res) => {
res.send(playerHtml.replace('{{VIDEO_ID_HERE}}', list[Math.floor(Math.random()*list.length)]))

Loading…
Cancel
Save