-
Notifications
You must be signed in to change notification settings - Fork 0
/
Book.py
27 lines (23 loc) · 835 Bytes
/
Book.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests
class Book(object):
def __init__(self, url, name, isbn, authors, numberOfPages, publisher, country, mediaType, released, characters, povCharacters):
self.url = url
self.name = name
self.isbn = isbn
self.authors = authors
self.numberOfPages = numberOfPages
self.publisher = publisher
self.country = country
self.mediaType = mediaType
self.released = released
#will be list of urls
self.characters = characters
self.characters_processed = None
self.povCharacters = povCharacters
@classmethod
def fromurl(cls, url):
json = requests.get(url).json()
if (type(json) == dict):
return [cls(*json.values())]
else:
return [cls(*(x.values())) for x in json]