def METHOD_NAME(library: str, recheck: bool, edited: bool):
    """Scan Photos library to find photos with bad (incorrect) file extensions.
    This can be run with osxphotos via: `osxphotos run find_bad_extensions.py`
    Both STDOUT and STDERR are used to output results.
    STDOUT is used to output a CSV file with the following columns:
    uuid, original_filename, version, current_extension, correct_extension, path
    Thus, to save the results to a file, run:
    osxphotos run find_bad_extensions.py > results.csv
    """
    # exiftool required to run
    try:
        get_exiftool_path()
    except FileNotFoundError as e:
        print(
            ":cross_mark-emoji:  [red]Could not find exiftool. Please download and install"
            " from https://exiftool.org/",
            file=sys.stderr,
        )
        raise click.Abort() from e
    # path to the cache database to store results of extension check
    cache_db_path = os.path.join(get_data_dir(), "bad_extensions.db")
    kvstore = SQLiteKVStore(
        cache_db_path, wal=True, serialize=json.dumps, deserialize=json.loads
    )
    kvstore.about = "osxphotos bad extensions cache"
    print(f"Using cache database: [blue]{cache_db_path}", file=sys.stderr)
    # load the Photos database and check each photo
    photosdb = PhotosDB(dbfile=library)
    for photo in photosdb.photos():
        check_photo(photo, recheck, "original", kvstore)
        if edited and photo.hasadjustments:
            check_photo(photo, recheck, "edited", kvstore)