diff --git a/richcontext/scholapi/scholapi.py b/richcontext/scholapi/scholapi.py index 7ba5366..f120ddb 100755 --- a/richcontext/scholapi/scholapi.py +++ b/richcontext/scholapi/scholapi.py @@ -315,10 +315,22 @@ def title_search (self, title): result_title = self._get_xml_node_value(result, "title") if self.title_match(title, result_title): - meta["doi"] = self._get_xml_node_value(result, "pid", {"classname": "doi"}) - meta["title"] = self._get_xml_node_value(result, "title") - meta["url"] = self._get_xml_node_value(result, "url") - meta["authors"] = [a.text for a in result.find_all("creator")] + val = self._get_xml_node_value(result, "pid", {"classname": "doi"}) + if val: + meta["doi"] = val + + val = self._get_xml_node_value(result, "title") + if val: + meta["title"] = val + + val = self._get_xml_node_value(result, "url") + if val: + meta["url"] = val + + val = [a.text for a in result.find_all("creator")] + if val: + meta["authors"] = val + meta["open"] = len(result.find_all("bestaccessright", {"classid": "OPEN"})) > 0 timing = self._mark_elapsed_time(t0) diff --git a/test.py b/test.py index 35f9e49..bd89f33 100755 --- a/test.py +++ b/test.py @@ -253,6 +253,12 @@ def test_openaire_title_search (self): self.assertTrue(response.authors() == authors) self.assertTrue(response.meta["open"]) + title = "Quantitative easing, portfolio rebalancing and credit growth: Micro evidence from Germany" + if source.has_credentials(): + response = source.title_search(title) + source.report_perf(response.timing) + self.assertTrue("doi" not in response.meta) + self.assertTrue(response.title() == title) def test_openaire_fulltext_search (self): schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")