mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-29 01:00:11 +02:00
allow passing links to remove method
This commit is contained in:
@@ -547,6 +547,7 @@ def add(urls: Union[str, List[str]],
|
|||||||
def remove(filter_str: Optional[str]=None,
|
def remove(filter_str: Optional[str]=None,
|
||||||
filter_patterns: Optional[List[str]]=None,
|
filter_patterns: Optional[List[str]]=None,
|
||||||
filter_type: str='exact',
|
filter_type: str='exact',
|
||||||
|
links: Optional[List[Link]]=None,
|
||||||
after: Optional[float]=None,
|
after: Optional[float]=None,
|
||||||
before: Optional[float]=None,
|
before: Optional[float]=None,
|
||||||
yes: bool=False,
|
yes: bool=False,
|
||||||
@@ -556,6 +557,7 @@ def remove(filter_str: Optional[str]=None,
|
|||||||
|
|
||||||
check_data_folder(out_dir=out_dir)
|
check_data_folder(out_dir=out_dir)
|
||||||
|
|
||||||
|
if links is None:
|
||||||
if filter_str and filter_patterns:
|
if filter_str and filter_patterns:
|
||||||
stderr(
|
stderr(
|
||||||
'[X] You should pass either a pattern as an argument, '
|
'[X] You should pass either a pattern as an argument, '
|
||||||
@@ -589,6 +591,7 @@ def remove(filter_str: Optional[str]=None,
|
|||||||
finally:
|
finally:
|
||||||
timer.end()
|
timer.end()
|
||||||
|
|
||||||
|
|
||||||
if not len(links):
|
if not len(links):
|
||||||
log_removal_finished(0, 0)
|
log_removal_finished(0, 0)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
@@ -606,7 +609,8 @@ def remove(filter_str: Optional[str]=None,
|
|||||||
should_remove = (
|
should_remove = (
|
||||||
(after is not None and float(link.timestamp) < after)
|
(after is not None and float(link.timestamp) < after)
|
||||||
or (before is not None and float(link.timestamp) > before)
|
or (before is not None and float(link.timestamp) > before)
|
||||||
or link_matches_filter(link, filter_patterns, filter_type)
|
or link_matches_filter(link, filter_patterns or [], filter_type)
|
||||||
|
or link in links
|
||||||
)
|
)
|
||||||
if should_remove:
|
if should_remove:
|
||||||
to_delete.append(link)
|
to_delete.append(link)
|
||||||
|
Reference in New Issue
Block a user