Compare commits
2 Commits
d2ec6b2861
...
fad66e6945
Author | SHA1 | Date | |
---|---|---|---|
fad66e6945 | |||
e3f39e37a1 |
63
app.deno.js
63
app.deno.js
@ -74,7 +74,9 @@ export async function pixivToPleroma(illust_id) {
|
||||
try {
|
||||
var {illust, images} = await downloadPixivIllust(illust_id);
|
||||
await postStatus({
|
||||
status: `https://www.pixiv.net/en/artworks/${illust_id}`,
|
||||
status: `https://www.pixiv.net/en/artworks/${illust_id}`
|
||||
+ ((images.length > 4) ? '\n⚠ >4 img' : '')
|
||||
+ ((illust.illustType == 2) ? '\n⚠ ugoira conversion not implemented' : ''),
|
||||
files: images,
|
||||
visibility: "unlisted",
|
||||
sensitive: Boolean(illust.xRestrict)
|
||||
@ -94,36 +96,41 @@ if (import.meta.main) Deno.serve({
|
||||
hostname: "127.0.0.1"
|
||||
}, async (req, info) => {
|
||||
var {pathname} = new URL(req.url);
|
||||
console.log(info.remoteAddr.hostname, pathname);
|
||||
console.log(info.remoteAddr.hostname, req.headers.get('x-forwarded-for'), pathname);
|
||||
|
||||
switch (pathname) {
|
||||
case "/ajax/illusts/bookmarks/add":
|
||||
var payload = await req.clone().json();
|
||||
console.log(payload);
|
||||
var {comment, illust_id, restrict, tags} = payload;
|
||||
pixivToPleroma(illust_id);
|
||||
break;
|
||||
case "/ajax/illusts/bookmarks/delete":
|
||||
var payload = await req.clone().formData();
|
||||
console.log(payload);
|
||||
// todo
|
||||
break;
|
||||
case "/touch/ajax_api/ajax_api.php":
|
||||
var payload = await req.clone().formData();
|
||||
console.log(payload);
|
||||
var mode = payload.get("mode");
|
||||
if (mode == "add_bookmark_illust") {
|
||||
var restrict = payload.get("restrict");
|
||||
var tag = payload.get("tag");
|
||||
var id = payload.get("id");
|
||||
var comment = payload.get("comment");
|
||||
pixivToPleroma(id);
|
||||
} else if (mode == "delete_bookmark_illust") {
|
||||
var id = payload.get("id");
|
||||
try {
|
||||
switch (pathname) {
|
||||
case "/ajax/illusts/bookmarks/add":
|
||||
var payload = await req.clone().json();
|
||||
console.log(payload);
|
||||
var {comment, illust_id, restrict, tags} = payload;
|
||||
pixivToPleroma(illust_id);
|
||||
break;
|
||||
case "/ajax/illusts/bookmarks/delete":
|
||||
var payload = await req.clone().formData();
|
||||
console.log(payload);
|
||||
// todo
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case "/touch/ajax_api/ajax_api.php":
|
||||
var payload = await req.clone().formData();
|
||||
console.log(payload);
|
||||
var mode = payload.get("mode");
|
||||
if (mode == "add_bookmark_illust") {
|
||||
var restrict = payload.get("restrict");
|
||||
var tag = payload.get("tag");
|
||||
var id = payload.get("id");
|
||||
var comment = payload.get("comment");
|
||||
pixivToPleroma(id);
|
||||
} else if (mode == "delete_bookmark_illust") {
|
||||
var id = payload.get("id");
|
||||
// todo
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("payload error:", error.stack);
|
||||
}
|
||||
|
||||
return fetch("https://www.pixiv.net"+pathname, {
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
|
Loading…
Reference in New Issue
Block a user