diff --git a/biliarchiver/cli_tools/utils.py b/biliarchiver/cli_tools/utils.py index 4f6586c..8613160 100644 --- a/biliarchiver/cli_tools/utils.py +++ b/biliarchiver/cli_tools/utils.py @@ -8,10 +8,13 @@ def read_bvids(bvids: str) -> list[str]: bvids_list = None file = Path(bvids) - if file.exists() and file.is_file(): - with open(file, "r", encoding="utf-8") as f: - bvids_list = f.read().split() - else: + try: + if file.exists() and file.is_file(): + with open(file, "r", encoding="utf-8") as f: + bvids_list = f.read().split() + else: + raise Exception("Not a file") + except Exception as _: bvids_list = bvids.split() del bvids @@ -26,4 +29,4 @@ def read_bvids(bvids: str) -> list[str]: def read_bvids_from_txt(txt_path: Union[Path,str]) -> List[str]: with open(txt_path, "r", encoding="utf-8") as f: bvids = [line.strip() for line in f if line.strip().startswith("BV")] - return bvids \ No newline at end of file + return bvids