feat(block): allow reading from multiple external sources
should be backward compatible if configured as a string already
This commit is contained in:
parent
0f537c888d
commit
b3012f66c1
1 changed files with 10 additions and 1 deletions
|
@ -35,7 +35,16 @@ class BlockExternalAutomation(BlockMirrorAutomation):
|
|||
|
||||
def fetch(self) -> None:
|
||||
user_agent = {'User-agent': 'BypassCensorship/1.0'}
|
||||
self._data = requests.get(app.config['EXTERNAL_CHECK_URL'], headers=user_agent, timeout=30).json()
|
||||
if isinstance(app.config.get('EXTERNAL_CHECK_URL', []), list):
|
||||
check_urls = app.config['EXTERNAL_CHECK_URL']
|
||||
elif isinstance(app.config.get('EXTERNAL_CHECK_URL'), str):
|
||||
check_urls = [app.config['EXTERNAL_CHECK_URL']]
|
||||
else:
|
||||
check_urls = []
|
||||
for check_url in check_urls:
|
||||
if self._data is None:
|
||||
self._data = []
|
||||
self._data.extend(requests.get(check_url, headers=user_agent, timeout=30).json())
|
||||
|
||||
def parse(self) -> None:
|
||||
self.patterns.extend(["https://" + trim_http_https(pattern) for pattern in self._data])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue