moviewyrm/bookwyrm/connectors/bookwyrm_connector.py

28 lines
908 B
Python
Raw Normal View History

2021-03-08 16:49:10 +00:00
""" using another bookwyrm instance as a source of book data """
from bookwyrm import activitypub, models
2020-11-29 02:56:28 +00:00
from .abstract_connector import AbstractMinimalConnector, SearchResult
2020-03-28 19:55:53 +00:00
2020-11-29 02:56:28 +00:00
class Connector(AbstractMinimalConnector):
2021-03-08 16:49:10 +00:00
""" this is basically just for search """
2020-11-29 02:46:50 +00:00
def get_or_create_book(self, remote_id):
2021-02-17 03:35:43 +00:00
edition = activitypub.resolve_remote_id(remote_id, model=models.Edition)
2021-01-11 18:25:34 +00:00
work = edition.parent_work
work.default_edition = work.get_default_edition()
work.save()
return edition
2020-11-29 02:46:50 +00:00
def parse_search_data(self, data):
return data
2020-05-04 00:53:14 +00:00
2020-11-29 02:46:50 +00:00
def format_search_result(self, search_result):
2021-03-08 16:49:10 +00:00
search_result["connector"] = self
2020-11-29 02:46:50 +00:00
return SearchResult(**search_result)
2021-03-01 20:09:21 +00:00
def parse_isbn_search_data(self, data):
return data
def format_isbn_search_result(self, search_result):
2021-03-13 21:55:20 +00:00
return self.format_search_result(search_result)