@@ -676,7 +676,7 @@ def history(self, maxresults=None, mindate=None, ratingKey=None, accountID=None,
676676 args ['viewedAt>' ] = int (mindate .timestamp ())
677677
678678 key = f'/status/sessions/history/all{ utils .joinArgs (args )} '
679- return self .fetchItems (key , maxresults = maxresults )
679+ return self .fetchItems (key , maxresults = maxresults , cls = History )
680680
681681 def playlists (self , playlistType = None , sectionId = None , title = None , sort = None , ** kwargs ):
682682 """ Returns a list of all :class:`~plexapi.playlist.Playlist` objects on the server.
@@ -1305,3 +1305,36 @@ def _loadData(self, data):
13051305 self .claimed = utils .cast (bool , data .attrib .get ('claimed' ))
13061306 self .machineIdentifier = data .attrib .get ('machineIdentifier' )
13071307 self .version = data .attrib .get ('version' )
1308+
1309+
1310+ class History (PlexObject ):
1311+ """ Represents a single history data point."""
1312+
1313+ def _loadData (self , data ):
1314+ self ._data = data
1315+ self .historyKey = data .attrib .get ('historyKey' )
1316+ self .key = data .attrib .get ('key' )
1317+ self .parentKey = data .attrib .get ('parentKey' )
1318+ self .ratingKey = data .attrib .get ('ratingKey' )
1319+ self .librarySectionID = data .attrib .get ('librarySectionID' )
1320+ self .grandparentKey = data .attrib .get ('grandparentKey' )
1321+ self .grandparentTitle = data .attrib .get ('grandparentTitle' )
1322+ self .title = data .attrib .get ('title' )
1323+ self .type = data .attrib .get ('type' )
1324+ self .thumb = data .attrib .get ('thumb' )
1325+ self .parentThumb = data .attrib .get ('parentThumb' )
1326+ self .grandparentThumb = data .attrib .get ('grandparentThumb' )
1327+ self .grandparentArt = data .attrib .get ('grandparentArt' )
1328+ self .index = data .attrib .get ('index' )
1329+ self .parentIndex = data .attrib .get ('parentIndex' )
1330+ self .viewedAt = utils .toDatetime (data .attrib .get ('viewedAt' ))
1331+ self .accountID = utils .cast (int , data .attrib .get ('accountID' ))
1332+ self .deviceID = utils .cast (int , data .attrib .get ('deviceID' ))
1333+
1334+ def __repr__ (self ):
1335+ return f"<{ self .__class__ .__name__ } :{ self .accountID } :{ self .viewedAt } >"
1336+
1337+ def delete (self ):
1338+ """ Delete history data point from Server. """
1339+ return self ._server .query (key = self .historyKey , method = self ._server ._session .delete )
1340+
0 commit comments