fix url is too long to be a path error
This commit is contained in:
parent
e3ac4c2405
commit
2e2b4f8150
1 changed files with 12 additions and 8 deletions
|
@ -25,14 +25,18 @@ def parse_generic_txt_export(text_file: IO[str]) -> Iterable[Link]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# if the line is a local file path that resolves, then we can archive it
|
# if the line is a local file path that resolves, then we can archive it
|
||||||
if Path(line).exists():
|
try:
|
||||||
yield Link(
|
if Path(line).exists():
|
||||||
url=line,
|
yield Link(
|
||||||
timestamp=str(datetime.now().timestamp()),
|
url=line,
|
||||||
title=None,
|
timestamp=str(datetime.now().timestamp()),
|
||||||
tags=None,
|
title=None,
|
||||||
sources=[text_file.name],
|
tags=None,
|
||||||
)
|
sources=[text_file.name],
|
||||||
|
)
|
||||||
|
except (OSError, PermissionError):
|
||||||
|
# nvm, not a valid path...
|
||||||
|
pass
|
||||||
|
|
||||||
# otherwise look for anything that looks like a URL in the line
|
# otherwise look for anything that looks like a URL in the line
|
||||||
for url in re.findall(URL_REGEX, line):
|
for url in re.findall(URL_REGEX, line):
|
||||||
|
|
Loading…
Reference in a new issue