Change how goodread import writes reviews
- adds published date - broadcasts review imports - completes review and shelve actions as it goes - some small connector fixes fixes #247
This commit is contained in:
@ -2,14 +2,16 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from dateutil import parser
|
||||
import pytz
|
||||
from urllib3.exceptions import ProtocolError
|
||||
import requests
|
||||
from requests import HTTPError
|
||||
|
||||
from django.db import transaction
|
||||
|
||||
from bookwyrm import models
|
||||
|
||||
|
||||
class ConnectorException(Exception):
|
||||
class ConnectorException(HTTPError):
|
||||
''' when the connector can't do what was asked '''
|
||||
|
||||
|
||||
@ -155,9 +157,11 @@ class AbstractConnector(ABC):
|
||||
''' for creating a new book or syncing with data '''
|
||||
book = update_from_mappings(book, data, self.book_mappings)
|
||||
|
||||
author_text = []
|
||||
for author in self.get_authors_from_data(data):
|
||||
book.authors.add(author)
|
||||
book.author_text = ', '.join(a.display_name for a in book.authors.all())
|
||||
author_text += author.display_name
|
||||
book.author_text = ', '.join(author_text)
|
||||
book.save()
|
||||
|
||||
if not update_cover:
|
||||
@ -287,12 +291,15 @@ def get_date(date_string):
|
||||
|
||||
def get_data(url):
|
||||
''' wrapper for request.get '''
|
||||
resp = requests.get(
|
||||
url,
|
||||
headers={
|
||||
'Accept': 'application/json; charset=utf-8',
|
||||
},
|
||||
)
|
||||
try:
|
||||
resp = requests.get(
|
||||
url,
|
||||
headers={
|
||||
'Accept': 'application/json; charset=utf-8',
|
||||
},
|
||||
)
|
||||
except ProtocolError:
|
||||
raise ConnectorException()
|
||||
if not resp.ok:
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
|
Reference in New Issue
Block a user