diff --git a/utils/gooodreads.py b/utils/gooodreads.py index a4cbf8e..3da4c7b 100644 --- a/utils/gooodreads.py +++ b/utils/gooodreads.py @@ -19,12 +19,13 @@ def get_details(book_object): book_object['lang'] = book.find('language_code').text book_object['rating'] = book.find('average_rating').text book_object['pages'] = book.find('num_pages').text + book_object['image_url'] = book.find('image_url').text except urllib.error.HTTPError as e: print('Error getting book details from GoodReads for book: {}. \nGot error: '.format(book_object['title'])) print(str(e.getcode()) + ' ' + e.msg) -def get_goodread_info(library): +def get_goodread_info(library, force): import sys print('') print('Getting GoodReads data...') @@ -39,7 +40,7 @@ def get_goodread_info(library): book_list = library[chapter] for book in book_list: # do not call the api again if we already have the infomation - if 'rating' in book and book['rating']: + if not force and 'rating' in book and book['rating']: processed += 1 continue get_details(book) diff --git a/utils/housekeep.py b/utils/housekeep.py index 50de7d3..7f8d1f0 100644 --- a/utils/housekeep.py +++ b/utils/housekeep.py @@ -20,6 +20,12 @@ try: '--sort_by', choices = ['rating', 'title', 'author', 'year'], help='defaults to rating') + parser.add_argument( + '--force', + dest='force', + action='store_true', + default=False + ) flags = parser.parse_args() except ImportError: flags = None @@ -42,10 +48,11 @@ def main(): out_file = flags.out_file or './../README-new.md' input_file_type = flags.input_file_type or 'new' sort_by = flags.sort_by or 'rating' + force = flags.force reverse = True if sort_by == 'rating' else False library = load(in_file, input_file_type) - get_goodread_info(library) + get_goodread_info(library, force) library = sort(library, sort_by, reverse) render(in_file, out_file, library)