Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detecting multiple episodes in symlink library #862

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/program/services/libraries/symlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,29 @@ def process_shows(directory: Path, item_type: str, is_anime: bool = False) -> Ge
for episode in os.listdir(directory / show / season):
if os.path.splitext(episode)[1][1:] not in ALLOWED_VIDEO_EXTENSIONS:
continue
if not (episode_number := re.search(r"s\d+e(\d+)", episode, re.IGNORECASE)):
episode_numbers = re.findall(r"s\d+e(\d+)(?:-e(\d+))?", episode, re.IGNORECASE)
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
if not episode_numbers:
logger.log("NOT_FOUND", f"Can't extract episode number at path {directory / show / season / episode}")
# Delete the episode since it can't be indexed
os.remove(directory / show / season / episode)
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
continue
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved

episode_item = Episode({"number": int(episode_number.group(1))})
resolve_symlink_and_set_attrs(episode_item, Path(directory) / show / season / episode)
find_subtitles(episode_item, Path(directory) / show / season / episode)
if settings_manager.settings.force_refresh:
episode_item.set("symlinked", True)
episode_item.set("update_folder", str(Path(directory) / show / season / episode))
else:
episode_item.set("symlinked", True)
episode_item.set("update_folder", "updated")
if is_anime:
episode_item.is_anime = True
episodes[int(episode_number.group(1))] = episode_item
for ep_range in episode_numbers:
start_ep = int(ep_range[0])
end_ep = int(ep_range[1]) if ep_range[1] else start_ep
for episode_number in range(start_ep, end_ep + 1):
episode_item = Episode({"number": episode_number})
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
resolve_symlink_and_set_attrs(episode_item, Path(directory) / show / season / episode)
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
find_subtitles(episode_item, Path(directory) / show / season / episode)
if settings_manager.settings.force_refresh:
episode_item.set("symlinked", True)
episode_item.set("update_folder", str(Path(directory) / show / season / episode))
else:
episode_item.set("symlinked", True)
episode_item.set("update_folder", "updated")
if is_anime:
episode_item.is_anime = True
episodes[episode_number] = episode_item
if len(episodes) > 0:
for i in range(1, max(episodes.keys())+1):
season_item.add_episode(episodes.get(i, Episode({"number": i})))
Expand Down