Don't show broken image previews when cover is absent

This commit is contained in:
Mouse Reeve 2021-04-29 13:03:56 -07:00
parent 6d7b3e9ae7
commit 15790abc70
2 changed files with 6 additions and 2 deletions

View file

@ -6,7 +6,7 @@ from .abstract_connector import AbstractMinimalConnector, SearchResult
class Connector(AbstractMinimalConnector): class Connector(AbstractMinimalConnector):
"""this is basically just for search""" """this is basically just for search"""
def get_or_create_book(self, remote_id, work=None): def get_or_create_book(self, remote_id):
return activitypub.resolve_remote_id(remote_id, model=models.Edition) return activitypub.resolve_remote_id(remote_id, model=models.Edition)
def parse_search_data(self, data): def parse_search_data(self, data):

View file

@ -69,6 +69,10 @@ class Connector(AbstractConnector):
return search_results return search_results
def format_search_result(self, search_result): def format_search_result(self, search_result):
cover = None
if search_result.cover:
cover = "%s%s" % (self.covers_url, search_result.cover)
return SearchResult( return SearchResult(
title=search_result.title, title=search_result.title,
key=search_result.remote_id, key=search_result.remote_id,
@ -77,7 +81,7 @@ class Connector(AbstractConnector):
if search_result.published_date if search_result.published_date
else None, else None,
connector=self, connector=self,
cover="%s%s" % (self.covers_url, search_result.cover), cover=cover,
confidence=search_result.rank if hasattr(search_result, "rank") else 1, confidence=search_result.rank if hasattr(search_result, "rank") else 1,
) )