import asyncio import os import time from api_client import get_phpsessid from pixiv_api import headers, sanitize_filename, search ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) PAGES = 50 # input_url = 'https://www.pixiv.net/tags/(%20AI%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%20OR%20AI%E7%94%9F%E6%88%90%20OR%20StableDiffusion%20OR%20AI-generated%20OR%20NovelAI%20OR%20NovelAIDiffusionAI%20OR%20AIart%20OR%20ComfyUI%20)/artworks?order=popular_d&scd=2026-01-07&s_mode=s_tag' input_url = input("Enter the URL: ") x='' n=int(time.time()*100) while n: x=chr(97+n%26)+x n//=26 def main() -> int: phpsessid = get_phpsessid() pixiv_cookies = {"PHPSESSID": phpsessid} try: post_ids, filename = asyncio.run(search( input_url, PAGES, ai_only=True, real_only=False, cookies=pixiv_cookies, headers=headers, )) except Exception as exc: print(f"Error: {exc}") return 1 post_ids = list(dict.fromkeys(post_ids)) filename = sanitize_filename(filename) output_path = os.path.join(ROOT_DIR, f"{x}_{filename}.txt") with open(output_path, "w", encoding="utf-8") as f: f.write("\n".join(map(str, post_ids))) print(f"Wrote {len(post_ids)} ids to {output_path}") return 0 if __name__ == "__main__": raise SystemExit(main())