mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-21 02:15:10 -04:00
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)
|
stdin_url = accept_stdin(stdin)
|
||||||
if (stdin_url and url) or (not stdin and not url):
|
if (stdin_url and url) or (not stdin and not url):
|
||||||
stderr(
|
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',
|
color='red',
|
||||||
)
|
)
|
||||||
raise SystemExit(2)
|
raise SystemExit(2)
|
||||||
|
|
|
@ -123,7 +123,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@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:
|
if not links:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -132,11 +132,7 @@ def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[It
|
||||||
link: Link = links[0]
|
link: Link = links[0]
|
||||||
try:
|
try:
|
||||||
for idx, link in enumerate(links):
|
for idx, link in enumerate(links):
|
||||||
if oneshot:
|
archive_link(link, overwrite=overwrite, methods=methods, out_dir=link.link_dir)
|
||||||
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)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
log_archiving_paused(len(links), idx, link.timestamp)
|
log_archiving_paused(len(links), idx, link.timestamp)
|
||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
|
|
|
@ -52,7 +52,7 @@ from .index.sql import (
|
||||||
remove_from_sql_main_index,
|
remove_from_sql_main_index,
|
||||||
)
|
)
|
||||||
from .index.html import parse_html_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 (
|
from .config import (
|
||||||
stderr,
|
stderr,
|
||||||
ConfigDict,
|
ConfigDict,
|
||||||
|
@ -496,10 +496,15 @@ def status(out_dir: str=OUTPUT_DIR) -> None:
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def oneshot(url: str, out_dir: str=OUTPUT_DIR):
|
def oneshot(url: str, out_dir: str=OUTPUT_DIR):
|
||||||
oneshot_links, _ = parse_links_memory([url])
|
oneshot_link, _ = parse_links_memory([url])
|
||||||
oneshot_links, _ = dedupe_links([], oneshot_links)
|
if len(oneshot_link) > 1:
|
||||||
archive_links(oneshot_links, out_dir=out_dir, skip_index=True, oneshot=True)
|
stderr(
|
||||||
return oneshot_links
|
'[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
|
@enforce_types
|
||||||
def add(urls: Union[str, List[str]],
|
def add(urls: Union[str, List[str]],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue