|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import os |
| 4 | +from typing import Annotated |
| 5 | +from typing import Optional |
4 | 6 |
|
| 7 | +import typer |
5 | 8 | from dotenv import load_dotenv |
6 | 9 | from utils.blogger import Blogger |
7 | 10 | from utils.downloader import Downloader |
|
15 | 18 | load_dotenv() |
16 | 19 | api_key = os.getenv("GEMMA_API_KEY") |
17 | 20 |
|
| 21 | +__version__ = "2.0.0" |
18 | 22 |
|
19 | | -if __name__ == "__main__": |
20 | | - url = input("Enter YouTube URL: ") |
21 | | - path_to_tesseract = input( |
22 | | - "Please enter the path where Tesseract is installed in your system: ", |
23 | | - ) |
| 23 | + |
| 24 | +def version_callback(value: bool): |
| 25 | + if value: |
| 26 | + print(f"Simone CLI Version: {__version__}") |
| 27 | + raise typer.Exit() |
| 28 | + |
| 29 | + |
| 30 | +def main( |
| 31 | + url: Annotated[ |
| 32 | + str, |
| 33 | + typer.Option( |
| 34 | + help="URL of the YouTube video. Should be within quotes.", |
| 35 | + rich_help_panel="Customization and Utils", |
| 36 | + ), |
| 37 | + ], |
| 38 | + path: Annotated[ |
| 39 | + str, |
| 40 | + typer.Option( |
| 41 | + help="Path where Tesseract is installed in your system. Should be within quotes.", |
| 42 | + rich_help_panel="Customization and Utils", |
| 43 | + ), |
| 44 | + ], |
| 45 | + version: Annotated[ |
| 46 | + Optional[bool], |
| 47 | + typer.Option("--version", callback=version_callback), |
| 48 | + ] = None, |
| 49 | +): |
24 | 50 |
|
25 | 51 | print("Downloading audio and video...") |
26 | | - downloads = Downloader(url) |
| 52 | + downloads = Downloader(f"{url}") |
27 | 53 | downloads.audio() |
28 | 54 | downloads.video() |
29 | 55 |
|
|
43 | 69 | frames = Framer("video.mp4") |
44 | 70 | frame = frames.get_video_frames() |
45 | 71 |
|
46 | | - scores = Scorer(frame, keyword, path_to_tesseract) |
| 72 | + scores = Scorer(frame, keyword, f"{path}") |
47 | 73 | score = scores.score_frames() |
48 | 74 |
|
49 | 75 | print("Saving screenshots...") |
|
57 | 83 | os.remove("video.mp4") |
58 | 84 |
|
59 | 85 | print("Blog post and 3 screenshots have been generated!") |
| 86 | + |
| 87 | + |
| 88 | +if __name__ == "__main__": |
| 89 | + typer.run(main) |
0 commit comments