def make_client(): """Create a client object""" key, secret = apikey.key, apikey.secret client = GoodreadsClient(key, secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) return client
def test_many_authors(self): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) book = client.book('18774683') assert len(book.authors) == 2 assert isinstance(book.authors[0], GoodreadsAuthor)
def create_book(book_id, rating=None): resp = GoodreadsClient.book(book_id) book = BookSchema().load(resp) book.save() resp_author = resp["authors"]["author"] if type(resp_author) != list: resp_author = [resp_author] for author in resp_author: a = AuthorSchema().load(author) a.save() book.authors.add(a) book.series = try_get_series(resp["work"][0]["id"]) book.series.save() resp_publisher = resp["publisher"] if resp_publisher: (pub, created) = Publisher.objects.get_or_create(name=resp_publisher) book.publisher = pub if rating is not None and rating != 0: book.rating = rating book.save()
def connect(key=None, secret=None, enabled=True): global _client if not enabled or not key or not secret: _client = None return if _client: # make sure the configuration has not changed since last we used the client if _client.client_key != key or _client.client_secret != secret: _client = None if not _client: _client = GoodreadsClient(key, secret)
def books_read_by_user(): results = [] page = 1 while True: resp = GoodreadsClient.shelf(settings.GOODREADS_USER_ID, "read", page) results += resp["review"] if int(resp["@end"]) >= int(resp["@total"]): break page += 1 return results
def try_get_series(work_id): try: series = GoodreadsClient.series(work_id) series = series["series_work"] # FIXME: probably shouldn't just select the first option automatically # if there are multiple choices... if type(series) == list: series = series[0] return SeriesSchema().load(series["series"]) except: uncategorized = Series.objects.get(id=0) return uncategorized
def search(request): query = request.GET.get("query") if query is not None: page = request.GET.get("page", 1) context = { "results": GoodreadsClient.search(query, page), "read": {b.id for b in Book.objects.all()}, "page": page, } else: context = {} return render(request, "web/search.html", context=context)
def setup_class(cls): client = GoodreadsClient('nTRaECtlyOjSmjJnLKRaiw', 'hCXp9GKlAe3sk1QIj0jXLF4UGLt9vfj54hDAfzHY') #client.authenticate(apikey.oauth_access_token, # apikey.oauth_access_token_secret) cls.book = client.book('11870085')
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.author = client.author('64941')
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.owned_book = client.owned_book('43018920')
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.comments = client.list_comments('user', '1')
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.events = client.list_events(55408) cls.event = cls.events[0]
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.comments = client.list_comments('user', '1') cls.comment = cls.comments[0]
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.book = client.book('11870085')
def setup_class(cls): cls.client = GoodreadsClient(apikey.key, apikey.secret) cls.client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret)
def setup_class(cls): client = GoodreadsClient(apikey.key, apikey.secret) client.authenticate(apikey.oauth_access_token, apikey.oauth_access_token_secret) cls.group = client.group(1)