Skip to content

Conversation

@JonnyWong16
Copy link
Collaborator

Description

PlexHistory objects are unique from their base media objects. These objects are built from /status/sessions/history instead of /library/metadata/<ratingKey>.

  • New PlexHistory.source() to return the source media object for the history object.
  • New PlexHistory.delete() to delete the history entry from the server.

Examples

>> history = plex.history()
>> historyObj = history[0]  # New `MovieHistory` object
>> historyObj 
<MovieHistory:1039:Big-Buck-Bunny>
>> historyObj.reload()  # Cannot reload a history object
NotImplementedError: History objects cannot be reloaded. Use source() to get the source media item.
>> historyObj.source()  # Returns the source `Movie` object.
<Movie:1039:Big-Buck-Bunny>

All existing methods should work with the new history objects, however, there may be some unknown behaviour since the object attributes may be different. It is recommended to work on the source media object to be safe.

>> history = plex.history()
>> historyObj = history[0]  # New `MovieHistory` object
>> historyObj
<EpisodeHistory:765:Game-of-Thrones-s01e01>
>> historyObj.show()  # Still able to call existing methods on history objects.
<Show:763:Game-of-Thrones>
>> historyObj.editTitle('New Title')  # Not recommended to work on the history object.
>> episode = historyObj.source()  # Get the source `Episode` object.
>> episode.editTitle('New Title')  # Recommended to work on the source media object.

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

@JonnyWong16 JonnyWong16 force-pushed the feature/history_object branch from 2de9a5c to bde1a33 Compare July 13, 2023 07:05
@JonnyWong16 JonnyWong16 changed the title Create separate PlexHistory objects Create separate PlexHistory objects Jul 27, 2023
@JonnyWong16 JonnyWong16 merged commit 58e279b into pushingkarmaorg:master Jul 28, 2023
@JonnyWong16 JonnyWong16 deleted the feature/history_object branch July 28, 2023 00:45
""" Reload the data for the history entry. """
raise NotImplementedError('History objects cannot be reloaded. Use source() to get the source media item.')

def source(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

this is an unfortunate method name, causing conflict:

what inspired this method name? maybe rename to origin or item or original?

Copy link
Contributor

Choose a reason for hiding this comment

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

@JonnyWong16: do you have answer? may give some ideas what other name to use here instead:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants