🤬
  • ■ ■ ■ ■ ■
    changedetectionio/fetch_processor/__init__.py
    skipped 2 lines
    3 3  class fetch_processor():
    4 4   contents = b''
    5 5   screenshot = None
     6 + datastore = None
    6 7   
    7 8   """
    8 9   base class for all fetch processors
    9 10   - json_html_plaintext
    10 11   - image (future)
    11 12   """
    12  - def __init__(self, *args, datastore, **kwargs):
    13  - super().__init__(*args, **kwargs)
    14  - self.datastore = datastore
    15  - 
    16  - # If there was a proxy list enabled, figure out what proxy_args/which proxy to use
    17  - # if watch.proxy use that
    18  - # fetcher.proxy_override = watch.proxy or main config proxy
    19  - # Allows override the proxy on a per-request basis
    20  - # ALWAYS use the first one is nothing selected
    21  - 
    22  - def set_proxy_from_list(self, watch):
    23  - proxy_args = None
    24  - if self.datastore.proxy_list is None:
    25  - return None
    26  - 
    27  - # If its a valid one
    28  - if any([watch['proxy'] in p for p in self.datastore.proxy_list]):
    29  - proxy_args = watch['proxy']
    30  - 
    31  - # not valid (including None), try the system one
    32  - else:
    33  - system_proxy = self.datastore.data['settings']['requests']['proxy']
    34  - # Is not None and exists
    35  - if any([system_proxy in p for p in self.datastore.proxy_list]):
    36  - proxy_args = system_proxy
    37  - 
    38  - # Fallback - Did not resolve anything, use the first available
    39  - if proxy_args is None:
    40  - proxy_args = self.datastore.proxy_list[0][0]
    41  - 
    42  - return proxy_args
    43 13   
  • ■ ■ ■ ■ ■
    changedetectionio/fetch_processor/image.py
    skipped 26 lines
    27 27  class perform_site_check(fetch_processor):
    28 28   xpath_data = None
    29 29   
     30 + def __init__(self, *args, datastore, **kwargs):
     31 + self.datastore = datastore
     32 + super().__init__(*args, **kwargs)
     33 + 
    30 34   def run(self, uuid):
    31 35   changed_detected = False
    32 36   screenshot = False # as bytes
    skipped 41 lines
    74 78   # If the klass doesnt exist, just use a default
    75 79   klass = getattr(content_fetcher, "html_requests")
    76 80   
    77  - proxy_args = self.set_proxy_from_list(watch)
     81 + proxy_args = self.datastore.get_preferred_proxy_for_watch(uuid)
    78 82   fetcher = klass(proxy_override=proxy_args)
    79 83   
    80 84   fetcher.run(
    skipped 47 lines
  • ■ ■ ■ ■ ■
    changedetectionio/fetch_processor/json_html_plaintext.py
    skipped 17 lines
    18 18   xpath_data = None
    19 19   
    20 20   def __init__(self, *args, datastore, **kwargs):
     21 + self.datastore = datastore
    21 22   super().__init__(*args, **kwargs)
    22  - self.datastore = datastore
     23 + 
    23 24   
    24 25   # Doesn't look like python supports forward slash auto enclosure in re.findall
    25 26   # So convert it to inline flag "foobar(?i)" type configuration
    skipped 275 lines
Please wait...
Page is in error, reload to recover