-
Notifications
You must be signed in to change notification settings - Fork 2
/
checker
executable file
·91 lines (85 loc) · 2.35 KB
/
checker
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env node
var request = require('request');
var notify= require('libnotify');
function isLinuxSupported(appid) {
request({
url: "http://store.steampowered.com/api/appdetails",
qs: {"appids": appid}
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var completeData = JSON.parse(body);
var data = completeData[Object.keys(completeData)[0]].data;
console.log("Linux supported for " + data.name + " ? " + data.platforms.linux);
if (data.platforms.linux === true) {
notify.notify("Supported !", {
title: "Steam checker - " + data.name,
image: "/usr/share/icons/gnome/48x48/status/starred.png"
});
} else {
/*
notify.notify("Still not supported", {
title: "Steam checker - " + data.name,
image: "/usr/share/icons/gnome/48x48/status/dialog-error.png"
});
*/
}
} else {
console.log(response.statusCode);
console.log(body);
}
});
}
function launch(appid, interval) {
request({
url: "http://store.steampowered.com/api/appdetails",
qs: {"appids": appid}
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var completeData = JSON.parse(body);
var data = completeData[Object.keys(completeData)[0]].data;
notify.notify("Beginning check for " + data.name + " every " + interval + " seconds", {
title: "Steam checker"
});
}
});
setInterval(function() {
isLinuxSupported(appid);
}, 1000 * interval);
}
function usage() {
console.error("./checker [-i interval_of_checking_in_seconds] appid");
console.error("Example: ./checker -i 30 255220");
}
var interval = 30;
(function() {
var index = 2;
if (process.argv.length <= 2) {
usage();
process.exit();
}
while (index < process.argv.length) {
if (process.argv[index] == "--help") {
usage();
process.exit();
} else if (process.argv[index] == "-i") {
interval = parseInt(process.argv[index + 1]);
index++;
} else {
appid = parseInt(process.argv[index]);
}
index++;
}
if (isNaN(interval)) {
console.error("Interval have to be an integer.");
process.exit();
}
if (isNaN(appid)) {
console.error("Appid have to be a number.");
process.exit();
}
launch(appid, interval);
/*
console.log("appid : " + appid)
console.log("interval : " + interval)
*/
})();