コード例 #1
0
    def _getAuthorCategory(self, author):
        """
        :param author: author
        
        Since ISBNdb does not provide author info
        """
        category_set = []
        from goodReadsApiParser import goodReadsApiParser as gr
        import itertools
        gr_instance = gr(self.GrKey)
        author_id = str(gr_instance.getAuthorId(author)) #get the gr id
        xml = gr_instance.connectToGoodreads("http://www.goodreads.com/author/list/"+author_id+".xml")#paginate the author's books
        #get the isbn of the first book returnedl ex, for the shining it's 0450040186
        tree = ET.fromstring(xml)
        categories = [category for category in tree.getiterator("isbn")]
        isbns= [i.text for i in categories]
        
        #return a list of isbns
        

        for i in isbns[:5]:
            for returned_genre in self._getTitleCategory(isbn = i):
                category_set.append(returned_genre.title())
                continue  #don't break on a returned value of None
        #category_set = set(category_set)
            
        
        return category_set
コード例 #2
0
 def getISBN(self,title):
     """
     :param: book title
     Given a book title, call the Goodreads parser and get the ISBN 
     of the top-ranked result. Goodreads will tolerate keyword searches
     for titles.  
     
     """
     from goodReadsApiParser import goodReadsApiParser as gr
     gr_instance = gr(self.GrKey)
     return str(gr_instance.getISBN(title))
コード例 #3
0
 def getBookAuthor(self, title):
     """
     :param title: title
     
     Given a book title, returns the  author of that book 
     using the getAuthor() method of goodReadsApiParser.py
     
     """
     from goodReadsApiParser import goodReadsApiParser as gr
     gr_instance = gr(self.GrKey)
     return str(gr_instance.getAuthor(title))