| 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 = 30 |
|
|
| 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=False, |
| 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) |
| with open(os.path.join(ROOT_DIR, f"{x}_{filename}.txt"), "w", encoding="utf-8") as f: |
| f.write("\n".join(map(str, post_ids))) |
| return 0 |
|
|
| if __name__ == "__main__": |
| raise SystemExit(main()) |
|
|