Skip to content

Commit

Permalink
improved error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
Barakudum committed Feb 9, 2024
1 parent 36af62b commit 312b378
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/jarklin/cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ def generate_info_file():
source = generator.source
dest = generator.dest
logging.debug(f"Cache: adding {generator}")
if is_deprecated(source=source, dest=dest) or is_incomplete(dest=dest):
logging.info(f"Cache: generating {generator}")
try:
generator.generate()
except Exception as error:
logging.error(f"Cache: generation failed ({generator})", exc_info=error)
continue
generate_info_file()
try:
if is_deprecated(source=source, dest=dest) or is_incomplete(dest=dest):
logging.info(f"Cache: generating {generator}")
try:
generator.generate()
except Exception as error:
logging.error(f"Cache: generation failed ({generator})", exc_info=error)
continue
generate_info_file()
info.append(InfoEntry(
path=str(source.relative_to(self.root)),
name=source.stem,
Expand All @@ -125,7 +125,8 @@ def generate_info_file():
modification_time=get_modification_time(source),
meta=json.loads(dest.joinpath("meta.json").read_bytes()),
))
except FileNotFoundError:
except FileNotFoundError as error:
logging.error(f"Cache: {generator} failed", exc_info=error)
continue

generate_info_file()
Expand Down
6 changes: 3 additions & 3 deletions src/jarklin/cache/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ def meta(self) -> VideoMeta:
) for stream in self.video_streams],
audio_streams=[AudioStreamMeta(
is_default=bool(stream['disposition']['default']),
language=stream['tags'].get('language', "<unknown>"),
language=stream.get('tags', {}).get('language', "<unknown>"),
) for stream in self.audio_streams],
subtitles=[SubtitleStreamMeta(
is_default=bool(stream['disposition']['default']),
language=stream['tags'].get('language', "<unknown>"),
language=stream.get('tags', {}).get('language', "<unknown>"),
) for stream in self.subtitle_streams],
chapters=[ChapterMeta(
id=chapter['id'],
# start=chapter['start'],
start_time=float(chapter['start_time']),
# end=chapter['end'],
end_time=float(chapter['end_time']),
title=chapter['tags']['title'],
title=chapter.get('tags', {})['title'],
) for chapter in self.chapters],
)

Expand Down

0 comments on commit 312b378

Please sign in to comment.