q6 commited on
Commit
45d40ce
·
1 Parent(s): c95aa3e
Files changed (3) hide show
  1. API/app.py +1 -1
  2. Client/Extract Pixiv/user.py +15 -19
  3. Client/hunt.py +11 -2
API/app.py CHANGED
@@ -207,7 +207,7 @@ async def pixif(
207
  results = await asyncio.gather(*tasks)
208
 
209
  image_exifs = {post_id: image_url for post_id, image_url in results if image_url}
210
- return {"image_exifs": image_exifs}
211
 
212
  @app.get("/")
213
  async def read_root():
 
207
  results = await asyncio.gather(*tasks)
208
 
209
  image_exifs = {post_id: image_url for post_id, image_url in results if image_url}
210
+ return image_exifs
211
 
212
  @app.get("/")
213
  async def read_root():
Client/Extract Pixiv/user.py CHANGED
@@ -2,26 +2,22 @@ import requests
2
  import re
3
  import os
4
 
5
- def main():
6
- os.chdir(os.path.dirname(os.path.abspath(__file__)))
7
 
8
- inp = input("Enter User IDs (separated by spaces or commas): ")
9
- user_ids = re.findall(r"\d+", inp)
10
 
11
- user_ids = [int(uid) for uid in user_ids]
12
 
13
- response = requests.get('https://q6-p.hf.space/users', params={'user_ids': user_ids})
14
- response.raise_for_status()
15
- data = response.json()
16
 
17
- for user_data in data:
18
- if 'error' in user_data:
19
- print(f"User ID {user_data.get('user_id')} Error: {user_data.get('error')}")
20
- continue
21
- filename = user_data['filename']
22
- post_ids = user_data['post_ids']
23
- with open(os.path.join("..", filename + '.txt'), "w", encoding='utf-8') as f:
24
- f.write("\n".join(post_ids))
25
-
26
- if __name__ == "__main__":
27
- main()
 
2
  import re
3
  import os
4
 
5
+ os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
6
 
7
+ inp = input("Enter User IDs (separated by spaces or commas): ")
8
+ user_ids = re.findall(r"\d+", inp)
9
 
10
+ user_ids = [int(uid) for uid in user_ids]
11
 
12
+ response = requests.get('https://q6-p.hf.space/users', params={'user_ids': user_ids})
13
+ response.raise_for_status()
14
+ data = response.json()
15
 
16
+ for user_data in data:
17
+ if 'error' in user_data:
18
+ print(f"User ID {user_data.get('user_id')} Error: {user_data.get('error')}")
19
+ continue
20
+ filename = user_data['filename']
21
+ post_ids = user_data['post_ids']
22
+ with open(os.path.join("..", filename + '.txt'), "w", encoding='utf-8') as f:
23
+ f.write("\n".join(post_ids))
 
 
 
Client/hunt.py CHANGED
@@ -4,9 +4,10 @@ import requests
4
 
5
 
6
  os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
7
 
8
  db = lmdb.open("db", subdir=True, map_size=10485760)
9
-
10
  valid = [f for f in os.listdir() if f.endswith(".txt")]
11
 
12
  for idx, file in enumerate(valid):
@@ -30,6 +31,14 @@ for index in indexs:
30
  with db.begin(write=False) as txn:
31
  post_ids = [post_id for post_id in post_ids if not txn.get(post_id.encode())]
32
 
 
 
33
  data = requests.post('https://q6-p.hf.space/pixif', json={"post_ids": post_ids}).json()
34
 
35
- print(data)
 
 
 
 
 
 
 
4
 
5
 
6
  os.chdir(os.path.dirname(os.path.abspath(__file__)))
7
+ os.makedirs("images/Stash", exist_ok=True)
8
 
9
  db = lmdb.open("db", subdir=True, map_size=10485760)
10
+ images_cache = os.listdir("images/Stash")
11
  valid = [f for f in os.listdir() if f.endswith(".txt")]
12
 
13
  for idx, file in enumerate(valid):
 
31
  with db.begin(write=False) as txn:
32
  post_ids = [post_id for post_id in post_ids if not txn.get(post_id.encode())]
33
 
34
+ if not post_ids:
35
+ continue
36
  data = requests.post('https://q6-p.hf.space/pixif', json={"post_ids": post_ids}).json()
37
 
38
+ with db.begin(write=True) as txn:
39
+ for post_id, url in data.items():
40
+ txn.put(post_id.encode(), url.encode())
41
+
42
+ missing_post_ids = set(post_ids) - set(data.keys())
43
+ for post_id in missing_post_ids:
44
+ txn.put(post_id.encode(), b'')