This commit is contained in:
dgtlmoon
2022-08-31 17:57:02 +02:00
parent 425f8ea632
commit dcd09359eb
5 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -500,7 +500,7 @@ def changedetection_app(config=None, datastore_o=None):
import hashlib
from changedetectionio.fetch_processor import json_html_plaintext
from .fetch_processor import json_html_plaintext
# Get the most recent one
newest_history_key = datastore.data['watching'][uuid].get('newest_history_key')
@@ -0,0 +1,37 @@
class fetch_processor():
"""
base class for all fetch processors
- json_html_plaintext
- image (future)
"""
def __init__(self, *args, datastore, **kwargs):
super().__init__(*args, **kwargs)
self.datastore = datastore
# If there was a proxy list enabled, figure out what proxy_args/which proxy to use
# if watch.proxy use that
# fetcher.proxy_override = watch.proxy or main config proxy
# Allows override the proxy on a per-request basis
# ALWAYS use the first one is nothing selected
def set_proxy_from_list(self, watch):
proxy_args = None
if self.datastore.proxy_list is None:
return None
# If its a valid one
if any([watch['proxy'] in p for p in self.datastore.proxy_list]):
proxy_args = watch['proxy']
# not valid (including None), try the system one
else:
system_proxy = self.datastore.data['settings']['requests']['proxy']
# Is not None and exists
if any([system_proxy in p for p in self.datastore.proxy_list]):
proxy_args = system_proxy
# Fallback - Did not resolve anything, use the first available
if proxy_args is None:
proxy_args = self.datastore.proxy_list[0][0]
return proxy_args
@@ -1,37 +0,0 @@
class fetch_processor():
"""
base class for all fetch processors
- json_html_plaintext
- image (future)
"""
def __init__(self, *args, datastore, **kwargs):
super().__init__(*args, **kwargs)
self.datastore = datastore
# If there was a proxy list enabled, figure out what proxy_args/which proxy to use
# if watch.proxy use that
# fetcher.proxy_override = watch.proxy or main config proxy
# Allows override the proxy on a per-request basis
# ALWAYS use the first one is nothing selected
def set_proxy_from_list(self, watch):
proxy_args = None
if self.datastore.proxy_list is None:
return None
# If its a valid one
if any([watch['proxy'] in p for p in self.datastore.proxy_list]):
proxy_args = watch['proxy']
# not valid (including None), try the system one
else:
system_proxy = self.datastore.data['settings']['requests']['proxy']
# Is not None and exists
if any([system_proxy in p for p in self.datastore.proxy_list]):
proxy_args = system_proxy
# Fallback - Did not resolve anything, use the first available
if proxy_args is None:
proxy_args = self.datastore.proxy_list[0][0]
return proxy_args
@@ -9,7 +9,7 @@ from changedetectionio import content_fetcher, html_tools
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from .fetch_processor import fetch_processor
from . import fetch_processor
# Some common stuff here that can be moved to a base class
# (set_proxy_from_list)
+1 -1
View File
@@ -117,7 +117,7 @@ class update_worker(threading.Thread):
os.unlink(full_path)
def run(self):
from changedetectionio.fetch_processor import json_html_plaintext
from .fetch_processor import json_html_plaintext
update_handler = json_html_plaintext.perform_site_check(datastore=self.datastore)