1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00
fftcgtool/main.py

57 lines
1.3 KiB
Python
Raw Normal View History

2021-08-03 00:22:00 +00:00
#!/usr/bin/env python3
2021-08-04 16:36:23 +00:00
import argparse
import logging
import os
2021-08-03 00:22:00 +00:00
2021-08-09 04:33:33 +00:00
from fftcg import Book, Opus
# constants
GRID = 7, 10 # default in TTsim: 7 rows, 10 columns
RESOLUTION = 429, 600 # default in TTsim: 480x670 pixels per card
2021-08-09 02:03:24 +00:00
def main() -> None:
# set up CLI
2021-08-04 16:36:23 +00:00
parser = argparse.ArgumentParser(
2021-08-09 04:18:56 +00:00
description="Imports FFTCG cards for TT-Sim.",
)
2021-08-04 16:36:23 +00:00
parser.add_argument(
2021-08-09 04:18:56 +00:00
"opus_id",
default="promo",
2021-08-04 22:54:15 +00:00
metavar="Opus_ID",
2021-08-04 16:36:23 +00:00
nargs="?",
2021-08-09 04:18:56 +00:00
help="the Opus to import",
)
2021-08-04 16:36:23 +00:00
parser.add_argument(
2021-08-09 04:18:56 +00:00
"-n", "--num_threads",
2021-08-04 16:36:23 +00:00
type=int,
default=20,
metavar="COUNT",
2021-08-09 04:18:56 +00:00
help="maximum number of concurrent requests",
)
2021-08-04 16:36:23 +00:00
args = parser.parse_args()
# set up logging
2021-08-09 04:18:56 +00:00
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(threadName)s %(message)s")
2021-08-04 16:36:23 +00:00
# output directory
if not os.path.exists("out"):
os.mkdir("out")
os.chdir("out")
# main program
opus = Opus(args.opus_id)
2021-08-04 22:54:15 +00:00
book = Book(opus, GRID, RESOLUTION, "eg", args.num_threads)
book.save(f"{opus.name}_{{}}.jpg")
# bye
logging.info("Done. Put the generated JSON files in your 'Saved Objects' Folder.")
logging.info("Thanks for using fftcgtool!")
2021-08-04 01:39:19 +00:00
2021-08-09 04:18:56 +00:00
if __name__ == "__main__":
2021-08-03 21:41:25 +00:00
main()