fix a thing in the new desc system
This commit is contained in:
@@ -77,7 +77,7 @@ def create_post(
|
||||
}
|
||||
|
||||
if description:
|
||||
data["post[artist_commentary_desc]"] = description
|
||||
data["post[artist_commentary][original_description]"] = description
|
||||
|
||||
print(f"Posting upload ID {upload_id}, tags '{tags}', rating {rating}")
|
||||
|
||||
@@ -95,6 +95,41 @@ def create_post(
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
|
||||
def find_pool_by_name(api_key, username, danbooru_url, pool_name):
|
||||
"""Find a pool by exact name. Returns pool dict (with id, post_ids, etc.) or None."""
|
||||
url = f"{danbooru_url}/pools.json"
|
||||
params = {
|
||||
"search[name]": pool_name,
|
||||
"limit": 1,
|
||||
"login": username,
|
||||
"api_key": api_key,
|
||||
}
|
||||
response = requests.get(url, params=params, auth=(username, api_key))
|
||||
if response.status_code == 200:
|
||||
pools = response.json()
|
||||
if pools and not pools[0].get("is_deleted", False):
|
||||
return pools[0]
|
||||
return None
|
||||
|
||||
|
||||
def update_pool(api_key, username, danbooru_url, pool_id, pool_ids):
|
||||
"""Update an existing pool's post list (replaces with the given pool_ids)."""
|
||||
url = f"{danbooru_url}/pools/{pool_id}.json?api_key={api_key}&login={username}"
|
||||
data = {
|
||||
"pool[category]": "series",
|
||||
"pool[post_ids_string]": " ".join(str(_id) for _id in pool_ids),
|
||||
}
|
||||
print(f"Updating pool {pool_id} with {len(pool_ids)} posts")
|
||||
response = requests.put(url, data=data)
|
||||
if response.status_code == 200:
|
||||
print(f"Updated pool {pool_id}.")
|
||||
else:
|
||||
print(
|
||||
f"Failed to update pool {pool_id}. Status code: {response.status_code}"
|
||||
)
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
|
||||
def create_pool(api_key, username, danbooru_url, pool_name, pool_ids):
|
||||
url = f"{danbooru_url}/pools.json?api_key={api_key}&login={username}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user