with api key

This commit is contained in:
Johannes
2026-04-23 18:41:36 +02:00
parent 1b3f30a5dd
commit 21fb84e4ab

View File

@@ -5,11 +5,13 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
URL = "https://e621.net/" #https://e621.net/
# === CONFIGURATION ===
QUERY = "n1k0" # Replace with your search query
SAVE_DIR = "Pictures/n1k0"
QUERY = "skidoo" # Replace with your search query
SAVE_DIR = "Pictures/skidoo"
LIMIT = 10000
PER_PAGE = 100 # API max is 320, but let's be safe
USER_AGENT = "e621-downloader/1.0 (by username on e621)" # Replace 'username' with your e621 username
USER_AGENT = "e621-downloader/1.0 (by Burrson on e621)"
LOGIN = "Burrson"
API_KEY = "gRBZhdfG9qkMPStyia6k7mFX"
THREADS = 100 # Number of parallel download threads
# Ensure save directory exists
@@ -28,15 +30,16 @@ while total_fetched < LIMIT:
"tags": QUERY,
"limit": PER_PAGE,
"page": current_page,
"login": LOGIN,
"api_key": API_KEY,
}
response = requests.get(URL + "posts.json", headers=headers, params=params)
response.raise_for_status()
data = response.json()
#print(data[0]["tags"])
posts = data
posts = data.get("posts", [])
#print (posts)
#posts = data.get("posts", [])
if not posts:
print(f"No more posts found at page {current_page}.")
break
@@ -58,13 +61,12 @@ print(f"Total posts collected for download: {len(all_posts)}")
def download_file(post):
#file_url = post.get("file", {}).get("url")
file_url = post["file_url"]
file_url = post.get("file", {}).get("url")
if not file_url:
return f"Skipped: No file URL for post {post.get('id')}"
#file_name = os.path.basename(file_url)
file_name = str(post["id"]) + os.path.splitext(post["file_url"])[1]
file_name = str(post["id"]) + os.path.splitext(file_url)[1]
file_path = os.path.join(SAVE_DIR, file_name)
try: