69def response(resp: "SXNG_Response") -> EngineResults:
70 res = EngineResults()
71 json_data = resp.json()
72
73 for item in json_data.get("docs", []):
74 cover = ""
75 if "lending_identifier_s" in item:
76 cover = f"https://archive.org/services/img/{item['lending_identifier_s']}"
77
78 published = item.get("publish_date")
79 if published:
80 published_dates = [date for date in map(_parse_date, published) if date]
81 if published_dates:
82 published = min(published_dates)
83
84 if not published:
85 published = _parse_date(str(item.get("first_publish_year")))
86
87 content = " / ".join(item.get("first_sentence", []))
88 res.add(
89 res.types.Paper(
90 url=f"{base_url}/{item['key']}",
91 title=item["title"],
92 content=content,
93 isbn=item.get("isbn", [])[:5],
94 authors=item.get("author_name", []),
95 thumbnail=cover,
96 publishedDate=published,
97 tags=item.get("subject", [])[:10] + item.get("place", [])[:10],
98 )
99 )
100 return res
101
102