From 7fe522f1c0629df8e055362be9611737b3312441 Mon Sep 17 00:00:00 2001 From: Laurie Date: Tue, 16 Jan 2024 16:46:16 +0100 Subject: [PATCH 1/2] Modification du formatage du nom de fichier --- index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index a155dc2..3577e30 100644 --- a/index.js +++ b/index.js @@ -12,13 +12,17 @@ function snapshotPath(){ return "/snapshot/snapshot-" + date.getFullYear() - + date.getMonth() - + date.getDay() - + "-" - + date.getHours() - + date.getMinutes() - + date.getSeconds() - + "-" + + "-" + + String(date.getMonth() + 1).padStart(2, '0') + + "-" + + String(date.getDate()).padStart(2, '0') + + "_" + + String(date.getHours()).padStart(2, '0') + + "-" + + String(date.getMinutes()).padStart(2, '0') + + "-" + + String(date.getSeconds()).padStart(2, '0') + + "_" + date.getMilliseconds() +".jpg"; } From d5f7add8e37eb391f9c6e352abb36a1c8535e53a Mon Sep 17 00:00:00 2001 From: Laurie Date: Sat, 31 May 2025 17:39:12 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Ajout=20d'une=20commande=20pour=20faire=20d?= =?UTF-8?q?es=20capture=20avec=20une=20seconde=20cam=C3=A9ra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 3577e30..9791384 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,8 @@ const port = 80; const http = require("http"); const fs = require('fs'); -const SNAPSHOT_URL = "http://192.168.1.68/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06," +const SNAPSHOT_SALON_URL = "http://192.168.1.68/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06," +const SNAPSHOT_GARAGE_URL = "http://192.168.1.69/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06," function snapshotPath(){ let date = new Date(); @@ -28,22 +29,38 @@ function snapshotPath(){ } -function snapshot() { - http.get(SNAPSHOT_URL, (res) => { +function snapshotSalon() { + http.get(SNAPSHOT_SALON_URL, (res) => { + res.pipe(fs.createWriteStream(snapshotPath())); + }); +} + +function snapshotGarage() { + http.get(SNAPSHOT_GARAGE_URL, (res) => { res.pipe(fs.createWriteStream(snapshotPath())); }); } app.get('/snapshot', (req, res) => { try{ - snapshot(); + snapshotSalon(); res.send('ok'); } catch(e) { res.status(500).send(e); } }); - + +app.get('/snapshotGarage', (req, res) => { + try{ + snapshotGarage(); + res.send('ok'); + } catch(e) + { + res.status(500).send(e); + } + }); + app.get('/', (req, res) => { res.send('Hello World!'); });