-
Notifications
You must be signed in to change notification settings - Fork 200
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
Make Plex XML "include" parameters configurable #603
Comments
This behavior is intentional. Accessing a attribute that isn’t included should trigger a reload with the most possible info. There are ways to avoid doing heavy reloads.
|
It can still be the default behaviour, but having the includes as customizable parameters is more user friendly. I am just using
|
#590 moved the child _include into the parent video class. We could use this single reference to break out params into the known kwargs for reload(). _include is only used to populate _details_keys, so why don't we move these params to reload() def reload(self, **kwargs):
""" Reload the data for this object from self.key. """
_additionalParams = ('checkFiles', 'includeAllConcerts', 'includeBandwidths', 'includeChapters',
'includeChildren', 'includeConcerts', 'includeExtras', 'includeFields',
'includeGeolocation', 'includeLoudnessRamps', 'includeMarkers', 'includeOnDeck',
'includePopularLeaves', 'includePreferences', 'includeRelated', 'includeRelatedCount',
'includeReviews', 'includeStations')
_allParams = {k: 1 for k in _additionalParams}
if kwargs:
for param, value in kwargs.items():
if param not in _additionalParams:
raise NotFound
elif value not in [0, False]:
raise NotFound
else:
_allParams.pop(param)
key = '?%s' % urlencode(_allParams)
.... |
I don't think we should have all the includes in Here is my first pass at customizing includes: JonnyWong16@c171aa2. >>> movie = plex.fetchItem(1)
>>> movie._details_key # This may be a breaking change since the details key used to be populated by default
''
>>> movie.reload(checkFiles=False) # Disable an include parameter
<Movie:1:Bridge.of.Spies.2015>
>>> movie._details_key
'/library/metadata/1?includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeFields=thumbBlurHash&includeFields=artBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1'
>>> movie.reload() # Default include all parameters
<Movie:1:Bridge.of.Spies.2015>
>>> movie._details_key
'/library/metadata/1?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeFields=thumbBlurHash&includeFields=artBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1'
>>> movie.reload(includeFields=True) # Override the include parameter
<Movie:1:Bridge.of.Spies.2015>
>>> movie._details_key
'/library/metadata/1?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1'
>>> movie = plex.fetchItem(1)
>>> movie.isPartialObject()
True
>>> movie.chapters # Auto-reload when accessing an attribute that is missing
[]
>>> movie.isPartialObject()
False
>>> movie._details_key
'/library/metadata/1?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeFields=thumbBlurHash&includeFields=artBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1' |
The same can be done today by using str.replace on the details key. I actually thought about that when I did the changes. I think your approach is better. Open a PR. We also need to change the way we check if the object is full. |
Do we need to change how we check if it is a full object? The object has been loaded from the API path (details key). Unless you want "full" to mean it has all the include parameters. |
Full should be all params yes. It will only reload on missing attributes anyway. |
Describe the issue
The
_include
parameters when retrieving XML data from Plex should be configurable. It would allow the user to save resources and speed up the response by only retrieving the XML tags/fields that they need.Example hardcoded
_include
parameters for~plexapi.video.Movie
:python-plexapi/plexapi/video.py
Lines 289 to 291 in 163d94d
This is especially useful for the
checkFiles=1
parameter since this causes the Plex server to hit the storage to check if a file exists (~plexapi.media.MediaPart.exists
) and is accessible (~plexapi.media.MediaPart.accessible
) which may timeout if cloud storage is being used for the Plex server.Code snipppets
Example of an unnecessary "heavy" reload.
Expected behavior
Example of a possible "lighter" reload.
Additional context
Some other XML includes that are available but not shown when viewing the XML through Plex.
includeFields=thumbBlurHash
adds thethumbBlurHash
field to the XML (used by Plexamp)includeFields=artBlurHash
adds theartBlurHash
field to the XML (used by Plexamp)Reference: BlurHash.
The text was updated successfully, but these errors were encountered: