-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
73 lines (66 loc) · 3.75 KB
/
main.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import src, time, json, os, random, logging, tensorflow, traceback
tensorflow.get_logger().setLevel(logging.FATAL)
class xool:
current_directory = os.getcwd()
types = ["classicshirts", "classicpants"]
def __init__(self, config):
if config["delete_all_images_on_restart"]:
src.files.remove_png()
self.config = config
for group in config["groups"]:
for cookie in config["groups"][group]["uploader_cookies"]:
self.upload(cookie, group)
def upload(self, cookie, group_id):
if not cookie:
raise Exception("Empty cookie")
cookie = src.cookie.cookie(cookie)
dn_stop = True
while dn_stop:
try:
current_type = random.choice(self.types)
items = src.scrape.scrape_assets(cookie, self.config["searching_tags"], current_type)
random.shuffle(items)
scraped = src.scrape.sort_assets(cookie, items[:5], self.config["blacklisted_creators"], self.config["blacklisted_words"], self.config["upload_without_blacklisted_words"]
)
for item in scraped:
if self.config["dupe_check"] and src.files.is_duplicate_file(f"{self.current_directory}/src/assets/{'shirts' if current_type == 'classicshirts' else 'pants'}", f"{item['name']}_{random.randint(0, 100)}.png"):
print(f"DUPE skipping: {item['name']}")
continue
path = src.download.save_asset(cookie, item["id"], "shirts" if current_type == "classicshirts" else "pants", item["name"], self.config["max_nudity_value"], self.current_directory)
if not path:
print(f"No path found skipping skipping: {item['name']}")
continue
if self.config["require_one_tag_in_name"]:
if any(value.lower() in os.path.basename(path).lower().split(" ") for value in self.config["searching_tags"].split(",")):
print(f"No required tag found skipping: {item['name']}")
continue
if self.config["dupe_check"] and src.files.is_similar(path, current_type):
print(f"Found similar clothe skipping: {item['name']}")
continue
item_uploaded = src.upload.create_asset(item["name"], path, "shirt" if current_type == "classicshirts" else "pants", cookie, group_id, self.config["description"], 5, 5)
if item_uploaded is False:
return
elif item_uploaded == 2:
print(f"Failed to upload skipping (not enough funds): {item['name']}")
continue
elif item_uploaded == 3:
print(f"Failed to upload skipping (no permission): {item['name']}")
continue
response = src.upload.release_asset(cookie, item_uploaded['response']['assetId'], self.config["assets_price"], item["name"], self.config["description"], group_id)
if response.status_code == 200 and response.json()["status"] == 0:
print(f"Released item. ID {item_uploaded['response']['assetId']}")
if self.config["upload_amount"] > 1:
self.config["upload_amount"] -= 1
elif self.config["upload_amount"] == 1:
dn_stop = False
else:
print(f"Failed to release item. ID {item_uploaded['response']['assetId']}")
except Exception as e:
if str(e) == "403":
print("403: Could mean invalid cookie.")
cookie.generate_token()
continue
print(f"ERROR: {traceback.format_exc()}")
finally:
time.sleep(self.config["sleep_each_upload"])
xool(json.loads(open("config.json", "r").read()))