diff --git a/summarize.py b/summarize.py index 45d5072..d3b6528 100755 --- a/summarize.py +++ b/summarize.py @@ -33,28 +33,24 @@ def grab_subtitles(url: str | Path) -> Path: import yt_dlp temp_dir = get_temp_dir() - try: - ydl_opts = { - "outtmpl": f"{temp_dir}/subs", - "writeautomaticsub": True, - "subtitlesformat": "json3", - "skip_download": True, - } + ydl_opts = { + "outtmpl": f"{temp_dir}/subs", + "writeautomaticsub": True, + "subtitlesformat": "json3", + "skip_download": True, + } - with yt_dlp.YoutubeDL(ydl_opts) as ydl: - info = ydl.extract_info(url, download=True) - filename = ydl.prepare_filename(info) - print(f"Subtitle file saved as: {filename}") + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + info = ydl.extract_info(url, download=True) + filename = ydl.prepare_filename(info) + print(f"Subtitle file saved as: {filename}") - for root, _, files in Path(temp_dir).walk(): - for file in files: - if file.endswith(".json3"): - return Path(root).joinpath(file) + for root, _, files in Path(temp_dir).walk(): + for file in files: + if file.endswith(".json3"): + return Path(root).joinpath(file) - raise ValueError("No correct json3 transcript object found.") - - except ValueError as e: - print(e) + raise ValueError("No correct json3 transcript object found.") def get_temp_dir() -> str: