Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
202f7360cb | ||
|
22850e929d | ||
f0595c0cf7 |
7
index.js
7
index.js
@ -18,15 +18,18 @@ dbclient.connect().then(async () => {
|
|||||||
app.get("/https://www.pixiv.net/en/artworks/:id", async (req, res) => {
|
app.get("/https://www.pixiv.net/en/artworks/:id", async (req, res) => {
|
||||||
//if (req.headers["cache-control"] == "max-age=0") { // this indicates a reload in chrome
|
//if (req.headers["cache-control"] == "max-age=0") { // this indicates a reload in chrome
|
||||||
// but chrome still sends it after redirect
|
// but chrome still sends it after redirect
|
||||||
if (ipa_lastload_map[req.ip] == req.params.id) {
|
if (ipa_lastload_map[req.ip] == req.params.id && req.query.noredirect == null) {
|
||||||
return redirectRandom(req, res);
|
return redirectRandom(req, res);
|
||||||
} else ipa_lastload_map[req.ip] = req.params.id;
|
} else ipa_lastload_map[req.ip] = req.params.id;
|
||||||
console.log(new Date().toLocaleString(), req.ip, req.params.id);
|
console.log(new Date().toLocaleString(), req.ip, req.params.id);
|
||||||
var asdf = await collection.findOne({_id: req.params.id}, {downloaded_images: 1});
|
var asdf = await collection.findOne({_id: req.params.id}, {downloaded_images: 1});
|
||||||
if (!asdf) return res.sendStatus(404);
|
if (!asdf) return res.sendStatus(404);
|
||||||
|
var filename = Object.keys(asdf.downloaded_images)[0];
|
||||||
|
res.type(filename.split('.').pop());
|
||||||
|
res.header("Content-Disposition", `filename=${filename}`);
|
||||||
var gfsid = Object.values(asdf.downloaded_images)[0];
|
var gfsid = Object.values(asdf.downloaded_images)[0];
|
||||||
bucket.openDownloadStream(gfsid).pipe(res);
|
bucket.openDownloadStream(gfsid).pipe(res);
|
||||||
});
|
});
|
||||||
app.listen(8039);
|
app.listen(39);
|
||||||
console.log("server ready");
|
console.log("server ready");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user