Improve reload performance by JonnyWong16 · Pull Request #1451 · pushingkarmaorg/python-plexapi

Description

Some of the default PlexPartialObject include parameters are unnecessary. The additional data is requested from the Plex server but just gets discarded or unused. For example:

  • includeExtras=1 adds extras to the metadata, but extras are fetched on-demand using the ExtrasMixin.extras() method.
  • includeRelated=1 adds related media hubs to the metadata, but the related hubs are fetched on-demand using the HubsMixin.hubs() method.

This change disables all the unused include parameters where an alternative on-demand method exists. This improves reloading (and auto-reloading) performance significantly.

Because not all the include parameters are included by default, isFullObject() now checks if the key path matches the init path as well as if the key query string is a subset of the init query string. This allows adding extra reload parameters in addition to the default parameters also a full object.

Breaking Change

The checkFiles parameter default is changed to 0 (disabled). This prevents the Plex server from scanning the files to check if they exist and are accessible which can have a significant impact on API response time. This only affects the MediaPart.exists and MediaPart.accessible attributes. A manual reload using reload(checkFiles=True) is now required to access these two attributes.

Ref.: #1449

Type of change

Please delete options that are not relevant.

  • 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