Skip to content

Commit 0b78f45

Browse files
Fix service.find
Catch failed service connection
1 parent db457a7 commit 0b78f45

2 files changed

Lines changed: 35 additions & 25 deletions

File tree

mediux_posters/__main__.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,20 @@ def media_posters(
463463
continue
464464

465465
tmdb_id = int(url.split("/")[-1])
466-
with CONSOLE.status(f"Searching {type(service).__name__} for TMDB id: '{tmdb_id}'"):
467-
entry = service.get(media_type=media_type, tmdb_id=tmdb_id)
468-
if not entry:
469-
LOGGER.warning(
470-
"[%s] Unable to find a %s with a Tmdb Id of '%d'",
471-
type(service).__name__,
472-
media_type.value.capitalize(),
473-
tmdb_id,
474-
)
475-
continue
466+
try:
467+
with CONSOLE.status(f"Searching {type(service).__name__} for TMDB id: '{tmdb_id}'"):
468+
entry = service.get(media_type=media_type, tmdb_id=tmdb_id)
469+
if not entry:
470+
LOGGER.warning(
471+
"[%s] Unable to find a %s with a Tmdb Id of '%d'",
472+
type(service).__name__,
473+
media_type.value.capitalize(),
474+
tmdb_id,
475+
)
476+
continue
477+
except ServiceError as err:
478+
LOGGER.warning("[%s] %s", type(service).__name__, err)
479+
break
476480
CONSOLE.rule(
477481
f"[{index + 1}/{len(url_list)}] {entry.display_name} [tmdb-{entry.tmdb_id}]",
478482
align="left",
@@ -615,18 +619,21 @@ def set_posters(
615619
align="left",
616620
style="subtitle",
617621
)
618-
619-
with CONSOLE.status(
620-
f"Searching {type(service).__name__} for '{set_data.set_title} [{tmdb_id}]'"
621-
):
622-
entry = service.find(tmdb_id=tmdb_id)
623-
if not entry:
624-
LOGGER.warning(
625-
"[%s] Unable to find any media with a Tmdb Id of '%d'",
626-
type(service).__name__,
627-
tmdb_id,
628-
)
629-
continue
622+
try:
623+
with CONSOLE.status(
624+
f"Searching {type(service).__name__} for '{set_data.set_title} [{tmdb_id}]'"
625+
):
626+
entry = service.get(media_type=media_type, tmdb_id=tmdb_id)
627+
if not entry:
628+
LOGGER.warning(
629+
"[%s] Unable to find any media with a Tmdb Id of '%d'",
630+
type(service).__name__,
631+
tmdb_id,
632+
)
633+
continue
634+
except ServiceError as err:
635+
LOGGER.warning("[%s] %s", type(service).__name__, err)
636+
break
630637
if simple_clean:
631638
LOGGER.info("Cleaning %s cache", entry.display_name)
632639
delete_folder(folder=get_cached_image(slugify(value=entry.display_name)))

uv.lock

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)