mirror of
https://github.com/pkkid/python-plexapi
synced 2025-02-16 21:08:27 +00:00
Merge pull request #199 from pkkid/split
add opt out and split mediaitem.
This commit is contained in:
commit
bdee9ad1f1
2 changed files with 23 additions and 2 deletions
|
@ -494,6 +494,16 @@ class Playable(object):
|
|||
for part in item.parts:
|
||||
yield part
|
||||
|
||||
def split(self):
|
||||
"""Split a duplicate."""
|
||||
key = '%s/split' % self.key
|
||||
return self._server.query(key, method=self._server._session.put)
|
||||
|
||||
def unmatch(self):
|
||||
"""Unmatch a media file."""
|
||||
key = '%s/unmatch' % self.key
|
||||
return self._server.query(key, method=self._server._session.put)
|
||||
|
||||
def play(self, client):
|
||||
""" Start playback on the specified client.
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ class MyPlexAccount(PlexObject):
|
|||
allheaders = BASE_HEADERS.copy()
|
||||
allheaders.update(headers or {})
|
||||
response = method(url, headers=allheaders, timeout=timeout, **kwargs)
|
||||
if response.status_code not in (200, 201):
|
||||
if response.status_code not in (200, 201, 204):
|
||||
codename = codes.get(response.status_code)[0]
|
||||
errtext = response.text.replace('\n', ' ')
|
||||
log.warn('BadRequest (%s) %s %s; %s' % (response.status_code, codename, response.url, errtext))
|
||||
|
@ -361,6 +361,18 @@ class MyPlexAccount(PlexObject):
|
|||
self._webhooks = self.listAttrs(data, 'url', etag='webhook')
|
||||
return self._webhooks
|
||||
|
||||
def optOut(self, playback=None, library=None):
|
||||
""" Opt in or out of sharing stuff with plex.
|
||||
See: https://www.plex.tv/about/privacy-legal/
|
||||
"""
|
||||
params = {}
|
||||
if playback is not None:
|
||||
params['optOutPlayback'] = int(playback)
|
||||
if library is not None:
|
||||
params['optOutLibraryStats'] = int(library)
|
||||
url = 'https://plex.tv/api/v2/user/privacy'
|
||||
return self.query(url, method=self._session.put, params=params)
|
||||
|
||||
|
||||
class MyPlexUser(PlexObject):
|
||||
""" This object represents non-signed in users such as friends and linked
|
||||
|
@ -461,7 +473,6 @@ class MyPlexServerShare(PlexObject):
|
|||
for section in data.iter('Section'):
|
||||
if section:
|
||||
sections.append(Section(self, section, url))
|
||||
|
||||
return sections
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue