p
File size: 1,033 Bytes
a082713
d625ef0
 
 
a082713
 
607c0f5
1b420ad
 
d625ef0
1b420ad
d625ef0
 
 
 
 
 
 
 
607c0f5
 
a082713
607c0f5
a082713
607c0f5
 
 
 
a082713
 
 
607c0f5
 
 
d625ef0
a082713
 
d625ef0
607c0f5
d625ef0
 
607c0f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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())