Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/mavedb/lib/external_publications.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,13 @@ def _fetch(self, url: str, return_format: str = "json") -> Any:
return []

response.raise_for_status()
return json.loads(response.text) if return_format == "json" else response.text

if return_format == "json":
if not response.text or not response.text.strip():
return []
try:
return json.loads(response.text)
except json.JSONDecodeError:
return []

return response.text
10 changes: 8 additions & 2 deletions src/mavedb/lib/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ async def fetch_biorxiv_article(identifier: str) -> Optional[RxivContentDetail]:
Fetch an existing bioRxiv article from Rxiv
"""
fetch = Rxiv("https://api.biorxiv.org", "biorxiv")
articles = fetch.content_detail(identifier=identifier)
try:
articles = fetch.content_detail(identifier=identifier)
except Exception:
return None
try:
return articles[-1]
except IndexError:
Expand All @@ -228,7 +231,10 @@ async def fetch_medrxiv_article(identifier: str) -> Optional[RxivContentDetail]:
Fetch an existing medRxiv article from Rxiv
"""
fetch = Rxiv("https://api.biorxiv.org", "medrxiv")
articles = fetch.content_detail(identifier=identifier)
try:
articles = fetch.content_detail(identifier=identifier)
except Exception:
return None
try:
return articles[-1]
except IndexError:
Expand Down
Loading