瀏覽代碼

Merge pull request #580 from BlipRanger/master

Nick Sweeting 5 年之前
父節點
當前提交
a194bb6301
共有 2 個文件被更改,包括 16 次插入2 次删除
  1. 13 2
      archivebox/core/forms.py
  2. 3 0
      archivebox/core/views.py

+ 13 - 2
archivebox/core/forms.py

@@ -10,11 +10,22 @@ CHOICES = (
     ('1', 'depth = 1 (archive these URLs and all URLs one hop away)'),
 )
 
+from ..extractors import get_default_archive_methods
+
+ARCHIVE_METHODS = [
+    (name, name)
+    for name, _, _ in get_default_archive_methods()
+]
+
+
 class AddLinkForm(forms.Form):
     url = forms.RegexField(label="URLs (one per line)", regex=URL_REGEX, min_length='6', strip=True, widget=forms.Textarea, required=True)
     depth = forms.ChoiceField(label="Archive depth", choices=CHOICES, widget=forms.RadioSelect, initial='0')
-
-
+    archive_methods = forms.MultipleChoiceField(
+        required=False,
+        widget=forms.SelectMultiple,
+        choices=ARCHIVE_METHODS,
+    )
 class TagWidgetMixin:
     def format_value(self, value):
         if value is not None and not isinstance(value, str):

+ 3 - 0
archivebox/core/views.py

@@ -150,12 +150,15 @@ class AddView(UserPassesTestMixin, FormView):
         url = form.cleaned_data["url"]
         print(f'[+] Adding URL: {url}')
         depth = 0 if form.cleaned_data["depth"] == "0" else 1
+        extractors = ','.join(form.cleaned_data["archive_methods"])
         input_kwargs = {
             "urls": url,
             "depth": depth,
             "update_all": False,
             "out_dir": OUTPUT_DIR,
         }
+        if extractors:
+            input_kwargs.update({"extractors": extractors})
         add_stdout = StringIO()
         with redirect_stdout(add_stdout):
             add(**input_kwargs)