(work)
| 309 | |
| 310 | |
| 311 | def format_work_data(work): |
| 312 | d = dict(work) |
| 313 | |
| 314 | key = work.get("key", "") |
| 315 | # New solr stores the key as /works/OLxxxW |
| 316 | if not key.startswith("/works/"): |
| 317 | key = "/works/" + key |
| 318 | |
| 319 | d["url"] = key |
| 320 | d["title"] = work.get("title", "") |
| 321 | |
| 322 | if "author_key" in work and "author_name" in work: |
| 323 | d["authors"] = [{"key": key, "name": name} for key, name in zip(work["author_key"], work["author_name"])] |
| 324 | |
| 325 | if "cover_edition_key" in work: |
| 326 | coverstore_url = get_coverstore_public_url() |
| 327 | d["cover_url"] = f"{coverstore_url}/b/olid/{work['cover_edition_key']}-M.jpg" |
| 328 | |
| 329 | d["read_url"] = "//archive.org/stream/" + work["ia"][0] |
| 330 | return d |
| 331 | |
| 332 | |
| 333 | class addauthor(delegate.page): |
no test coverage detected