Data parity for seasons and episodes#1593
Open
Touchstone64 wants to merge 9 commits intopushingkarmaorg:masterfrom
Open
Data parity for seasons and episodes#1593Touchstone64 wants to merge 9 commits intopushingkarmaorg:masterfrom
Touchstone64 wants to merge 9 commits intopushingkarmaorg:masterfrom
Conversation
…chSeasons() and searchEpisodes() methods and Show.seasons() and Season.episodes() methods
Contributor
Author
|
I'm out of depth trying to solve the failing CI step as I'm unfamiliar with Github actions, but I'll do some research and see if I can offer any solutions. |
Collaborator
|
The test failure is just a caching issue. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a TV parent/child relation key builder to align GUID inclusion across show/season/episode “member” retrieval methods with library search behavior (per #1592).
Changes:
- Introduces
TvParentChildMixin._buildRelationKey()to append relation query params (includingincludeGuidsby default). - Updates
Show,Season, andEpisoderetrieval methods to use_buildRelationKey()when fetching related objects. - Adds/updates tests to assert GUID presence on related objects without relying on auto-reload behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
plexapi/video.py |
Switches show/season/episode relation fetches to use _buildRelationKey() so returned partials include GUIDs. |
plexapi/mixins/tv_parent_child.py |
Adds the new key-building helper for TV parent/child relations. |
plexapi/mixins/__init__.py |
Wires the new mixin into ShowMixins, SeasonMixins, and EpisodeMixins. |
tests/test_video.py |
Adds assertions/tests to validate GUID availability for related TV objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| def episodes(self, **kwargs): | ||
| """ Returns a list of :class:`~plexapi.video.Episode` objects in the season. """ | ||
| key = f'{self.key}/children' | ||
| key = self._buildRelationKey(f'{self.key}/children') |
Comment on lines
+7
to
+17
| def _buildRelationKey(self, key, **kwargs): | ||
| """ Returns a key suitable for fetching parent/child TV items """ | ||
| args = {} | ||
|
|
||
| args['includeGuids'] = int(bool(kwargs.pop('includeGuids', True))) | ||
| for name, value in list(kwargs.items()): | ||
| args[name] = value | ||
|
|
||
| params = utils.joinArgs(args).lstrip('?') | ||
|
|
||
| return f"{key}?{params}" |
| season_by_name = show.season("Season 1") | ||
| assert show.ratingKey == season.parentRatingKey and season_by_name.parentRatingKey | ||
| assert season.ratingKey == season_by_name.ratingKey | ||
| assert season.guids |
Comment on lines
+1351
to
+1354
| show = episode.show() | ||
| assert show | ||
| assert show.isPartialObject() | ||
| assert show.guids |
| def seasons(self, **kwargs): | ||
| """ Returns a list of :class:`~plexapi.video.Season` objects in the show. """ | ||
| key = f'{self.key}/children?excludeAllLeaves=1' | ||
| key = self._buildRelationKey(f'{self.key}/children', excludeAllLeaves=1) |
| def episodes(self, **kwargs): | ||
| """ Returns a list of :class:`~plexapi.video.Episode` objects in the show. """ | ||
| key = f'{self.key}/allLeaves' | ||
| key = self._buildRelationKey(f'{self.key}/allLeaves') |
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.
Description
This PR includes a mixin supporting a key builder suitable for all TV parent/child searches, including guids unless specifically instructed otherwise, and implements it for all object-retrieving methods as described in #1592.
Fixes #1592
Type of change
Please delete options that are not relevant.
Checklist:
In all honesty I've had great difficulty setting up an 'all-tests-pass' test harness with tools/plex-bootstraptest.py, but I have been able to use it to create an environment that could run the new unit tests individually. The new tests all fail when the mixin's
_buildRelationKey()includeGuids code is commented out, and pass when it's reinstated, so I'm happy that the changes are effective and the unit tests are of value.Please feel free to make or suggest any changes that would help pull this PR into line with the spirit of this repo.