diff --git a/datahugger/base.py b/datahugger/base.py index a8b4994..893a12b 100644 --- a/datahugger/base.py +++ b/datahugger/base.py @@ -91,10 +91,14 @@ def _get_attr_link(self, record, **kwargs): return self._get_attr_attr(record, self.ATTR_FILE_LINK_JSONPATH) def _get_attr_name(self, record): - if not hasattr(self, "ATTR_NAME_JSONPATH"): - return None - - return self._get_attr_attr(record, self.ATTR_NAME_JSONPATH) + # if the name is defined, get the name + if hasattr(self, "ATTR_NAME_JSONPATH"): + return self._get_attr_attr(record, self.ATTR_NAME_JSONPATH) + # if not, try to get the name from the link + elif self._get_attr_link(record): + url = self._get_attr_link(record) + return url.split("/")[-1] + return None def _get_attr_size(self, record): if not hasattr(self, "ATTR_SIZE_JSONPATH"): diff --git a/datahugger/services.py b/datahugger/services.py index 82ff49f..5f0cb4e 100644 --- a/datahugger/services.py +++ b/datahugger/services.py @@ -402,9 +402,14 @@ class DataEuropaDataset(DatasetDownloader): META_FILES_JSONPATH = '$.@graph[?(@.@type == "dcat:Distribution")]' # paths to file attributes - ATTR_FILE_LINK_JSONPATH = "'dcat:accessURL'.@id" - ATTR_NAME_JSONPATH = "'dct:title'" ATTR_SIZE_JSONPATH = "'dcat:byteSize'.@value" + ATTR_FILE_LINK_JSONPATH = "'dcat:downloadURL'.@id" + + def _get_attr_link(self, record, **kwargs): + if self._get_attr_attr(record, "'dcat:downloadURL'.@id"): + return self._get_attr_attr(record, "'dcat:downloadURL'.@id") + else: + return self._get_attr_attr(record, "'dcat:accessURL'.@id") class SeaNoeDataset(DatasetDownloader): diff --git a/tests/test_repositories.toml b/tests/test_repositories.toml index 775786a..aa14924 100644 --- a/tests/test_repositories.toml +++ b/tests/test_repositories.toml @@ -119,8 +119,8 @@ location = "https://b2share.eudat.eu/records/db2ef5890fa44c7a85af366a50de73b9" files = "2024-02-13.sav" [[dataeuropa]] -location = "https://data.europa.eu/data/datasets/65e092e4009f18f050b14216" -files = "consolidation-wattzhub-schema-irve-statique-20240220-152202.csv" +location = "https://data.europa.eu/data/datasets/9qee-iv7c" +files = "9qee-iv7c.csv" [[seanoe]] location = "https://doi.org/10.17882/101042"