forked from robertmartin8/KindleClippings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (28 loc) · 1.32 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import logging
import fire
from src.clippings_parser import parse_clippings
from src.file_conversion import convert_files_to_formatted_highlights
logging.basicConfig(format='%(asctime)s %(name)s %(message)s', level=logging.DEBUG)
logger = logging.getLogger(__name__)
def main(source: str, destination: str, encoding: str = "utf8", output_format: str = "pdf", include_clip_meta: bool = True):
"""
Main function to parse Kindle clippings and create formatted files.
Parameters
----------
source : str
Path to the source file or directory.
destination : str
Path to the destination directory.
encoding : str, optional
Encoding of the source file, by default 'utf8'.
output_format : str, optional
Output format, by default 'pdf'.
include_clip_meta : bool, optional
Whether to include clipping metadata, by default True.
"""
logger.info(f"Using parameters: source: {source}, destination: {destination}, output_format: {output_format}, include_clip_meta: {include_clip_meta}")
parsed_files = parse_clippings(source, destination, encoding, include_clip_meta)
formatted_files = convert_files_to_formatted_highlights(parsed_files, output_format)
logger.info(f"{len(formatted_files)} converted successfully")
if __name__ == "__main__":
fire.Fire(main)