Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pubget/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _add_license(article: etree.Element, metadata: Dict[str, Any]) -> None:

def _add_id(article_id: etree.Element, metadata: Dict[str, Any]) -> None:
id_type = article_id.get("pub-id-type")
if id_type not in ["pmc", "pmid", "doi"]:
if id_type not in ["pmc", "pmid", "doi", "pmcid"]:
return
if id_type == "pmc":
id_type = "pmcid"
Expand Down
15 changes: 10 additions & 5 deletions src/pubget/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ def get_pmcid(article: Union[etree.ElementTree, etree.Element]) -> int:
pmcid = article.find(
"front/article-meta/article-id[@pub-id-type='pmcid']"
)
if pmc is None and pmcid is None:
raise ValueError("No PMC ID found in the article XML.")
if pmc:

val = None
if pmc is not None:
val = pmc.text
else:
val = pmcid.text.replace("PMC", "")
elif pmcid is not None:
val = pmcid.text
if val.startswith("PMC"):
val = val[3:]

if val is None or not val.isdigit():
raise ValueError("No valid PMCID found in article XML.")

return int(val)

Expand Down
Loading