mirror of
https://github.com/saveweb/biliarchiver.git
synced 2024-09-18 18:45:28 -07:00
fix: catch OSError
when string is too long
`OSError: [Errno 36] File name too long`
This commit is contained in:
parent
7e55bb3298
commit
53c08488fc
@ -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
|
||||
return bvids
|
||||
|
Loading…
Reference in New Issue
Block a user