From 4afb936ed565164277b414c3cd18eac79f3829b0 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 27 Sep 2023 09:50:59 -0800 Subject: [PATCH] adds dataAccessUrls to opera product output --- SearchAPI/CMR/Output/jsonlite.py | 6 ++++-- SearchAPI/CMR/SubQuery.py | 2 +- SearchAPI/CMR/Translate/fields.py | 3 ++- SearchAPI/CMR/Translate/parse_cmr_response.py | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/SearchAPI/CMR/Output/jsonlite.py b/SearchAPI/CMR/Output/jsonlite.py index f85cf749..6fabc9db 100644 --- a/SearchAPI/CMR/Output/jsonlite.py +++ b/SearchAPI/CMR/Output/jsonlite.py @@ -42,6 +42,7 @@ def req_fields_jsonlite(): 'subswath', 'pgeVersion', 'operaBurstID', + 'additionalUrls' ] return fields @@ -177,9 +178,10 @@ def getItem(self, p): result['burst'] = burst - if p.get('operaBurstID') is not None: + if p.get('operaBurstID') is not None or result['productID'].startswith('OPERA'): result['opera'] = { - 'operaBurstID': p.get('operaBurstID') + 'operaBurstID': p.get('operaBurstID'), + 'additionalUrls': p.get('additionalUrls') } return result diff --git a/SearchAPI/CMR/SubQuery.py b/SearchAPI/CMR/SubQuery.py index 2d0e2330..dc267143 100644 --- a/SearchAPI/CMR/SubQuery.py +++ b/SearchAPI/CMR/SubQuery.py @@ -160,7 +160,7 @@ def get_page(self, session): api_url = self.cmr_api_url() response = session.post(api_url, data=self.params, headers=self.headers) - if 'CMR-Search-After' in response.headers: + if 'CMR-Search-After' in response.headers: session.headers.update({'CMR-Search-After': response.headers['CMR-Search-After']}) query_duration = perf_counter() - q_start diff --git a/SearchAPI/CMR/Translate/fields.py b/SearchAPI/CMR/Translate/fields.py index 83a8b48d..b9f5bebe 100644 --- a/SearchAPI/CMR/Translate/fields.py +++ b/SearchAPI/CMR/Translate/fields.py @@ -60,7 +60,8 @@ def get_field_paths(): 'thumbnailUrl': attr_path('THUMBNAIL_URL'), 'track': attr_path('PATH_NUMBER'), 'pgeVersion': "./PGEVersionClass/PGEVersion", - + 'additionalUrls': "./OnlineAccessURLs", + # BURST FIELDS 'absoluteBurstID': attr_path('BURST_ID_ABSOLUTE'), 'relativeBurstID': attr_path('BURST_ID_RELATIVE'), diff --git a/SearchAPI/CMR/Translate/parse_cmr_response.py b/SearchAPI/CMR/Translate/parse_cmr_response.py index e1a7f1a6..0e78ba28 100644 --- a/SearchAPI/CMR/Translate/parse_cmr_response.py +++ b/SearchAPI/CMR/Translate/parse_cmr_response.py @@ -198,7 +198,8 @@ def float_or_none(a): result['downloadUrl'] = urls[0] result['fileName'] = result['granuleName'] + '.' + urls[0].split('.')[-1] - + if result.get('product_file_id', '').startswith('OPERA'): + result['additionalUrls'] = [url for url in get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL') if not url.endswith('.md5') and not url.startswith('s3://')] return result