|
1 |
| -# To package up as executable, run this in command prompt: |
| 1 | +`# To package up as executable, run this in command prompt: |
2 | 2 | # pyinstaller --onefile --hidden-import=colorama --icon=favicon.ico autofill.py
|
3 | 3 | import colorama
|
4 | 4 | from webdriver_manager.chrome import ChromeDriverManager
|
@@ -108,7 +108,7 @@ def fill_cards(bar: tqdm, driver, root):
|
108 | 108 | # Switch the finish to foil if the user ordered foil cards
|
109 | 109 | if root[0][3].text == "true":
|
110 | 110 | foil_dropdown = Select(driver.find_element_by_id("dro_product_effect"))
|
111 |
| - foil_dropdown.select_by_visible_text("Holographic (card front)") |
| 111 | + foil_dropdown.select_by_value("EF_055") |
112 | 112 |
|
113 | 113 | # Accept current settings and move to next step
|
114 | 114 | driver.execute_script(
|
@@ -140,7 +140,10 @@ def fill_cards(bar: tqdm, driver, root):
|
140 | 140 |
|
141 | 141 | # Page over to the next step from "add text to fronts"
|
142 | 142 | wait(driver)
|
143 |
| - driver.find_element_by_id("closeBtn").click() |
| 143 | + try: |
| 144 | + driver.find_element_by_id("closeBtn").click() |
| 145 | + except NoSuchElementException: |
| 146 | + pass |
144 | 147 | driver.execute_script("javascript:oDesign.setNextStep();")
|
145 | 148 |
|
146 | 149 | # Select "different images" for backs
|
@@ -305,7 +308,6 @@ def download_card(bar: tqdm, cardinfo):
|
305 | 308 |
|
306 | 309 | except requests.exceptions.Timeout:
|
307 | 310 | # Failed to download image because of a timeout error - add it to error queue
|
308 |
| - # print("timeout error") |
309 | 311 | q_error.put("{}:\n {}".format(filename, "https://drive.google.com/uc?id=" + file_id + "&export=download"))
|
310 | 312 |
|
311 | 313 | # Same check as before - if, after we've tried to download the image, the file doesn't exist or is empty,
|
@@ -388,15 +390,21 @@ def insert_card(driver, pid, slots):
|
388 | 390 | print("MPC Autofill initialising.")
|
389 | 391 | t = time.time()
|
390 | 392 |
|
391 |
| - # Parse XML doc |
392 |
| - try: |
393 |
| - tree = ET.parse(currdir + "/cards.xml") |
394 |
| - except FileNotFoundError: |
| 393 | + # people sometimes name the file different things - so the script will try all of these filenames |
| 394 | + # before whinging that it can't find an order file in the directory |
| 395 | + tree = None |
| 396 | + filenames = ["cards.xml", "cards.xml.txt", "cards.txt.xml", "cards.xml.xml"] |
| 397 | + for filename in filenames: |
395 | 398 | try:
|
396 |
| - tree = ET.parse(currdir + "/cards.xml.txt") |
| 399 | + tree = ET.parse(currdir + "/" + filename) |
| 400 | + break |
397 | 401 | except FileNotFoundError:
|
398 |
| - input("cards.xml not found in this directory. Press enter to exit.") |
399 |
| - sys.exit(0) |
| 402 | + pass |
| 403 | + |
| 404 | + if not tree: |
| 405 | + input("cards.xml not found in this directory. Press enter to exit.") |
| 406 | + sys.exit(0) |
| 407 | + |
400 | 408 | root = tree.getroot()
|
401 | 409 |
|
402 | 410 | # Extract information out of XML doc
|
|
0 commit comments