def search_author(name): """Looking for an author""" response = web.getXML("https://www.goodreads.com/api/author_url/%s?key=%s" % (urllib.parse.quote(name), context.config["goodreadskey"])) if response is not None and len(response.getElementsByTagName("author")) and response.getElementsByTagName("author")[0].hasAttribute("id"): response = web.getXML("https://www.goodreads.com/author/show/%s.xml?key=%s" % (urllib.parse.quote(response.getElementsByTagName("author")[0].getAttribute("id")), context.config["goodreadskey"])) if response is not None and len(response.getElementsByTagName("author")): return response.getElementsByTagName("author")[0] return None
def get_book(title): """Retrieve a book from its title""" response = web.getXML("https://www.goodreads.com/book/title.xml?key=%s&title=%s" % (context.config["goodreadskey"], urllib.parse.quote(title))) if response is not None and len(response.getElementsByTagName("book")): return response.getElementsByTagName("book")[0] else: return None
def search_books(title): """Get a list of book matching given title""" response = web.getXML("https://www.goodreads.com/search.xml?key=%s&q=%s" % (context.config["goodreadskey"], urllib.parse.quote(title))) if response is not None and len(response.getElementsByTagName("search")): return response.getElementsByTagName("search")[0].getElementsByTagName("results")[0].getElementsByTagName("work") else: return []
def search_author(name): """Looking for an author""" response = web.getXML( "https://www.goodreads.com/api/author_url/%s?key=%s" % (urllib.parse.quote(name), context.config["goodreadskey"])) if response is not None and len( response.getElementsByTagName("author") ) and response.getElementsByTagName("author")[0].hasAttribute("id"): response = web.getXML( "https://www.goodreads.com/author/show/%s.xml?key=%s" % (urllib.parse.quote( response.getElementsByTagName("author")[0].getAttribute("id")), context.config["goodreadskey"])) if response is not None and len( response.getElementsByTagName("author")): return response.getElementsByTagName("author")[0] return None
def station_status(station): """Gets available and free status of a given station""" response = web.getXML(URL_API % station) if response is not None: available = int(response.getElementsByTagName("available")[0].firstChild.nodeValue) free = int(response.getElementsByTagName("free")[0].firstChild.nodeValue) return (available, free) else: return (None, None)
def get_book(title): """Retrieve a book from its title""" response = web.getXML( "https://www.goodreads.com/book/title.xml?key=%s&title=%s" % (context.config["goodreadskey"], urllib.parse.quote(title))) if response is not None and len(response.getElementsByTagName("book")): return response.getElementsByTagName("book")[0] else: return None
def search_books(title): """Get a list of book matching given title""" response = web.getXML( "https://www.goodreads.com/search.xml?key=%s&q=%s" % (context.config["goodreadskey"], urllib.parse.quote(title))) if response is not None and len(response.getElementsByTagName("search")): return response.getElementsByTagName("search")[0].getElementsByTagName( "results")[0].getElementsByTagName("work") else: return []
def __init__(self, terms): self.wfares = web.getXML(URL_API % quote(terms), timeout=12)