blob: 73aee6c7f82689f40d1a2164118737e335efa6c8 (
plain)
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
|
#!/bin/node
require('console');
const args = process.argv.slice(2)
const archs = args.length < 1 ? [`x86_64`] : args;
const fs = require('fs');
const path = require('path');
const syncRequest = require('sync-request');
const os = require('os');
require('seajs');
const file = "linuxQQDownload"
const indexUrl = "https://im.qq.com/linuxqq/index.shtml";
var url;
try {
url = syncRequest('GET', indexUrl).body.toString().match(new RegExp(`https?://[\\w\\.\\/\\-\\_]+/${file}\\.js\\?t=[0-9]+`))[0];
} catch (err) {
url = `https://cdn-go.cn/qq-web/im.qq.com_new/latest/rainbow/${file}.js`;
}
const res = syncRequest('GET', url);
fs.mkdtemp(path.join(os.tmpdir(), "/"), (err, directory) => {
if (err) throw err;
seajs.config({
base: directory,
});
fs.writeFileSync(path.join(directory, `${file}.js`), res.body);
seajs.use(`${file}`, function (config) {
console.log(`version=${config.version}`);
console.log(`updateDate=${config.updateDate}`);
for (const key in archs) {
const arch = archs[key];
let config_index;
switch (arch) {
case `x86_64`:
config_index = `x64DownloadUrl`;
break;
case `aarch64`:
config_index = `armDownloadUrl`;
break;
case `loong64`:
config_index = `loongarchDownloadUrl`;
break;
default:
throw new Error(`This arch is currently not supported`);
}
console.log(`url_${arch}=${config[config_index].appimage}`);
}
});
fs.rm(directory, { recursive: true }, (err) => {
if (err) throw err;
});
});
|