Add def to get modqueue

This commit is contained in:
KenwoodFox 2026-01-06 11:35:19 -05:00
parent b71965e5d9
commit 91eb0fb7f5
1 changed files with 36 additions and 0 deletions

View File

@ -579,3 +579,39 @@ def delete_post(post_id, danbooru_url, api_key, username, reason=""):
except Exception as e: except Exception as e:
print(f"Exception during deletion: {e}") print(f"Exception during deletion: {e}")
return False return False
def fetch_modqueue(danbooru_url, api_key, username, limit=100):
"""
Fetches posts from the modqueue (pending or flagged posts).
Args:
danbooru_url (str): The base URL of the booru
api_key (str): The API key for authentication
username (str): The username for authentication
limit (int): Maximum number of posts to fetch
Returns:
list: List of posts in the modqueue
"""
url = f"{danbooru_url}/posts.json"
params = {
"tags": "status:pending OR status:flagged",
"limit": limit,
"login": username,
"api_key": api_key,
}
try:
response = requests.get(url, params=params)
if response.status_code == 200:
posts = response.json()
print(f"Found {len(posts)} posts in modqueue")
return posts
else:
print(f"Failed to fetch modqueue. Status code: {response.status_code}")
print(f"Response: {response.text}")
return []
except Exception as e:
print(f"Exception fetching modqueue: {e}")
return []