fix process script
This commit is contained in:
parent
d62894309a
commit
401a6a47d7
1 changed files with 4 additions and 4 deletions
|
@ -45,13 +45,13 @@ def process_log(media_type, log) -> None:
|
||||||
for i, item in enumerate(log_items):
|
for i, item in enumerate(log_items):
|
||||||
if id_key not in item:# and "skip" not in item:
|
if id_key not in item:# and "skip" not in item:
|
||||||
if media_type in ["films", "books"]:
|
if media_type in ["films", "books"]:
|
||||||
item_title = item["Title"]
|
item_title = item["Title"] if "Title" in item else item["title"]
|
||||||
elif "tv-episodes" == media_type:
|
elif "tv-episodes" == media_type:
|
||||||
item_title = item["Episode Title"]
|
item_title = item["Episode Title"]
|
||||||
elif "tv-series" == media_type:
|
elif "tv-series" == media_type:
|
||||||
item_title = item["Show Title"]
|
item_title = item["Show Title"]
|
||||||
|
|
||||||
logger.info(f"Processing {item_title} ({item['Author']})…")
|
logger.info(f"Processing {item_title} ({item['Author'] if "Author" in item else item["authors"] if "authors" in item else "No Author"})…")
|
||||||
|
|
||||||
# Rename pre-existing fields
|
# Rename pre-existing fields
|
||||||
if "Date Added" in item:
|
if "Date Added" in item:
|
||||||
|
@ -143,7 +143,7 @@ def process_log(media_type, log) -> None:
|
||||||
|
|
||||||
if new_log_item is None:
|
if new_log_item is None:
|
||||||
ol_work_id = input(
|
ol_work_id = input(
|
||||||
f"Enter OpenLibrary Work ID for '{item_title}' ({item['Author']}), or 'd' to delete the record: "
|
f"Enter OpenLibrary Work ID for '{item_title}' ({item['Author'] if "Author" in item else item["authors"] if "authors" in item else "No Author"}), or 'd' to delete the record: "
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'd' == ol_work_id:
|
if 'd' == ol_work_id:
|
||||||
|
@ -250,7 +250,7 @@ def import_from_openlibrary_by_details(item, item_title, media_type) -> dict | N
|
||||||
|
|
||||||
logger.info(f"Importing '{item_title}'…")
|
logger.info(f"Importing '{item_title}'…")
|
||||||
|
|
||||||
api_url = f"https://openlibrary.org/search.json?title={slugify(item['Title'].split(':')[0], separator='%20')}&author={slugify(item['Author'], separator='%20')}"
|
api_url = f"https://openlibrary.org/search.json?title={slugify((item['Title'] if "Title" in item else item["title"]).split(':')[0], separator='%20')}&author={slugify((item['Author'] if "Author" in item else item["authors"] if "authors" in item else "No Author"), separator='%20')}"
|
||||||
|
|
||||||
# Sending API request
|
# Sending API request
|
||||||
response = requests.get(api_url, headers={"accept": "application/json"}, timeout=15)
|
response = requests.get(api_url, headers={"accept": "application/json"}, timeout=15)
|
||||||
|
|
Loading…
Reference in a new issue