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