Notice: My personal stance on AI generated artwork. Retweet and share if you agree. Let us discuss, and not immediately scream bloody murder.

Now Viewing: Adding posts to pool via API/scripting
Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

Hawker - Group: Member - Total Posts: 42
user_avatar
Adding posts to pool via API/scripting
Posted on: 12/13/23 08:44AM

I'm working on migrating my favorites to pools (as I appear to have hit the cap). Getting lists of favorites, deleting them - no problem. However, I'm having some trouble adding a post to a pool (public for testing; will be personal when done). I didn't see a direct API endpoint for this, but I found the following code in the page (de-obfuscated variables):

function addToPoolID(post_id) {
var pool_id = prompt("Please enter the ID of the pool you wish to add this post to.");
if (pool_id == "" || pool_id == null) {
return false
}
var json_data = {
id: pool_id,
commit: "import"
};
json_data.posts = {};
json_data.posts[post_id] = 1;
$.post("index.php?page=pool&s=import&id=" + pool_id, json_data, function(d) {})
}

Based on this I tried to whip up a quick proof-of-concept in first Perl, then simply curl, but no luck:

curl -v -d '{"commit":"import","id":61515,"posts":[9348759:1]}' -H 'Content-Type: application/json' 'gelbooru.com:443/index.ph...import&id=61515'


I'm sure whatever I have wrong here is simple and subtle - anyone see what? Or have a better way of programmatically adding posts to a pool?



KaizokuJimbei - Group: Member - Total Posts: 70
user_avatar
Posted on: 12/13/23 11:19AM

1) Go to settings/my profile. On the url above copy the id number.

2) Go to your new pool and click import. On the search bar type the following, fav:id_number_goes_here.

3) Remove posts you don't want and then scroll all the way down. Click import.

You are done.

By the way. You can use the search bar in the import screen the same way you search normally. Thus, if you want to let's say import only general images from your favourites then you should type, fav:id_number_goes_here rating:general.



Hawker - Group: Member - Total Posts: 42
user_avatar
Posted on: 12/13/23 04:09PM

I'm working with ~24000 favorites. Doing it manually like that doesn't scale. I also need to be able to remove corresponding posts from my favorites after moving them to the pool, which this doesn't do. If I can just programatically "add post x to pool y" then I'm golden (and it's clear I'm close to it; it's just a REST API call, but I don't have the parameters *quite* right).



Hawker - Group: Member - Total Posts: 42
user_avatar
Posted on: 12/14/23 04:05PM

Got it; was assuming that it was a JSON request rather than an XMLHttpRequest. Changed the payload formatting and request header and all good. Now to automate!



add_replyAdd Reply


1