INNER CODE UNIT · Python
main
cognitivetech/ollama-ebook-summary · book2text.py:160
def main(input_file, output_dir, output_csv):
if os.path.exists(output_dir):
shutil.rmtree(output_dir)
os.makedirs(output_dir, exist_ok=True)
file_type = os.path.splitext(input_file)[1][1:] # Remove the dot
if file_type == 'epub':
success = split_epub_by_sections(input_file, output_dir) # Changed from output_directory to output_dir
if not success:
print("Error detected while splitting EPUB. Attempting alternative method with epubunz.py.")
extract_html_files(input_file, output_dir) # Make sure this matches too
file_type = 'html'
elif file_type == 'pdf':
from lib.pdf_splitter import split_pdf, get_toc, prepare_page_ranges
pdf = pypdf.PdfReader(input_file)