|
2 | 2 | from stashapi.stashapp import StashInterface |
3 | 3 | import sys |
4 | 4 | import json |
5 | | -import time |
6 | | -import re |
7 | 5 |
|
| 6 | +STASH_BOXES = [ |
| 7 | + "https://fansdb.cc", |
| 8 | + "https://pmvstash.org", |
| 9 | + "https://stashdb.org", |
| 10 | + "https://javstash.org" |
| 11 | +] |
8 | 12 |
|
9 | 13 | def processPerformer(performer): |
10 | | - log.debug(performer["stash_ids"]) |
| 14 | + log.trace(performer["stash_ids"]) |
11 | 15 | stash_boxes = [x["endpoint"] for x in performer["stash_ids"]] |
12 | 16 | needs_update = False |
13 | 17 | performer_update = {"id": performer["id"], "stash_ids": performer["stash_ids"]} |
14 | 18 | for url in performer["urls"]: |
15 | | - log.debug(url) |
16 | | - if "https://fansdb.cc/performers/" in url: |
17 | | - if "https://fansdb.cc/graphql" not in stash_boxes: |
| 19 | + log.trace(url) |
| 20 | + for domain in STASH_BOXES: |
| 21 | + if domain in url and f"{domain}/graphql" not in stash_boxes: |
18 | 22 | performer_update["stash_ids"].append( |
19 | | - {"endpoint": "https://fansdb.cc/graphql", "stash_id": url[-36:]} |
20 | | - ) |
21 | | - needs_update = True |
22 | | - if "https://pmvstash.org/performers/" in url: |
23 | | - if "https://pmvstash.org/graphql" not in stash_boxes: |
24 | | - performer_update["stash_ids"].append( |
25 | | - {"endpoint": "https://pmvstash.org/graphql", "stash_id": url[-36:]} |
26 | | - ) |
27 | | - needs_update = True |
28 | | - if "https://stashdb.org/performers/" in url: |
29 | | - if "https://stashdb.org/graphql" not in stash_boxes: |
30 | | - performer_update["stash_ids"].append( |
31 | | - {"endpoint": "https://stashdb.org/graphql", "stash_id": url[-36:]} |
| 23 | + {"endpoint": f"{domain}/graphql", "stash_id": url[-36:]} |
32 | 24 | ) |
33 | 25 | needs_update = True |
| 26 | + log.info("Adding stashbox %s to performer %s" % (domain, performer["id"])) |
34 | 27 |
|
35 | | - log.debug(performer_update) |
| 28 | + log.trace(performer_update) |
36 | 29 | if needs_update: |
37 | 30 | stash.update_performer(performer_update) |
38 | 31 |
|
|
0 commit comments