diff --git a/landsatxplore/earthexplorer.py b/landsatxplore/earthexplorer.py index 9b39dbb..5e0f3c3 100644 --- a/landsatxplore/earthexplorer.py +++ b/landsatxplore/earthexplorer.py @@ -32,6 +32,19 @@ "sentinel_2a": "5e83a42c6eba8084", } +# Quick fix to use fallback paths for Landsat 8 errors (suggested at https://github.com/yannforget/landsatxplore/issues/45) +DATA_PRODUCTS_II = { + "landsat_tm_c1": "5e83d08fd9932768", + "landsat_etm_c1": "5e83a507d6aaa3db", + "landsat_8_c1": "5e83d0b84df8d8c2", + "landsat_tm_c2_l1": "5e83d0a0f94d7d8d", + "landsat_etm_c2_l1": "5e83d0d08fec8a66", + "landsat_ot_c2_l1": "5e81f14f92acf9ef", + "landsat_tm_c2_l2": "5e83d11933473426", + "landsat_etm_c2_l2": "5e83d12aed0efa58", + "landsat_ot_c2_l2": "5e83d14fec7cae84", + "sentinel_2a": "5e83a42c6eba8084", +} def _get_tokens(body): """Get `csrf_token` and `__ncforminfo`.""" @@ -144,8 +157,16 @@ def download(self, identifier, output_dir, dataset=None, timeout=300, skip=False entity_id = self.api.get_entity_id(identifier, dataset) else: entity_id = identifier - url = EE_DOWNLOAD_URL.format( - data_product_id=DATA_PRODUCTS[dataset], entity_id=entity_id - ) - filename = self._download(url, output_dir, timeout=timeout, skip=skip) + + # Quick fix to use fallback paths for Landsat 8 errors (suggested at https://github.com/yannforget/landsatxplore/issues/45) + try: + url = EE_DOWNLOAD_URL.format( + data_product_id=DATA_PRODUCTS[dataset], entity_id=entity_id + ) + filename = self._download(url, output_dir, timeout=timeout, skip=skip) + except: + url = EE_DOWNLOAD_URL.format( + data_product_id=DATA_PRODUCTS_II[dataset], entity_id=entity_id + ) + filename = self._download(url, output_dir, timeout=timeout, skip=skip) return filename