@@ -600,13 +600,17 @@ def claimToken(self):
600600 raise BadRequest ('(%s) %s %s; %s' % (response .status_code , codename , response .url , errtext ))
601601 return response .json ()['token' ]
602602
603- def history (self ):
604- """ Get Play History for all library sections on all servers for the owner. """
603+ def history (self , maxresults = 9999999 , mindate = None ):
604+ """ Get Play History for all library sections on all servers for the owner.
605+ Parameters:
606+ maxresults (int): Only return the specified number of results (optional).
607+ mindate (datetime): Min datetime to return results from.
608+ """
605609 servers = [x for x in self .resources () if x .provides == 'server' and x .owned ]
606610 hist = []
607611 for server in servers :
608612 conn = server .connect ()
609- hist .extend (conn .history (accountID = 1 ))
613+ hist .extend (conn .history (maxresults = maxresults , mindate = mindate , accountID = 1 ))
610614 return hist
611615
612616
@@ -686,11 +690,15 @@ def server(self, name):
686690
687691 raise NotFound ('Unable to find server %s' % name )
688692
689- def history (self ):
690- """ Get all Play History for a user in all shared servers. """
693+ def history (self , maxresults = 9999999 , mindate = None ):
694+ """ Get all Play History for a user in all shared servers.
695+ Parameters:
696+ maxresults (int): Only return the specified number of results (optional).
697+ mindate (datetime): Min datetime to return results from.
698+ """
691699 hist = []
692700 for server in self .servers :
693- hist .extend (server .history ())
701+ hist .extend (server .history (maxresults = maxresults , mindate = mindate ))
694702 return hist
695703
696704
@@ -719,10 +727,15 @@ def _loadData(self, data):
719727 self .type = data .attrib .get ('type' )
720728 self .shared = utils .cast (bool , data .attrib .get ('shared' ))
721729
722- def history (self ):
723- """ Get all Play History for a user for this section in this shared server. """
730+ def history (self , maxresults = 9999999 , mindate = None ):
731+ """ Get all Play History for a user for this section in this shared server.
732+ Parameters:
733+ maxresults (int): Only return the specified number of results (optional).
734+ mindate (datetime): Min datetime to return results from.
735+ """
724736 server = self ._server ._server .resource (self ._server .name ).connect ()
725- return server .history (accountID = self ._server .accountID , librarySectionID = self .sectionKey )
737+ return server .history (maxresults = maxresults , mindate = mindate ,
738+ accountID = self ._server .accountID , librarySectionID = self .sectionKey )
726739
727740
728741class MyPlexServerShare (PlexObject ):
@@ -781,10 +794,14 @@ def sections(self):
781794
782795 return sections
783796
784- def history (self ):
785- """ Get all Play History for a user in this shared server. """
797+ def history (self , maxresults = 9999999 , mindate = None ):
798+ """ Get all Play History for a user in this shared server.
799+ Parameters:
800+ maxresults (int): Only return the specified number of results (optional).
801+ mindate (datetime): Min datetime to return results from.
802+ """
786803 server = self ._server .resource (self .name ).connect ()
787- return server .history (accountID = self .accountID )
804+ return server .history (maxresults = maxresults , mindate = mindate , accountID = self .accountID )
788805
789806
790807class MyPlexResource (PlexObject ):
0 commit comments