fix: Remove support for multiple urls in oneshot command
This commit is contained in:
parent
3afb2401bc
commit
8bcb171e74
3 changed files with 14 additions and 13 deletions
|
@ -47,7 +47,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
|||
stdin_url = accept_stdin(stdin)
|
||||
if (stdin_url and url) or (not stdin and not url):
|
||||
stderr(
|
||||
'[X] You must pass URLs/paths to add via stdin or CLI arguments.\n',
|
||||
'[X] You must pass URL/path to add via stdin or CLI arguments.\n',
|
||||
color='red',
|
||||
)
|
||||
raise SystemExit(2)
|
||||
|
@ -59,4 +59,4 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(args=sys.argv[1:], stdin=sys.stdin)
|
||||
main(args=sys.argv[1:], stdin=sys.stdin)
|
||||
|
|
|
@ -123,7 +123,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
|
|||
|
||||
|
||||
@enforce_types
|
||||
def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None, skip_index: bool=False, oneshot: bool=False) -> List[Link]:
|
||||
def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None) -> List[Link]:
|
||||
if not links:
|
||||
return []
|
||||
|
||||
|
@ -132,11 +132,7 @@ def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[It
|
|||
link: Link = links[0]
|
||||
try:
|
||||
for idx, link in enumerate(links):
|
||||
if oneshot:
|
||||
link_out_dir = out_dir or link.link_dir
|
||||
else:
|
||||
link_out_dir = link.link_dir
|
||||
archive_link(link, overwrite=overwrite, methods=methods, out_dir=link_out_dir, skip_index=skip_index)
|
||||
archive_link(link, overwrite=overwrite, methods=methods, out_dir=link.link_dir)
|
||||
except KeyboardInterrupt:
|
||||
log_archiving_paused(len(links), idx, link.timestamp)
|
||||
raise SystemExit(0)
|
||||
|
|
|
@ -52,7 +52,7 @@ from .index.sql import (
|
|||
remove_from_sql_main_index,
|
||||
)
|
||||
from .index.html import parse_html_main_index
|
||||
from .extractors import archive_links
|
||||
from .extractors import archive_links, archive_link
|
||||
from .config import (
|
||||
stderr,
|
||||
ConfigDict,
|
||||
|
@ -496,10 +496,15 @@ def status(out_dir: str=OUTPUT_DIR) -> None:
|
|||
|
||||
@enforce_types
|
||||
def oneshot(url: str, out_dir: str=OUTPUT_DIR):
|
||||
oneshot_links, _ = parse_links_memory([url])
|
||||
oneshot_links, _ = dedupe_links([], oneshot_links)
|
||||
archive_links(oneshot_links, out_dir=out_dir, skip_index=True, oneshot=True)
|
||||
return oneshot_links
|
||||
oneshot_link, _ = parse_links_memory([url])
|
||||
if len(oneshot_link) > 1:
|
||||
stderr(
|
||||
'[X] You should pass a single url to the oneshot command',
|
||||
color='red'
|
||||
)
|
||||
raise SystemExit(2)
|
||||
archive_link(oneshot_link[0], out_dir=out_dir, skip_index=True)
|
||||
return oneshot_link
|
||||
|
||||
@enforce_types
|
||||
def add(urls: Union[str, List[str]],
|
||||
|
|
Loading…
Reference in a new issue