q6 commited on
Commit
e948e33
·
1 Parent(s): 1840151

Moved transactions

Browse files
Client/Extract Pixiv/ai_search.py CHANGED
@@ -11,7 +11,7 @@ os.chdir(os.path.dirname(os.path.abspath(__file__)))
11
 
12
  input_url = input("Enter the URL: ")
13
 
14
- pages = 420 // 60
15
 
16
  params = {
17
  'raw': input_url,
 
11
 
12
  input_url = input("Enter the URL: ")
13
 
14
+ pages = 120 // 60
15
 
16
  params = {
17
  'raw': input_url,
Client/hunt.py CHANGED
@@ -27,17 +27,17 @@ for inp in inputs:
27
  start, end = map(int, inp.split("-"))
28
  indexs.extend(range(start - 1, end))
29
 
30
- with db.begin(write=True) as txn:
31
- for index in indexs:
32
- group_name = valid[index].rsplit(".", 1)[0]
33
 
34
- group_cache = os.listdir(f"images/{group_name}")
35
 
36
- with open(valid[index], "r") as f:
37
- post_ids = [x for x in f.read().split("\n") if x]
 
 
 
38
 
39
- filtered_post_ids = [post_id for post_id in post_ids if not txn.get(post_id.encode())]
40
- print(filtered_post_ids)
41
  data = requests.post('https://q6-p.hf.space/pixif', json={"post_ids": filtered_post_ids}).json()
42
 
43
  for post_id, url in data.items():
@@ -46,7 +46,7 @@ with db.begin(write=True) as txn:
46
  missing_post_ids = set(filtered_post_ids) - set(data.keys())
47
  for post_id in missing_post_ids:
48
  txn.put(post_id.encode(), b'\x00')
49
-
50
  to_download = {}
51
  for post_id in set(post_ids):
52
  if f"{post_id}.png" in images_cache:
@@ -55,14 +55,14 @@ with db.begin(write=True) as txn:
55
  if url != b'\x00':
56
  to_download[post_id] = url.decode()
57
 
58
- images_zip = requests.post('https://q6-p.hf.space/download', json={'posts': data})
59
 
60
- with io.BytesIO(images_zip.content) as f:
61
- with ZipFile(f) as z:
62
- z.extractall("images/Stash")
63
 
64
- for i, post_id in enumerate(post_ids):
65
- if f"{post_id}.png" in images_cache and f"{i}_{post_id}.png" not in group_cache:
66
- os.makedirs(f"images/{group_name}", exist_ok=True)
67
- os.link(f"images/Stash/{post_id}.png", f"images/{group_name}/{i}_{post_id}.png")
68
- continue
 
27
  start, end = map(int, inp.split("-"))
28
  indexs.extend(range(start - 1, end))
29
 
30
+ for index in indexs:
31
+ group_name = valid[index].rsplit(".", 1)[0]
 
32
 
33
+ group_cache = os.listdir(f"images/{group_name}")
34
 
35
+ with open(valid[index], "r") as f:
36
+ post_ids = [x for x in f.read().split("\n") if x]
37
+
38
+ with db.begin(write=True) as txn:
39
+ filtered_post_ids = [post_id for post_id in post_ids if txn.get(post_id.encode()) == None]
40
 
 
 
41
  data = requests.post('https://q6-p.hf.space/pixif', json={"post_ids": filtered_post_ids}).json()
42
 
43
  for post_id, url in data.items():
 
46
  missing_post_ids = set(filtered_post_ids) - set(data.keys())
47
  for post_id in missing_post_ids:
48
  txn.put(post_id.encode(), b'\x00')
49
+
50
  to_download = {}
51
  for post_id in set(post_ids):
52
  if f"{post_id}.png" in images_cache:
 
55
  if url != b'\x00':
56
  to_download[post_id] = url.decode()
57
 
58
+ images_zip = requests.post('https://q6-p.hf.space/download', json={'posts': data})
59
 
60
+ with io.BytesIO(images_zip.content) as f:
61
+ with ZipFile(f) as z:
62
+ z.extractall("images/Stash")
63
 
64
+ for i, post_id in enumerate(post_ids):
65
+ if f"{post_id}.png" in images_cache and f"{i}_{post_id}.png" not in group_cache:
66
+ os.makedirs(f"images/{group_name}", exist_ok=True)
67
+ os.link(f"images/Stash/{post_id}.png", f"images/{group_name}/{i}_{post_id}.png")
68
+ continue
Client/test2.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import lmdb
3
+ import requests
4
+ import io
5
+ from zipfile import ZipFile
6
+
7
+ img_base = 'https://i.pximg.net/img-original/'
8
+
9
+ os.chdir(os.path.dirname(os.path.abspath(__file__)))
10
+ os.makedirs("images/Stash", exist_ok=True)
11
+
12
+ db = lmdb.open("db", subdir=True, map_size=1048576)
13
+
14
+ with db.begin(write=True) as txn:
15
+ print(txn.get(b"test") == None)