def search_for(searchterm): """ search goodreads or googlebooks for a searchterm, return a list of results """ if lazylibrarian.CONFIG['BOOK_API'] == "GoogleBooks": GB = GoogleBooks(searchterm) myqueue = queue.Queue() search_api = threading.Thread(target=GB.find_results, name='GB-RESULTS', args=[searchterm, myqueue]) search_api.start() else: # lazylibrarian.CONFIG['BOOK_API'] == "GoodReads": myqueue = queue.Queue() GR = GoodReads(searchterm) search_api = threading.Thread(target=GR.find_results, name='GR-RESULTS', args=[searchterm, myqueue]) search_api.start() search_api.join() searchresults = myqueue.get() sortedlist = sorted(searchresults, key=itemgetter('highest_fuzz', 'num_reviews'), reverse=True) return sortedlist
def _findBook(self, **kwargs): if 'name' not in kwargs: self.data = 'Missing parameter: name' return if lazylibrarian.CONFIG['BOOK_API'] == "GoogleBooks": GB = GoogleBooks(kwargs['name']) myqueue = queue.Queue() search_api = threading.Thread(target=GB.find_results, name='API-GBRESULTS', args=[kwargs['name'], myqueue]) search_api.start() else: # lazylibrarian.CONFIG['BOOK_API'] == "GoodReads": GR = GoodReads(kwargs['name']) myqueue = queue.Queue() search_api = threading.Thread(target=GR.find_results, name='API-GRRESULTS', args=[kwargs['name'], myqueue]) search_api.start() search_api.join() self.data = myqueue.get()