dreadpirateshawn / goodreads Goto Github PK
View Code? Open in Web Editor NEWThis project forked from sefakilic/goodreads
:snake: Python wrapper for Goodreads API :books:
This project forked from sefakilic/goodreads
:snake: Python wrapper for Goodreads API :books:
When a shelf contains only a single item (or for instance the last page of a shelf does), then it's returned as a single dict rather than a list of dicts.
Example URL (although this will undoubtedly stop repro'ing as content changes):
https://www.goodreads.com/review/list/18761398.xml?v=2&page=3&shelf=3-star
This is ultimately an xml issue, since the spec does not disambiguate "always single child" vs "list that happens to be a single item". See martinblech/xmltodict#14 for discussion, and see https://stackoverflow.com/a/39068400/128977 for a workaround in newer xmltodict versions.
Sample api data:
<reviews start="41" end="60" total="587">
<review>
...
<date_added>Thu Apr 04 19:28:50 -0700 2019</date_added>
...
</review>
Desired method: date_added
Return value: datetime object
Use-case: Determining which books have been on my to-read shelf the longest.
From some vectors, the book data presents the gid as text, whereas other vectors returns the book data as an OrderedDict.
>>> from goodreads import client
>>> gc = client.GoodreadsClient("...", "...")
>>> books = gc.shelf("18761398", 'to-read')
>>> books[0].gid
OrderedDict([('@type', 'integer'), ('#text', '25109947')])
>>> book = gc.book(25109947)
>>> book.gid
'25109947'
The <rating>
value is present in the reviews API, e.g. https://www.goodreads.com/review/list/18761398.xml?v=2 aka "Get the books on a members shelf".
The data is outside the <book>
object in the review response, so it's not obtainable via the book._book_dict
.
The request here is to expand the client.shelf()
response to include the full review data, not just the book object.
Unclear run steps:
Add makefile or similar for tests, perhaps they use pytest?
Difficult to debug:
Actual value isn't reported by asserts, simply that it doesn't match expected value, e.g.
FAIL: tests.author_test.TestAuthor.test_gender
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/goodreads/tests/author_test.py", line 36, in test_gender
assert self.author.gender == 'malt'
AssertionError
Many missing asserts:
Various tests can never fail because they don't actually assert anything, e.g.
def test_born_at(self):
self.author.born_at == '1938/01/10'
Example of both cases:
OrderedDict([
('id', OrderedDict([
('@type', 'integer'),
('#text', '546454')])),
('isbn', '0532601467'),
('isbn13', '9780532601463'),
('text_reviews_count', OrderedDict([('@type', 'integer'), ('#text', '98')])),
('uri', 'kca://book/amzn1.gr.book.v1.nc7d34Wasx0hXPwjH9DMLQ'),
('title', 'The Voyage of the Space Beagle'),
('title_without_series', 'The Voyage of the Space Beagle'),
('image_url', 'https://s.gr-assets.com/assets/nophoto/book/111x148-bcc042a9c91a29c1d680899eff700a03.png'),
('small_image_url', 'https://s.gr-assets.com/assets/nophoto/book/50x75-a91bf249278a81aabab721ef782c4a74.png'),
('large_image_url', None),
('link', 'https://www.goodreads.com/book/show/546454.The_Voyage_of_the_Space_Beagle'),
('num_pages', '192'),
('format', 'Paperback'),
('edition_information', None),
('publisher', 'Macfadden-Bartell'),
('publication_day', None),
('publication_year', '1963'),
('publication_month', None),
('average_rating', '3.86'),
('ratings_count', '3137'),
('description', None),
('authors', OrderedDict([
('author', OrderedDict([
('id', '1293688'),
('name', 'A.E. van Vogt'),
('role', None),
('image_url', OrderedDict([
('@nophoto', 'false'),
('#text', 'https://images.gr-assets.com/authors/1226200601p5/1293688.jpg')
])),
('small_image_url', OrderedDict([
('@nophoto', 'false'),
('#text', 'https://images.gr-assets.com/authors/1226200601p2/1293688.jpg')
])),
('link', 'https://www.goodreads.com/author/show/1293688.A_E_van_Vogt'),
('average_rating', '3.84'),
('ratings_count', '38578'),
('text_reviews_count', '2280')
]))
])),
('published', '1963'),
('work', OrderedDict([('id', '2016616'), ('uri', 'kca://work/amzn1.gr.work.v1.3tDylDehuKu4BaHTdlO5Ow')]))
])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.