diff --git a/scripts/validate-filenames.py b/scripts/validate-filenames.py index 392af24e..5d19d495 100644 --- a/scripts/validate-filenames.py +++ b/scripts/validate-filenames.py @@ -40,7 +40,7 @@ "variability", ) -API_URL = "https://cds.climate.copernicus.eu/api/v2" +API_URL = "https://cds.climate.copernicus.eu/api/catalogue/v1/collections" def main(paths: list[Path]) -> None: @@ -50,7 +50,7 @@ def main(paths: list[Path]) -> None: assert len(segments) == 4, f"{path=!s}: Invalid {path.name=}" ( data_type, - dataset_id, + collection_id, assessment_category, question_number, ) = segments @@ -64,10 +64,13 @@ def main(paths: list[Path]) -> None: assert folder in path.parts[folder_index], f"{path=!s}: Invalid {folder=}" # Check dataset ID - url = f"{API_URL}/resources/dataset/{dataset_id}" - assert ( - urllib.request.urlopen(url).getcode() == 200 - ), f"{path=!s}: Invalid {dataset_id=}" + url = "/".join([API_URL, collection_id]) + code = None + try: + code = urllib.request.urlopen(url).getcode() + except Exception: + pass + assert code == 200, f"{path=!s}: Invalid {collection_id=}" # Check assessment category assert (