forked from staff0rd/sd-hydrus-tagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (30 loc) · 1.01 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
from tqdm import tqdm
from src.api import HydrusApi
from src.commands import get_command
from src.utils import get_sdnext_tags
args, parser = get_command()
host = args.host
command = args.command
if command == "request-permissions":
api = HydrusApi(host, "")
result = api.request_permissions([2, 3])
print(result)
elif command == "process-images":
api = HydrusApi(host, args.access_key)
file_ids = api.get_files_to_process(args.extra_tags, force=args.force)
service_key = api.get_tag_service_key()
if service_key is None:
raise Exception("No tag service found")
image_count = len(file_ids)
print(f"Found {image_count} images to process")
if image_count > 0:
print("Processing images...")
for file_id in tqdm(file_ids):
image = api.get_image(file_id)
tags = get_sdnext_tags(image)
api.add_tags(file_id, service_key, tags)
print("Done!")
else:
print(f"Unknown command: {command}")
parser.print_help()
exit(1)