diff --git a/.gitignore b/.gitignore index b1be820..58cfea6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -konachan/ \ No newline at end of file +Pictures/ \ No newline at end of file diff --git a/Catgirl.py b/Catgirl.py index 753ed7d..1311172 100644 --- a/Catgirl.py +++ b/Catgirl.py @@ -1,7 +1,7 @@ import urllib.request -tags = "catgirl" #separate with + -rating = "rating%3A" + "safe" #all, safe, questionable, questionableplus, explicit +tags = "wedding_dress" #separate with + +rating = "rating%3A" + "all" #all, safe, questionable, questionableplus, explicit order = "order%3A" + "date" #date, fav, score, random, wide, nonwide site = "konachan.com" #konachan.com, yande.re, danbooru.donmai.us downloadnummer = 1 diff --git a/Slideshow.py b/Slideshow.py index 4eea1c8..d7abe8c 100644 --- a/Slideshow.py +++ b/Slideshow.py @@ -1,11 +1,11 @@ from flask import Flask, render_template import os -app = Flask(__name__, static_folder='konachan') +app = Flask(__name__, static_folder='Pictures') @app.route('/') def slideshow(): - image_folder = 'konachan' + image_folder = 'Pictures/lori_bondage' images = [f'/{image_folder}/{f}' for f in os.listdir(image_folder) if f.lower().endswith(('png', 'jpg', 'jpeg', 'gif'))] return render_template('slideshow.html', images=images) diff --git a/get_pics_kona.py b/get_pics_kona.py new file mode 100644 index 0000000..122749b --- /dev/null +++ b/get_pics_kona.py @@ -0,0 +1,88 @@ +import os +import requests +from tqdm import tqdm +from concurrent.futures import ThreadPoolExecutor, as_completed + +URL = "https://konachan.com/" #https://e621.net/ +# === CONFIGURATION === +QUERY = "cleavage barefoot rating:questionableless" # Replace with your search query +SAVE_DIR = "semi_safe_cleave" +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 +THREADS = 100 # Number of parallel download threads + +# Ensure save directory exists +os.makedirs(SAVE_DIR, exist_ok=True) + +headers = {"User-Agent": USER_AGENT} + +all_posts = [] +current_page = 1 +total_fetched = 0 + +print("Fetching posts in batches...") + +while total_fetched < LIMIT: + params = { + "tags": QUERY, + "limit": PER_PAGE, + "page": current_page, + } + + response = requests.get(URL + "post.json", headers=headers, params=params) + response.raise_for_status() + data = response.json() + #print(data[0]["tags"]) + posts = data + #posts = data.get("posts", []) + if not posts: + print(f"No more posts found at page {current_page}.") + break + + all_posts.extend(posts) + total_fetched += len(posts) + + print(f"Fetched {len(posts)} posts from page {current_page}. Total so far: {total_fetched}.") + + current_page += 1 + + # Stop if we fetched fewer than requested in this batch (meaning it's probably the end) + if len(posts) < PER_PAGE: + break + +# Trim to desired limit, just in case we overfetched +all_posts = all_posts[:LIMIT] +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"] + 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_path = os.path.join(SAVE_DIR, file_name) + + try: + file_response = requests.get(file_url, headers=headers) + file_response.raise_for_status() + with open(file_path, "wb") as f: + f.write(file_response.content) + return f"Downloaded: {file_name}" + except Exception as e: + return f"Failed: {file_url} with error {e}" + + +print("Starting download...") + +with ThreadPoolExecutor(max_workers=THREADS) as executor: + futures = [executor.submit(download_file, post) for post in all_posts] + for future in tqdm(as_completed(futures), total=len(futures), desc="Downloading"): + result = future.result() + if result.startswith("Failed") or result.startswith("Skipped"): + print(result) + +print("Download complete!") diff --git a/get_pics_yan.py b/get_pics_yan.py new file mode 100644 index 0000000..2e52058 --- /dev/null +++ b/get_pics_yan.py @@ -0,0 +1,89 @@ +import os +import requests +from tqdm import tqdm +from concurrent.futures import ThreadPoolExecutor, as_completed + +URL = "https://yande.re/" #https://e621.net/ +# === CONFIGURATION === +QUERY = "loli bondage" # Replace with your search query +SAVE_DIR = "lori_bondage" +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 +THREADS = 100 # Number of parallel download threads + +# Ensure save directory exists +os.makedirs(SAVE_DIR, exist_ok=True) + +headers = {"User-Agent": USER_AGENT} + +all_posts = [] +current_page = 1 +total_fetched = 0 + +print("Fetching posts in batches...") + +while total_fetched < LIMIT: + params = { + "tags": QUERY, + "limit": PER_PAGE, + "page": current_page, + } + + response = requests.get(URL + "post.json", headers=headers, params=params) + response.raise_for_status() + data = response.json() + #print(data[0]["tags"]) + posts = data + #print (posts) + #posts = data.get("posts", []) + if not posts: + print(f"No more posts found at page {current_page}.") + break + + all_posts.extend(posts) + total_fetched += len(posts) + + print(f"Fetched {len(posts)} posts from page {current_page}. Total so far: {total_fetched}.") + + current_page += 1 + + # Stop if we fetched fewer than requested in this batch (meaning it's probably the end) + if len(posts) < PER_PAGE: + break + +# Trim to desired limit, just in case we overfetched +all_posts = all_posts[:LIMIT] +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"] + 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_path = os.path.join(SAVE_DIR, file_name) + + try: + file_response = requests.get(file_url, headers=headers) + file_response.raise_for_status() + with open(file_path, "wb") as f: + f.write(file_response.content) + return f"Downloaded: {file_name}" + except Exception as e: + return f"Failed: {file_url} with error {e}" + + +print("Starting download...") + +with ThreadPoolExecutor(max_workers=THREADS) as executor: + futures = [executor.submit(download_file, post) for post in all_posts] + for future in tqdm(as_completed(futures), total=len(futures), desc="Downloading"): + result = future.result() + if result.startswith("Failed") or result.startswith("Skipped"): + print(result) + +print("Download complete!") diff --git a/templates/slideshow.html b/templates/slideshow.html index 45567ca..dc8bd50 100644 --- a/templates/slideshow.html +++ b/templates/slideshow.html @@ -3,30 +3,65 @@ Slideshow

Slideshow

- + + + +
+ + + + +
+ +
1 / {{ images|length }}
+ diff --git a/test/347822.jpg b/test/347822.jpg new file mode 100644 index 0000000..3e595c4 Binary files /dev/null and b/test/347822.jpg differ