utils: Update books.json.
This commit is contained in:
6806
utils/books.json
6806
utils/books.json
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ required_fields = ["title", "author", "url", "rating", "year", "pages", "image_u
|
||||
def book_has_all_fields(book):
|
||||
for required_field in required_fields:
|
||||
if required_field not in existing_book:
|
||||
print(f"Missing {required_field}")
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -21,13 +22,16 @@ if __name__ == "__main__":
|
||||
if (title := book["title"]) in existing_book_names_to_details:
|
||||
existing_book = existing_book_names_to_details[title]
|
||||
if book_has_all_fields(existing_book):
|
||||
print(f"🆗 {title}")
|
||||
continue
|
||||
new_book = {
|
||||
"title": title,
|
||||
"author": book["author"],
|
||||
"url": book["url"],
|
||||
}
|
||||
fetched = get_details(new_book)
|
||||
if fetched:
|
||||
print(f"✅ {title} fetched")
|
||||
print(f"✅ {title}")
|
||||
existing_book_names_to_details[title] = new_book
|
||||
with open("books.json", "w") as f:
|
||||
json.dump(existing_book_names_to_details, f, sort_keys=True, indent=4, separators=(',', ': '))
|
||||
|
||||
Reference in New Issue
Block a user