1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-27 10:07:22 +00:00

Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
morpheus65535 2022-05-04 06:35:49 -04:00
commit 6e7423c9b5
2 changed files with 11 additions and 9 deletions

View file

@ -20,27 +20,29 @@ logger = logging.getLogger(__name__)
def _get_matching_sub(sub_names, forced=False, episode=None): def _get_matching_sub(sub_names, forced=False, episode=None):
matching_sub = None matching_sub = None
for sub_name in sub_names:
guess = guessit(sub_name, options={"single_value": True})
is_movie = not guess.get("episode") or not episode
guess_options = {"single_value": True}
if episode is not None:
guess_options["type"] = "episode" # type: ignore
for sub_name in sub_names:
if not forced and os.path.splitext(sub_name.lower())[0].endswith("forced"): if not forced and os.path.splitext(sub_name.lower())[0].endswith("forced"):
logger.debug("Ignoring forced subtitle: %s", sub_name) logger.debug("Ignoring forced subtitle: %s", sub_name)
continue continue
# If it's a movie then get the first subtitle # If it's a movie then get the first subtitle
if is_movie: if episode is None:
logger.debug("Movie subtitle found: %s", sub_name) logger.debug("Movie subtitle found: %s", sub_name)
matching_sub = sub_name matching_sub = sub_name
break break
# Get episode info guess = guessit(sub_name, options=guess_options)
guess_episode = guess.get("episode")
if guess_episode is None: if guess.get("episode") is None:
logger.debug("No episode info found in file: %s", sub_name) logger.debug("No episode info found in file: %s", sub_name)
continue continue
if episode == guess_episode: if episode == guess["episode"]:
logger.debug("Episode matched: %s", sub_name) logger.debug("Episode matched: %s", sub_name)
matching_sub = sub_name matching_sub = sub_name
break break

View file

@ -19,7 +19,7 @@ from rarfile import RarFile
1, 1,
"breaking.bad.s01e01.srt", "breaking.bad.s01e01.srt",
), ),
(("dummy.forced.srt",), True, 1, "dummy.forced.srt"), (("dummy.forced.srt",), True, None, "dummy.forced.srt"),
(("dummy.forced.srt",), False, 1, None), (("dummy.forced.srt",), False, 1, None),
], ],
) )