Fix/custom search templates not saved#12155
Closed
Mika3578 wants to merge 8 commits intopymedusa:developfrom
Closed
Fix/custom search templates not saved#12155Mika3578 wants to merge 8 commits intopymedusa:developfrom
Mika3578 wants to merge 8 commits intopymedusa:developfrom
Conversation
…ting default templates against scene exceptions. Update search string handling to strip year from titles for custom templates.
- Test that custom templates (default=0) are preserved even when titles don't match scene exceptions - Test that default templates (default=1) are removed when scene exceptions are removed - Test that default templates with show name are always preserved - Test isolation between multiple shows Co-authored-by: Mika3578 <[email protected]>
- Extract common mock creation logic into _create_mock_functions helper - Remove unused monkeypatch_function_return fixture parameter - All tests still passing Co-authored-by: Mika3578 <[email protected]>
Co-authored-by: Mika3578 <[email protected]>
Co-authored-by: Mika3578 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This pull request fixes two issues with custom search templates: (1) custom templates were being incorrectly deleted or filtered out, and (2) year suffixes from show titles were being included in search queries for custom templates when they shouldn't be.
Changes:
- Modified
SearchTemplates._clean()to only remove default templates when their scene exceptions are removed, preserving all custom templates - Modified
SearchTemplates.update()to skip scene exception validation for custom templates, ensuring they're always saved - Modified episode and season search string generation in
GenericProviderto strip year suffixes from titles in custom templates while preserving them in default templates
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| medusa/search_templates.py | Added AND \default` = 1` clause to _clean() to preserve custom templates; modified update() to skip scene exception validation for custom templates |
| medusa/providers/generic_provider.py | Added import of get_title_without_year helper; modified episode and season search string generation to conditionally strip year from custom template titles |
| tests/test_search_templates.py | Added comprehensive tests for template cleanup behavior with default and custom templates |
| tests/providers/test_generic_provider.py | Added parameterized tests for episode and season search string generation with various template configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Mika3578 <[email protected]>
Co-authored-by: Mika3578 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves how search strings are generated for TV series episodes and seasons, especially when using custom search templates. The main change is that custom templates now strip the year from the series title in search queries, while default templates preserve it. The update also ensures that only default templates are cleaned up when scene exceptions are removed, and only default templates are validated against scene exceptions in the database. Comprehensive tests have been added to verify these behaviors.
Template handling improvements:
Custom search templates now strip the year from the series title when generating search strings for episodes and seasons, while default templates retain the year. This is achieved by introducing the
get_title_without_yearhelper and updating the logic inGenericProvider._get_episode_search_stringsandGenericProvider._get_season_search_strings. [1] [2] [3]The cleanup logic in
SearchTemplates._cleanis updated to only remove default templates when their associated scene exception is no longer present, preserving custom templates.The update logic in
SearchTemplates.updatenow always saves custom templates and only validates default templates against the database for the existence of a scene exception.Testing enhancements:
tests/providers/test_generic_provider.pyto verify episode and season search string generation with various combinations of default and custom templates, filtering by season, and template enable/disable states.Fix custom search templates not saved and year in search queriesCustom search templates not saved (fixes Custom search templates not saved #11024, Cutome search template not saving #11038)
Cause: Custom templates were filtered out by the scene exception check in update() and could be removed by _clean().
Changes in medusa/search_templates.py:
update(): Skip the scene exception check for custom templates (default=0). Only default templates are validated against scene_exceptions.
_clean(): Add AND \default\ = 1 so only default templates are deleted. Custom templates are left untouched.
Year in search queries (Append year to show title)
Cause: With "Append (year) to each show title" enabled, custom templates could get a title like "Show Name (2024)" from the UI. That value was used in provider search strings, but the year should only be used for folder creation and UI, not for search.
Changes in medusa/providers/generic_provider.py:
For custom search templates, use get_title_without_year() when building search strings.
Default templates still use the original title; their titles already come from series.name without a year.
Applied for both episode and season search templates.