2023-09-11 16:09:18 +00:00
|
|
|
import sys
|
2023-09-11 17:02:17 +00:00
|
|
|
import logging
|
2023-09-11 16:09:18 +00:00
|
|
|
|
2023-09-11 17:02:17 +00:00
|
|
|
from logging_config import setup_logging
|
2023-09-11 17:35:55 +00:00
|
|
|
from image_processing import process_images
|
|
|
|
from deck_creation import prompt_for_card_content, response_to_json, to_package
|
|
|
|
|
|
|
|
APKG_FILE = "out.apkg"
|
2023-09-11 16:09:18 +00:00
|
|
|
|
2023-09-11 17:02:17 +00:00
|
|
|
setup_logging()
|
2023-09-11 16:09:18 +00:00
|
|
|
|
2023-09-11 17:35:55 +00:00
|
|
|
def images_to_package(directory_path):
|
|
|
|
ocr_text = process_images(directory_path)
|
2023-09-11 16:09:18 +00:00
|
|
|
response_text = prompt_for_card_content(ocr_text)
|
|
|
|
deck_json = response_to_json(response_text)
|
2023-09-11 17:35:55 +00:00
|
|
|
return to_package(deck_json)
|
2023-09-11 16:09:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if len(sys.argv) != 2:
|
|
|
|
print("Usage: python ankiai.py <directory_path_containing_images>")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2023-09-11 17:35:55 +00:00
|
|
|
images_to_package(sys.argv[1]).write_to_file(APKG_FILE)
|
|
|
|
logging.info(f"Deck created at: {APKG_FILE}")
|