Compare commits
3 Commits
0b989fb317
...
2c166ecdb2
Author | SHA1 | Date | |
---|---|---|---|
2c166ecdb2 | |||
ebbaec9e0e | |||
53db080d92 |
@ -24,7 +24,7 @@ client.on("messageCreate", async message => {
|
|||||||
let json = html.match(/<meta name="preload-data" id="meta-preload-data" content='(.*)'>/)[1];
|
let json = html.match(/<meta name="preload-data" id="meta-preload-data" content='(.*)'>/)[1];
|
||||||
let data = JSON.parse(json);
|
let data = JSON.parse(json);
|
||||||
let url = Object.values(data.illust)[0].urls.original;
|
let url = Object.values(data.illust)[0].urls.original;
|
||||||
await message.channel.send(url.replace("https://i.pximg.net/", `https://${config.web_hostname}/pixiv-cache/`));
|
await message.channel.send(url.replace("https://i.pximg.net/", `https://${config.web_hostname}/pixiv-proxy/`));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("pixiv error,", error.message);
|
console.error("pixiv error,", error.message);
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ client.on("messageCreate", async message => {
|
|||||||
|
|
||||||
app.use("/pixiv-proxy/", (req, res, next) => {
|
app.use("/pixiv-proxy/", (req, res, next) => {
|
||||||
if (req.method != "GET") return next();
|
if (req.method != "GET") return next();
|
||||||
let local_file_path = config.data_dir + "pixiv-cache/" + req.url.replace(/\//g, '\\');
|
let local_file_path = config.data_dir + "pixiv-cache/" + req.url.split('?')[0].replace(/\//g, '\\');
|
||||||
if (fs.existsSync(local_file_path)) res.sendFile(local_file_path);
|
if (fs.existsSync(local_file_path)) res.sendFile(local_file_path);
|
||||||
else {
|
else {
|
||||||
https.get(`https://i.pximg.net${req.url}`, {
|
https.get(`https://i.pximg.net${req.url}`, {
|
||||||
|
Loading…
Reference in New Issue
Block a user