diff --git a/reader3.py b/reader3.py index d0b9d3f..a9db5fd 100644 --- a/reader3.py +++ b/reader3.py @@ -8,6 +8,7 @@ from dataclasses import dataclass, field from typing import List, Dict, Optional, Any from datetime import datetime +from pathlib import Path from urllib.parse import unquote import ebooklib @@ -300,8 +301,10 @@ def save_to_pickle(book: Book, output_dir: str): sys.exit(1) epub_file = sys.argv[1] - assert os.path.exists(epub_file), "File not found." - out_dir = os.path.splitext(epub_file)[0] + "_data" + epub_path = Path(epub_file) + assert epub_path.exists(), "File not found." + out_dir = Path() / epub_path.stem + out_dir = str(out_dir) + "_data" book_obj = process_epub(epub_file, out_dir) save_to_pickle(book_obj, out_dir)