Remove unused combine_watched_dicts
Signed-off-by: Luis Garcia <git@luigi311.com>
This commit is contained in:
@@ -17,9 +17,6 @@ from src.library import (
|
||||
check_skip_logic,
|
||||
generate_library_guids_dict,
|
||||
)
|
||||
from src.watched import (
|
||||
combine_watched_dicts,
|
||||
)
|
||||
|
||||
load_dotenv(override=True)
|
||||
|
||||
|
||||
@@ -5,33 +5,6 @@ from src.functions import logger, search_mapping, contains_nested
|
||||
from src.library import generate_library_guids_dict
|
||||
|
||||
|
||||
def combine_watched_dicts(dicts: list):
|
||||
# Ensure that the input is a list of dictionaries
|
||||
if not all(isinstance(d, dict) for d in dicts):
|
||||
raise ValueError("Input must be a list of dictionaries")
|
||||
|
||||
combined_dict = {}
|
||||
|
||||
for single_dict in dicts:
|
||||
for key, value in single_dict.items():
|
||||
if key not in combined_dict:
|
||||
combined_dict[key] = {}
|
||||
|
||||
for subkey, subvalue in value.items():
|
||||
if subkey in combined_dict[key]:
|
||||
# If the subkey already exists in the combined dictionary,
|
||||
# check if the values are different and raise an exception if they are
|
||||
if combined_dict[key][subkey] != subvalue:
|
||||
raise ValueError(
|
||||
f"Conflicting values for subkey '{subkey}' under key '{key}'"
|
||||
)
|
||||
else:
|
||||
# If the subkey does not exist in the combined dictionary, add it
|
||||
combined_dict[key][subkey] = subvalue
|
||||
|
||||
return combined_dict
|
||||
|
||||
|
||||
def check_remove_entry(video, library, video_index, library_watched_list_2):
|
||||
if video_index is not None:
|
||||
if (
|
||||
|
||||
@@ -13,7 +13,7 @@ parent = os.path.dirname(current)
|
||||
# the sys.path.
|
||||
sys.path.append(parent)
|
||||
|
||||
from src.watched import cleanup_watched, combine_watched_dicts
|
||||
from src.watched import cleanup_watched
|
||||
|
||||
tv_shows_watched_list_1 = {
|
||||
frozenset(
|
||||
@@ -541,116 +541,3 @@ def test_mapping_cleanup_watched():
|
||||
|
||||
assert return_watched_list_1 == expected_watched_list_1
|
||||
assert return_watched_list_2 == expected_watched_list_2
|
||||
|
||||
|
||||
def test_combine_watched_dicts():
|
||||
input_watched = [
|
||||
{
|
||||
"test3": {
|
||||
"Anime Movies": [
|
||||
{
|
||||
"title": "Ponyo",
|
||||
"tmdb": "12429",
|
||||
"imdb": "tt0876563",
|
||||
"locations": ("Ponyo (2008) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
{
|
||||
"title": "Spirited Away",
|
||||
"tmdb": "129",
|
||||
"imdb": "tt0245429",
|
||||
"locations": ("Spirited Away (2001) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
{
|
||||
"title": "Castle in the Sky",
|
||||
"tmdb": "10515",
|
||||
"imdb": "tt0092067",
|
||||
"locations": ("Castle in the Sky (1986) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
{"test3": {"Anime Shows": {}}},
|
||||
{"test3": {"Cartoon Shows": {}}},
|
||||
{
|
||||
"test3": {
|
||||
"Shows": {
|
||||
frozenset(
|
||||
{
|
||||
("tmdb", "64464"),
|
||||
("tvdb", "301824"),
|
||||
("tvrage", "45210"),
|
||||
("title", "11.22.63"),
|
||||
("locations", ("11.22.63",)),
|
||||
("imdb", "tt2879552"),
|
||||
}
|
||||
): [
|
||||
{
|
||||
"imdb": "tt4460418",
|
||||
"title": "The Rabbit Hole",
|
||||
"locations": (
|
||||
"11.22.63 S01E01 The Rabbit Hole Bluray-1080p.mkv",
|
||||
),
|
||||
"status": {"completed": True, "time": 0},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{"test3": {"Subbed Anime": {}}},
|
||||
]
|
||||
expected = {
|
||||
"test3": {
|
||||
"Anime Movies": [
|
||||
{
|
||||
"title": "Ponyo",
|
||||
"tmdb": "12429",
|
||||
"imdb": "tt0876563",
|
||||
"locations": ("Ponyo (2008) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
{
|
||||
"title": "Spirited Away",
|
||||
"tmdb": "129",
|
||||
"imdb": "tt0245429",
|
||||
"locations": ("Spirited Away (2001) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
{
|
||||
"title": "Castle in the Sky",
|
||||
"tmdb": "10515",
|
||||
"imdb": "tt0092067",
|
||||
"locations": ("Castle in the Sky (1986) Bluray-1080p.mkv",),
|
||||
"status": {"completed": True, "time": 0},
|
||||
},
|
||||
],
|
||||
"Anime Shows": {},
|
||||
"Cartoon Shows": {},
|
||||
"Shows": {
|
||||
frozenset(
|
||||
{
|
||||
("tmdb", "64464"),
|
||||
("tvdb", "301824"),
|
||||
("tvrage", "45210"),
|
||||
("title", "11.22.63"),
|
||||
("locations", ("11.22.63",)),
|
||||
("imdb", "tt2879552"),
|
||||
}
|
||||
): [
|
||||
{
|
||||
"imdb": "tt4460418",
|
||||
"title": "The Rabbit Hole",
|
||||
"locations": (
|
||||
"11.22.63 S01E01 The Rabbit Hole Bluray-1080p.mkv",
|
||||
),
|
||||
"status": {"completed": True, "time": 0},
|
||||
}
|
||||
]
|
||||
},
|
||||
"Subbed Anime": {},
|
||||
}
|
||||
}
|
||||
|
||||
assert combine_watched_dicts(input_watched) == expected
|
||||
|
||||
Reference in New Issue
Block a user