Skip to content

Data parity for seasons and episodes#1593

Open
Touchstone64 wants to merge 9 commits intopushingkarmaorg:masterfrom
Touchstone64:data-parity-for-seasons-and-episodes
Open

Data parity for seasons and episodes#1593
Touchstone64 wants to merge 9 commits intopushingkarmaorg:masterfrom
Touchstone64:data-parity-for-seasons-and-episodes

Conversation

@Touchstone64
Copy link
Contributor

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

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.

@Touchstone64
Copy link
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.

@JonnyWong16
Copy link
Collaborator

The test failure is just a caching issue.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (including includeGuids by default).
  • Updates Show, Season, and Episode retrieval 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')
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.

Ensure data parity for shows, seasons and episodes retrieved by search methods and member methods

3 participants