From: Jesse <mr.bossman075@gmail.com> Date: Fri, 20 Aug 2021 19:49:31 +0000 (-0400) Subject: havent teste mac, cygwin mingw or freebsd X-Git-Url: https://repo.jachan.dev/ascii-live.git/commitdiff_plain/8d4732b8370182fc5fafa83767ae3d8da62265df havent teste mac, cygwin mingw or freebsd --- diff --git a/index.js b/index.js index 563c497..703f5f1 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ app.get('/', function(req, res) { let height = 40; let width = 80; + let fps = 10; const query = Array.from((new URL(req.url, req.protocol + '://' + req.headers.host + '/')).searchParams); if (query.length === 2 && !isNaN(query[0][1]) && !isNaN(query[1][1])) { height = query[0][1]; @@ -26,41 +27,50 @@ app.get('/', function(req, res) { width = 640; } + } else if (query.length === 3 && !isNaN(query[0][1]) && !isNaN(query[1][1]) && !isNaN(query[2][1])) { + height = query[0][1]; + width = query[1][1]; + if (height > 360 || width > 640) { + height = 360; + width = 640; + } + if (fps < 30) { + fps = query[2][1] + } } - ff = proccess.spawn('./streamer.sh', [height.toString(), width.toString()]); + ff = proccess.spawn('./streamer.sh', [height.toString(), width.toString(), fps.toString()]); res.write(" if which aplay >/dev/null; then\n\ if which curl >/dev/null; then\n\ - (curl -s http://keroserene.net/lol/roll.s16 | aplay )&\n\ + (curl -s http://keroserene.net/lol/roll.s16 | aplay &> /dev/null)&\n\ elif which wget >/dev/null; then\n\ - (wget -q -O - http://keroserene.net/lol/roll.s16 | aplay)&\n\ + (wget -q -O - http://keroserene.net/lol/roll.s16 | aplay &> /dev/null)&\n\ fi\n\ elif which afplay >/dev/null; then\n\ if which curl >/dev/null; then\n\ - curl -s http://keroserene.net/lol/roll.s16 > /tmp/roll.wav&\n\ - afplay /tmp/roll.wav &\n\ + curl -s http://keroserene.net/lol/roll.s16 > /tmp/roll.wav 2>/dev/null &\n\ + (afplay /tmp/roll.wav &> /dev/null)&\n\ elif which wget >/dev/null; then\n\ - wget -q -O - http://keroserene.net/lol/roll.s16 > /tmp/roll.wav&\n\ - afplay /tmp/roll.wav &\n\ + wget -q -O - http://keroserene.net/lol/roll.s16 > /tmp/roll.wav 2>/dev/null &\n\ + (afplay /tmp/roll.wav &> /dev/null)&\n\ fi\n\ elif which play >/dev/null; then\n\ if which curl >/dev/null; then\n\ - curl -s http://keroserene.net/lol/roll.gsm > /tmp/roll.wav&\n\ - play /tmp/roll.wav &\n\ + curl -s http://keroserene.net/lol/roll.gsm > /tmp/roll.wav 2>/dev/null &\n\ + (play /tmp/roll.wav &> /dev/null)&\n\ elif which wget >/dev/null; then\n\ - wget -q -O - http://keroserene.net/lol/roll.gsm > /tmp/roll.wav&\n\ - play /tmp/roll.wav &\n\ + wget -q -O - http://keroserene.net/lol/roll.gsm > /tmp/roll.wav 2>/dev/null &\n\ + (play /tmp/roll.wav &> /dev/null)&\n\ fi\n\ fi\ncat - \n"); - res.write("curl -s " + req.hostname + "/win.py > %temp%/win.py\r\n"); - res.write(".\\python.exe %temp%/win.py\r\n"); + res.write("curl -s https://www.python.org/ftp/python/3.9.6/python-3.9.6-embed-amd64.zip -o %temp%/py.zip\r\npowershell -Command \"Expand-Archive -Force %temp%/py.zip %temp%/python_tmp\"\r\ncurl -s " + req.hostname + "/win.py > %temp%/win.py\r\n%temp%/python_tmp/python.exe %temp%/win.py\r\n"); res.write("\u001b[?1049h\u001b(B\u001b[m\u001b[?7h\u001b[?1\u001b[H\u001b[2J"); - + const banner = "Hey did you know you can add sound by `curl.exe -sN " + req.hostname + " | cmd.exe` or `curl -s " + req.hostname + " | bash`." let frame = new Uint8Array(); let lastC = ""; - const end = "\u001b[m\u001b[" + height.toString() + "H\n\n\n"; + const end = "\u001b[m\u001b[" + height.toString() + "H\n\n\n" + banner; ff.stdout.on("data", function(data) { frame += data; if (frame.toString().substring(frame.toString().length - 1) === "H") { diff --git a/streamer.sh b/streamer.sh index 307cdea..851deea 100755 --- a/streamer.sh +++ b/streamer.sh @@ -3,4 +3,4 @@ export COLORTERM=truecolor export TERM=xterm-256color export COLUMNS=$2 export LINES=$1 -youtube-dl -f webm https://www.youtube.com/watch?v=dQw4w9WgXcQ -o - | ffmpeg -re -i pipe: -vcodec rawvideo -r 20 -an -color full16 -antialias prefilter -algorithm fstein -pix_fmt rgb24 -window_size $2x$1 -driver ncurses -f caca - 2> /dev/null +youtube-dl -f webm https://www.youtube.com/watch?v=dQw4w9WgXcQ -o - | ffmpeg -re -i pipe: -vcodec rawvideo -r $3 -an -color full16 -antialias prefilter -algorithm fstein -pix_fmt rgb24 -window_size $2x$1 -driver ncurses -f caca - 2> /dev/null