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

Conversation

FlashLightning67
Copy link
Contributor

@FlashLightning67 FlashLightning67 commented Nov 5, 2024

Ensures that all episodes are found from symlink titles when ingesting symlinks into the db. Fixes an issue with symlink ingestion where files containing multiple episodes would only have one of the episodes added to the db, which causes the missing episodes to be submitted for scraping again after every db reset.

Summary by CodeRabbit

  • New Features

    • Enhanced episode processing to handle multiple episodes from filenames.
    • Improved error handling for missing episode information with automatic file deletion.
  • Bug Fixes

    • Refined logic for extracting episode numbers, leading to more reliable indexing.
  • Chores

    • Minor adjustments to logging statements for consistency.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The pull request introduces substantial modifications to the process_shows function within the SymlinkLibrary class in src/program/services/libraries/symlink.py. The updates replace the previous episode number extraction logic with a new approach utilizing the parse_title function, allowing for better handling of multiple episodes. The function now creates Episode instances for each number in the list obtained from parse_title, enhances error handling by deleting problematic files, and adjusts logging statements to align with the new logic.

Changes

File Path Change Summary
src/program/services/libraries/symlink.py Enhanced process_shows function to utilize parse_title for episode extraction; improved error handling by deleting problematic files; adjusted logging statements.

Poem

In the burrow where shows align,
A rabbit hops through episode time.
With ranges now, we dance and play,
Extracting tales in a joyful way.
Errors vanish, files take flight,
A symphony of shows, oh what a sight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
src/program/services/libraries/symlink.py (2)

176-181: Simplify symlinked and update_folder assignments

The symlinked attribute is set to True in both branches of the condition, and update_folder is assigned in both branches with only the value differing. Simplify the code by consolidating these assignments to reduce redundancy and enhance readability.

Apply this diff to streamline the code:

     episode_item.set("symlinked", True)
-    if settings_manager.settings.force_refresh:
-        episode_item.set("update_folder", str(Path(directory) / show / season / episode))
-    else:
-        episode_item.set("update_folder", "updated")
+    update_folder_value = (
+        str(Path(directory) / show / season / episode)
+        if settings_manager.settings.force_refresh
+        else "updated"
+    )
+    episode_item.set("update_folder", update_folder_value)

183-184: Ensure is_anime attribute is correctly set on episode_item

The is_anime attribute is being set within the loop for episodes. Confirm that this attribute is meant to be set on each episode_item. If show_item.is_anime is already set, this assignment might be redundant.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 91d3f7d and c735805.

📒 Files selected for processing (1)
  • src/program/services/libraries/symlink.py (1 hunks)

src/program/services/libraries/symlink.py Outdated Show resolved Hide resolved
src/program/services/libraries/symlink.py Outdated Show resolved Hide resolved
src/program/services/libraries/symlink.py Outdated Show resolved Hide resolved
@dreulavelle
Copy link
Member

dreulavelle commented Nov 5, 2024

Have you tested this? We also need to verify that the downloaders are downloading episodes appropriately too. e.g. setting the same file for both episode items.

@dreulavelle dreulavelle changed the title fix detecting multiple episodes in symlink library fix: detecting multiple episodes in symlink library Nov 5, 2024
@FlashLightning67
Copy link
Contributor Author

I have tested it, I've been manually loading these changes up every time I've had to reset my db for the past few months lol.

The symlinker seems handles these types of files well. The downloaders (at least RD) also handle them fine now too, the last refactor broke them but the refactor from today doesn't have that issue.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
src/program/services/libraries/symlink.py (1)

163-182: Add logging for multiple episode detection

Since this PR specifically addresses the detection of multiple episodes, it would be helpful to log when multiple episodes are successfully detected from a single file.

Add logging before the episode processing loop:

 episode_numbers: list[int] = parse_title(episode).get("episodes", [])
+if len(episode_numbers) > 1:
+    logger.info(f"Detected multiple episodes {episode_numbers} in file {episode}")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c735805 and ccecf74.

📒 Files selected for processing (1)
  • src/program/services/libraries/symlink.py (2 hunks)
🔇 Additional comments (1)
src/program/services/libraries/symlink.py (1)

10-10: LGTM! Good choice using PTT for title parsing.

The addition of PTT for title parsing aligns with the recommended approach and provides a more robust solution for episode detection.

src/program/services/libraries/symlink.py Show resolved Hide resolved
src/program/services/libraries/symlink.py Show resolved Hide resolved
Copy link
Member

@dreulavelle dreulavelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now!

@dreulavelle dreulavelle merged commit ebd11fd into rivenmedia:main Nov 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants