Browse Source

Allow list filtering by tag name

JDC 5 years ago
parent
commit
cbb3d04c12
2 changed files with 2 additions and 1 deletions
  1. 1 1
      archivebox/cli/archivebox_list.py
  2. 1 0
      archivebox/index/__init__.py

+ 1 - 1
archivebox/cli/archivebox_list.py

@@ -98,7 +98,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
     parser.add_argument(
     parser.add_argument(
         '--filter-type',
         '--filter-type',
         type=str,
         type=str,
-        choices=('exact', 'substring', 'domain', 'regex'),
+        choices=('exact', 'substring', 'domain', 'regex','tag'),
         default='exact',
         default='exact',
         help='Type of pattern matching to use when filtering URLs',
         help='Type of pattern matching to use when filtering URLs',
     )
     )

+ 1 - 0
archivebox/index/__init__.py

@@ -361,6 +361,7 @@ LINK_FILTERS = {
     'substring': lambda pattern: Q(url__icontains=pattern),
     'substring': lambda pattern: Q(url__icontains=pattern),
     'regex': lambda pattern: Q(url__iregex=pattern),
     'regex': lambda pattern: Q(url__iregex=pattern),
     'domain': lambda pattern: Q(url__istartswith=f"http://{pattern}") | Q(url__istartswith=f"https://{pattern}") | Q(url__istartswith=f"ftp://{pattern}"),
     'domain': lambda pattern: Q(url__istartswith=f"http://{pattern}") | Q(url__istartswith=f"https://{pattern}") | Q(url__istartswith=f"ftp://{pattern}"),
+    'tag': lambda pattern: Q(tags__name=pattern),
 }
 }
 
 
 @enforce_types
 @enforce_types