diff --git a/pywb/warcserver/index/indexsource.py b/pywb/warcserver/index/indexsource.py index 7572c56a..45da9d32 100644 --- a/pywb/warcserver/index/indexsource.py +++ b/pywb/warcserver/index/indexsource.py @@ -119,11 +119,12 @@ def init_from_config(cls, config): class RemoteIndexSource(BaseIndexSource): CDX_MATCH_RX = re.compile('^cdxj?\+(?Phttps?\:.*)') - def __init__(self, api_url, replay_url, url_field='load_url', closest_limit=100): + def __init__(self, api_url, replay_url, url_field='load_url', closest_limit=100, use_remote_date_filter=False): self.api_url = api_url self.replay_url = replay_url self.url_field = url_field self.closest_limit = closest_limit + self.use_remote_date_filter = use_remote_date_filter self._init_sesh() def _get_api_url(self, params): @@ -133,7 +134,13 @@ def _get_api_url(self, params): if 'matchType' in params: api_url += '&matchType=' + params.get('matchType') - + + if self.use_remote_date_filter: + if 'from' in params: + api_url += '&from=' + params.get('from') + if 'to' in params: + api_url += '&to=' + params.get('to') + return api_url def load_index(self, params): @@ -211,7 +218,9 @@ def init_from_config(cls, config): if config['type'] != 'cdx': return - return cls(config['api_url'], config['replay_url']) + use_remote_date_filter = config.get('use_remote_date_filter', False) + + return cls(config['api_url'], config['replay_url'], use_remote_date_filter=use_remote_date_filter) # =============================================================================