Skip to content

Commit bdee9ad

Browse files
authored
Merge pull request #199 from pkkid/split
add opt out and split mediaitem.
2 parents 1121fdc + ae3e90e commit bdee9ad

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

plexapi/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,16 @@ def iterParts(self):
494494
for part in item.parts:
495495
yield part
496496

497+
def split(self):
498+
"""Split a duplicate."""
499+
key = '%s/split' % self.key
500+
return self._server.query(key, method=self._server._session.put)
501+
502+
def unmatch(self):
503+
"""Unmatch a media file."""
504+
key = '%s/unmatch' % self.key
505+
return self._server.query(key, method=self._server._session.put)
506+
497507
def play(self, client):
498508
""" Start playback on the specified client.
499509

plexapi/myplex.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

365377
class 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

Comments
 (0)