mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-05-19 05:50:38 -04:00
Fix regex for importing episodes (#128)
This pull request makes a small but significant change to the `import_torrent_files` method in `media_manager/movies/service.py`. The change updates the regular expression used to match subtitle file names, making it more flexible in recognizing language codes. * [`media_manager/movies/service.py`](diffhunk://#diff-57cfa309860beba31573487107eba3f7ef8ef60429c48c02fb262b9f4ff9b8d3L527-R527): Updated the regular expression in `import_torrent_files` to match language codes in subtitle file names that are separated by either a dot (`.`) or a space (` `), instead of only a dot. It fixes #124. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2bcec538a3
commit
89f4a76825
@@ -524,7 +524,7 @@ class MovieService:
|
||||
# import subtitles
|
||||
for subtitle_file in subtitle_files:
|
||||
language_code_match = re.search(
|
||||
r"\.([a-z]{2})\.srt$", subtitle_file.name, re.IGNORECASE
|
||||
r"[. ]([a-z]{2})\.srt$", subtitle_file.name, re.IGNORECASE
|
||||
)
|
||||
if not language_code_match:
|
||||
log.warning(
|
||||
|
||||
@@ -164,8 +164,8 @@ def remove_special_characters(filename: str) -> str:
|
||||
"""
|
||||
# Remove invalid characters
|
||||
sanitized = re.sub(r"([<>:\"/\\|?*])", "", filename)
|
||||
|
||||
|
||||
# Remove leading and trailing dots or spaces
|
||||
sanitized = sanitized.strip(" .")
|
||||
|
||||
|
||||
return sanitized
|
||||
|
||||
@@ -553,13 +553,13 @@ class TvService:
|
||||
if season_file.file_path_suffix != "":
|
||||
episode_file_name += f" - {season_file.file_path_suffix}"
|
||||
pattern = (
|
||||
r".*[.]S0?"
|
||||
r".*[. ]S0?"
|
||||
+ str(season.number)
|
||||
+ r"E0?"
|
||||
+ str(episode.number)
|
||||
+ r"[.].*"
|
||||
+ r"[. ].*"
|
||||
)
|
||||
subtitle_pattern = pattern + r"[.]([A-Za-z]{2})[.]srt"
|
||||
subtitle_pattern = pattern + r"[. ]([A-Za-z]{2})[. ]srt"
|
||||
target_file_name = season_path / episode_file_name
|
||||
|
||||
# import subtitles
|
||||
|
||||
Reference in New Issue
Block a user