Skip to content

Commit b9ea290

Browse files
author
Gerit Wagner
committed
crossref: ignore NA/UNKNOWN in url generation
1 parent db3f31b commit b9ea290

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

colrev/packages/crossref/src/crossref_api.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,28 @@ def _create_query_url(
465465
print(record.data)
466466
raise AssertionError
467467

468-
bibl = (
469-
record.data[Fields.TITLE].replace("-", "_")
470-
+ " "
471-
+ record.data.get(Fields.YEAR, "")
472-
)
468+
bibl = ""
469+
if Fields.TITLE in record.data and record.data[Fields.TITLE] not in [
470+
"",
471+
"NA",
472+
"UNKNOWN",
473+
]:
474+
bibl += record.data[Fields.TITLE]
475+
if Fields.YEAR in record.data and record.data[Fields.YEAR] not in [
476+
"",
477+
"NA",
478+
"UNKNOWN",
479+
]:
480+
bibl += record.data[Fields.YEAR]
481+
473482
bibl = re.sub(r"[\W]+", "", bibl.replace(" ", "_"))
474483
params["query.bibliographic"] = bibl.replace("_", " ").rstrip("+")
475-
476484
container_title = record.get_container_title()
477-
if "." not in container_title:
485+
if "." not in container_title and container_title not in [
486+
"NA",
487+
"",
488+
"UNKNOWN",
489+
]:
478490
container_title = container_title.replace(" ", "_")
479491
container_title = re.sub(r"[\W]+", "", container_title)
480492
params["query.container-title"] = container_title.replace("_", " ")

0 commit comments

Comments
 (0)