forked from loveiu516/loveiu516.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto_todatabase.js
50 lines (45 loc) · 1.56 KB
/
photo_todatabase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var wget = require('node-wget');
var imgur = require('imgur');
function periodicActivity() {
var toDay = new Date();
var nowtime = toDay.getHours()*60+toDay.getMinutes();
var nowdate = toDay.getDate();
var nowmonth = toDay.getMonth()+1;
var nowyear = toDay.getFullYear();
var photoname = nowyear.toString() +"-"+ nowmonth.toString() +"-"+ nowdate.toString() +"-"+ nowtime.toString() +".jpg";
wget({
url: 'http://192.168.40.163:8080/?action=snapshot',
dest: "./photo/"+photoname,
timeout: 10000
},
function (error, response, body) {
if (error) {
console.error(error);
} else {
console.log("OK");
imgur.uploadFile("./photo/"+photoname)
.then(function (json) {
console.log(json.data.link);
wget({
url: 'https://script.google.com/macros/s/AKfycbyfxrkEGKbZQwOP8-SP4j-04RMGQhOu_an2fmFKeB3ekzB7xng/exec?photo=' + json.data.link,
dest: './photogas',
timeout: 10000
},
function (error, response, body) {
if (error) {
console.error(error);
} else {
console.log("OK");
}
}
);
})
.catch(function (err) {
console.error(err.message);
});
}
}
);
setTimeout(periodicActivity, 55000);
}
periodicActivity();