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
16 changes: 12 additions & 4 deletions paper_search_mcp/academic_platforms/hal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import logging
import re
from datetime import datetime
from typing import List, Optional, Dict, Any

import requests
Expand Down Expand Up @@ -239,9 +240,16 @@ def _parse_doc(self, doc: Dict[str, Any]) -> Optional[Paper]:
doi = doi[0] if doi else ""

year = doc.get("publicationDateY_i") or doc.get("producedDateY_i", "")
pub_date = (
str(year) if year else (doc.get("submittedDate_s", "") or "")[:10]
)
pub_date_str = str(year) if year else (doc.get("submittedDate_s", "") or "")[:10]
pub_date = None
if pub_date_str:
try:
pub_date = datetime.fromisoformat(pub_date_str[:10])
except ValueError:
try:
pub_date = datetime(int(pub_date_str[:4]), 1, 1)
except (ValueError, TypeError):
pub_date = None

pdf_url = doc.get("fileMain_s", "") or ""
record_url = doc.get("uri_s", f"https://hal.archives-ouvertes.fr/{hal_id}")
Expand All @@ -252,7 +260,7 @@ def _parse_doc(self, doc: Dict[str, Any]) -> Optional[Paper]:
authors=authors,
abstract=abstract.strip(),
doi=doi,
published_date=str(pub_date),
published_date=pub_date,
Comment on lines 242 to +263
pdf_url=pdf_url,
url=record_url,
source="hal",
Expand Down
11 changes: 8 additions & 3 deletions paper_search_mcp/academic_platforms/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import annotations

import logging
from datetime import datetime
from typing import List, Optional, Dict, Any

import requests
Expand Down Expand Up @@ -244,9 +245,13 @@ def _parse_record(self, hit: Dict[str, Any]) -> Optional[Paper]:

abstract = re.sub(r"<[^>]+>", " ", abstract).strip()

pub_date = meta.get("publication_date", "")
if len(pub_date) >= 4:
pub_date = pub_date[:10] # keep YYYY-MM-DD
pub_date_str = meta.get("publication_date", "")
pub_date = None
if len(pub_date_str) >= 4:
try:
pub_date = datetime.fromisoformat(pub_date_str[:10])
except ValueError:
pub_date = datetime(int(pub_date_str[:4]), 1, 1)
Comment on lines +248 to +254

# Pick the best available PDF url from top-level links
pdf_url = ""
Expand Down