@@ -145,7 +145,7 @@ def query(self, url, method=None, headers=None, timeout=None, **kwargs):
145145 allheaders = BASE_HEADERS .copy ()
146146 allheaders .update (headers or {})
147147 response = method (url , headers = allheaders , timeout = timeout , ** kwargs )
148- if response .status_code not in (200 , 201 ):
148+ if response .status_code not in (200 , 201 , 204 ):
149149 codename = codes .get (response .status_code )[0 ]
150150 errtext = response .text .replace ('\n ' , ' ' )
151151 log .warn ('BadRequest (%s) %s %s; %s' % (response .status_code , codename , response .url , errtext ))
@@ -361,6 +361,18 @@ def webhooks(self):
361361 self ._webhooks = self .listAttrs (data , 'url' , etag = 'webhook' )
362362 return self ._webhooks
363363
364+ def optOut (self , playback = None , library = None ):
365+ """ Opt in or out of sharing stuff with plex.
366+ See: https://www.plex.tv/about/privacy-legal/
367+ """
368+ params = {}
369+ if playback is not None :
370+ params ['optOutPlayback' ] = int (playback )
371+ if library is not None :
372+ params ['optOutLibraryStats' ] = int (library )
373+ url = 'https://plex.tv/api/v2/user/privacy'
374+ return self .query (url , method = self ._session .put , params = params )
375+
364376
365377class MyPlexUser (PlexObject ):
366378 """ This object represents non-signed in users such as friends and linked
@@ -461,7 +473,6 @@ def sections(self):
461473 for section in data .iter ('Section' ):
462474 if section :
463475 sections .append (Section (self , section , url ))
464-
465476 return sections
466477
467478
0 commit comments