rename path
This commit is contained in:
parent
78d829e1ac
commit
f6e591c940
1 changed files with 16 additions and 16 deletions
|
@ -101,7 +101,7 @@ def delete_existing(item_id: str, media_type: str, log: str) -> None:
|
||||||
else:
|
else:
|
||||||
raise Exception("Invalid ID for book")
|
raise Exception("Invalid ID for book")
|
||||||
|
|
||||||
elif media_type in ["films", "tv-episodes"]:
|
elif media_type in ["films", "tv_episodes"]:
|
||||||
if re.search("tt[0-9]+", item_id) is not None:
|
if re.search("tt[0-9]+", item_id) is not None:
|
||||||
id_key = "isbn_id"
|
id_key = "isbn_id"
|
||||||
elif re.search("[0-9]+", item_id) is not None:
|
elif re.search("[0-9]+", item_id) is not None:
|
||||||
|
@ -150,10 +150,10 @@ def check_for_existing(
|
||||||
p_log for p_log in ["log", "current", "wishlist"] if p_log != log
|
p_log for p_log in ["log", "current", "wishlist"] if p_log != log
|
||||||
]:
|
]:
|
||||||
if (
|
if (
|
||||||
"current" == log_to_check and media_type in ["books", "games", "tv-series"]
|
"current" == log_to_check and media_type in ["books", "games", "tv_series"]
|
||||||
) or (
|
) or (
|
||||||
"wishlist" == log_to_check
|
"wishlist" == log_to_check
|
||||||
and media_type in ["books", "games", "films", "tv-series"]
|
and media_type in ["books", "games", "films", "tv_series"]
|
||||||
):
|
):
|
||||||
existing_item = return_if_exists(item_id, media_type, log_to_check)
|
existing_item = return_if_exists(item_id, media_type, log_to_check)
|
||||||
if existing_item is not None:
|
if existing_item is not None:
|
||||||
|
@ -169,7 +169,7 @@ def add_item_to_log(item_id: str, media_type: str, log: str) -> None:
|
||||||
|
|
||||||
item: dict | None = None
|
item: dict | None = None
|
||||||
log_to_delete = None
|
log_to_delete = None
|
||||||
if media_type not in ["tv-episodes", "books"]:
|
if media_type not in ["tv_episodes", "books"]:
|
||||||
item, log_to_delete = check_for_existing(item_id, media_type, log)
|
item, log_to_delete = check_for_existing(item_id, media_type, log)
|
||||||
|
|
||||||
if item is None:
|
if item is None:
|
||||||
|
@ -203,7 +203,7 @@ def add_item_to_log(item_id: str, media_type: str, log: str) -> None:
|
||||||
item = new_item if new_item is not None else item
|
item = new_item if new_item is not None else item
|
||||||
|
|
||||||
if log in ["log", "current"]:
|
if log in ["log", "current"]:
|
||||||
if "date_started" not in item and media_type in ["books", "tv-series", "games"]:
|
if "date_started" not in item and media_type in ["books", "tv_series", "games"]:
|
||||||
date_started = ""
|
date_started = ""
|
||||||
while re.search("[0-9]{4}-[0-9]{2}-[0-9]{2}", date_started) is None:
|
while re.search("[0-9]{4}-[0-9]{2}-[0-9]{2}", date_started) is None:
|
||||||
date_started = input("Enter date started [YYYY-MM-DD, t for today]: ")
|
date_started = input("Enter date started [YYYY-MM-DD, t for today]: ")
|
||||||
|
@ -260,10 +260,10 @@ def add_item_to_log(item_id: str, media_type: str, log: str) -> None:
|
||||||
def import_by_id(import_id, media_type, log) -> dict | None:
|
def import_by_id(import_id, media_type, log) -> dict | None:
|
||||||
"""Import from the appropriate API by unique ID"""
|
"""Import from the appropriate API by unique ID"""
|
||||||
|
|
||||||
if media_type in ["films", "tv-series"]:
|
if media_type in ["films", "tv_series"]:
|
||||||
return import_from_tmdb_by_id(import_id, media_type)
|
return import_from_tmdb_by_id(import_id, media_type)
|
||||||
|
|
||||||
if media_type in ["tv-episodes"]:
|
if media_type in ["tv_episodes"]:
|
||||||
return import_from_tmdb_by_external_id(import_id, media_type)
|
return import_from_tmdb_by_external_id(import_id, media_type)
|
||||||
|
|
||||||
if media_type in ["books"]:
|
if media_type in ["books"]:
|
||||||
|
@ -307,9 +307,9 @@ def import_from_tmdb_by_external_id(external_id, media_type) -> dict:
|
||||||
raise Exception(f"Error {response.status_code}: {response.text}")
|
raise Exception(f"Error {response.status_code}: {response.text}")
|
||||||
|
|
||||||
key = ""
|
key = ""
|
||||||
if "tv-episodes" == media_type:
|
if "tv_episodes" == media_type:
|
||||||
key = "tv_episode_results"
|
key = "tv_episode_results"
|
||||||
elif "tv-series" == media_type:
|
elif "tv_series" == media_type:
|
||||||
key = "tv_results"
|
key = "tv_results"
|
||||||
elif "films" == media_type:
|
elif "films" == media_type:
|
||||||
key = "movie_results"
|
key = "movie_results"
|
||||||
|
@ -537,11 +537,11 @@ def cleanup_result(item, media_type) -> dict:
|
||||||
if field_name in item:
|
if field_name in item:
|
||||||
del item[field_name]
|
del item[field_name]
|
||||||
|
|
||||||
if media_type in ["films", "tv-series", "tv-episodes"]:
|
if media_type in ["films", "tv_series", "tv_episodes"]:
|
||||||
item["tmdb_id"] = item["id"]
|
item["tmdb_id"] = item["id"]
|
||||||
del item["id"]
|
del item["id"]
|
||||||
|
|
||||||
title_key = "name" if "tv-series" == media_type else "title"
|
title_key = "name" if "tv_series" == media_type else "title"
|
||||||
|
|
||||||
if f"original_{title_key}" in item and "original_language" in item:
|
if f"original_{title_key}" in item and "original_language" in item:
|
||||||
if (
|
if (
|
||||||
|
@ -550,7 +550,7 @@ def cleanup_result(item, media_type) -> dict:
|
||||||
):
|
):
|
||||||
del item[f"original_{title_key}"], item["original_language"]
|
del item[f"original_{title_key}"], item["original_language"]
|
||||||
|
|
||||||
if "tv-episodes" == media_type:
|
if "tv_episodes" == media_type:
|
||||||
item["series"] = {"tmdb_id": item["show_id"]}
|
item["series"] = {"tmdb_id": item["show_id"]}
|
||||||
del item["show_id"]
|
del item["show_id"]
|
||||||
|
|
||||||
|
@ -605,8 +605,8 @@ def main() -> None:
|
||||||
"""Prompt user to select media type and log to process"""
|
"""Prompt user to select media type and log to process"""
|
||||||
|
|
||||||
media_type = ""
|
media_type = ""
|
||||||
while media_type not in ["films", "tv-episodes", "tv-series", "books"]:
|
while media_type not in ["films", "tv_episodes", "tv_series", "books"]:
|
||||||
media_type = input("Select media type [films|tv-episodes|tv-series|books]: ")
|
media_type = input("Select media type [films|tv_episodes|tv_series|books]: ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item_id = ""
|
item_id = ""
|
||||||
|
@ -628,12 +628,12 @@ def main() -> None:
|
||||||
else:
|
else:
|
||||||
item_id = "".join(re.findall(r"\d+", input("Enter ISBN: ")))
|
item_id = "".join(re.findall(r"\d+", input("Enter ISBN: ")))
|
||||||
|
|
||||||
elif "tv-episodes" == media_type:
|
elif "tv_episodes" == media_type:
|
||||||
log = "log"
|
log = "log"
|
||||||
while re.search("(tt)?[0-9]+", item_id) is None:
|
while re.search("(tt)?[0-9]+", item_id) is None:
|
||||||
item_id = input("Enter TVDB or IMDB ID: ")
|
item_id = input("Enter TVDB or IMDB ID: ")
|
||||||
|
|
||||||
elif "tv-series" == media_type:
|
elif "tv_series" == media_type:
|
||||||
while log not in ["log", "current", "wishlist"]:
|
while log not in ["log", "current", "wishlist"]:
|
||||||
log = input("Enter log to update [log|current|wishlist]: ")
|
log = input("Enter log to update [log|current|wishlist]: ")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue