mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-25 16:38:09 +00:00
Small code cleanup
This commit is contained in:
parent
470c5d4acb
commit
72b4e7da76
3 changed files with 16 additions and 13 deletions
|
@ -17,16 +17,19 @@ class AbstractConnector(ABC):
|
||||||
|
|
||||||
self.book_mappings = {}
|
self.book_mappings = {}
|
||||||
|
|
||||||
self.base_url = info.base_url
|
fields = [
|
||||||
self.books_url = info.books_url
|
'base_url',
|
||||||
self.covers_url = info.covers_url
|
'books_url',
|
||||||
self.search_url = info.search_url
|
'covers_url',
|
||||||
self.key_name = info.key_name
|
'search_url',
|
||||||
self.max_query_count = info.max_query_count
|
'key_name',
|
||||||
self.name = info.name
|
'max_query_count',
|
||||||
self.local = info.local
|
'name',
|
||||||
self.id = info.id
|
'identifier',
|
||||||
self.identifier = info.identifier
|
'local'
|
||||||
|
]
|
||||||
|
for field in fields:
|
||||||
|
setattr(self, field, getattr(info, field))
|
||||||
|
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
|
@ -235,7 +238,7 @@ def get_data(url):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class SearchResult:
|
class SearchResult(object):
|
||||||
''' standardized search result object '''
|
''' standardized search result object '''
|
||||||
def __init__(self, title, key, author, year):
|
def __init__(self, title, key, author, year):
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Connector(AbstractConnector):
|
||||||
|
|
||||||
|
|
||||||
def get_cover(cover_url):
|
def get_cover(cover_url):
|
||||||
''' ask openlibrary for the cover '''
|
''' download the cover '''
|
||||||
image_name = cover_url.split('/')[-1]
|
image_name = cover_url.split('/')[-1]
|
||||||
response = requests.get(cover_url)
|
response = requests.get(cover_url)
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
|
|
|
@ -310,7 +310,7 @@ def handle_boost(activity):
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def handle_tag(activity):
|
def handle_tag(activity):
|
||||||
''' someone is tagging or shelving a book '''
|
''' someone is tagging a book '''
|
||||||
user = get_or_create_remote_user(activity['actor'])
|
user = get_or_create_remote_user(activity['actor'])
|
||||||
if not user.local:
|
if not user.local:
|
||||||
book = activity['target']['id']
|
book = activity['target']['id']
|
||||||
|
|
Loading…
Reference in a new issue