2016-03-21 04:26:02 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-09-05 14:09:15 +00:00
|
|
|
|
import requests
|
2014-12-29 03:21:58 +00:00
|
|
|
|
from requests.status_codes import _codes as codes
|
2019-06-03 03:12:07 +00:00
|
|
|
|
from plexapi import BASE_HEADERS, CONFIG, TIMEOUT, X_PLEX_CONTAINER_SIZE
|
2017-01-26 06:33:01 +00:00
|
|
|
|
from plexapi import log, logfilter, utils
|
2017-02-25 04:50:58 +00:00
|
|
|
|
from plexapi.alert import AlertListener
|
2017-02-06 04:52:10 +00:00
|
|
|
|
from plexapi.base import PlexObject
|
2016-04-02 06:19:32 +00:00
|
|
|
|
from plexapi.client import PlexClient
|
2017-02-03 07:15:41 +00:00
|
|
|
|
from plexapi.compat import ElementTree, urlencode
|
2020-04-09 20:56:26 +00:00
|
|
|
|
from plexapi.exceptions import BadRequest, NotFound, Unauthorized
|
2017-02-13 02:55:55 +00:00
|
|
|
|
from plexapi.library import Library, Hub
|
2017-02-23 06:33:30 +00:00
|
|
|
|
from plexapi.settings import Settings
|
2016-04-11 03:49:23 +00:00
|
|
|
|
from plexapi.playlist import Playlist
|
2014-12-29 03:21:58 +00:00
|
|
|
|
from plexapi.playqueue import PlayQueue
|
2017-02-04 17:43:50 +00:00
|
|
|
|
from plexapi.utils import cast
|
2019-10-10 15:12:34 +00:00
|
|
|
|
from plexapi.media import Optimized, Conversion
|
2017-02-13 02:55:55 +00:00
|
|
|
|
|
|
|
|
|
# Need these imports to populate utils.PLEXOBJECTS
|
2017-02-25 05:46:24 +00:00
|
|
|
|
from plexapi import (audio as _audio, video as _video, # noqa: F401
|
|
|
|
|
photo as _photo, media as _media, playlist as _playlist) # noqa: F401
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
|
|
|
|
|
2017-02-06 04:52:10 +00:00
|
|
|
|
class PlexServer(PlexObject):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" This is the main entry point to interacting with a Plex server. It allows you to
|
|
|
|
|
list connected clients, browse your library sections and perform actions such as
|
|
|
|
|
emptying trash. If you do not know the auth token required to access your Plex
|
|
|
|
|
server, or simply want to access your server with your username and password, you
|
|
|
|
|
can also create an PlexServer instance from :class:`~plexapi.myplex.MyPlexAccount`.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
baseurl (str): Base url for to access the Plex Media Server (default: 'http://localhost:32400').
|
|
|
|
|
token (str): Required Plex authentication token to access the server.
|
|
|
|
|
session (requests.Session, optional): Use your own session object if you want to
|
|
|
|
|
cache the http responses from PMS
|
2017-04-24 02:59:22 +00:00
|
|
|
|
timeout (int): timeout in seconds on initial connect to server (default config.TIMEOUT).
|
2017-02-03 06:29:19 +00:00
|
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
|
allowCameraUpload (bool): True if server allows camera upload.
|
|
|
|
|
allowChannelAccess (bool): True if server allows channel access (iTunes?).
|
|
|
|
|
allowMediaDeletion (bool): True is server allows media to be deleted.
|
|
|
|
|
allowSharing (bool): True is server allows sharing.
|
|
|
|
|
allowSync (bool): True is server allows sync.
|
|
|
|
|
backgroundProcessing (bool): Unknown
|
|
|
|
|
certificate (bool): True if server has an HTTPS certificate.
|
|
|
|
|
companionProxy (bool): Unknown
|
|
|
|
|
diagnostics (bool): Unknown
|
|
|
|
|
eventStream (bool): Unknown
|
|
|
|
|
friendlyName (str): Human friendly name for this server.
|
|
|
|
|
hubSearch (bool): True if `Hub Search <https://www.plex.tv/blog
|
|
|
|
|
/seek-plex-shall-find-leveling-web-app/>`_ is enabled. I believe this
|
|
|
|
|
is enabled for everyone
|
|
|
|
|
machineIdentifier (str): Unique ID for this server (looks like an md5).
|
|
|
|
|
multiuser (bool): True if `multiusers <https://support.plex.tv/hc/en-us/articles
|
|
|
|
|
/200250367-Multi-User-Support>`_ are enabled.
|
|
|
|
|
myPlex (bool): Unknown (True if logged into myPlex?).
|
|
|
|
|
myPlexMappingState (str): Unknown (ex: mapped).
|
|
|
|
|
myPlexSigninState (str): Unknown (ex: ok).
|
2017-08-11 19:14:32 +00:00
|
|
|
|
myPlexSubscription (bool): True if you have a myPlex subscription.
|
2017-02-03 06:29:19 +00:00
|
|
|
|
myPlexUsername (str): Email address if signed into myPlex (user@example.com)
|
2017-04-29 05:47:21 +00:00
|
|
|
|
ownerFeatures (list): List of features allowed by the server owner. This may be based
|
2017-02-03 06:29:19 +00:00
|
|
|
|
on your PlexPass subscription. Features include: camera_upload, cloudsync,
|
|
|
|
|
content_filter, dvr, hardware_transcoding, home, lyrics, music_videos, pass,
|
|
|
|
|
photo_autotags, premium_music_metadata, session_bandwidth_restrictions, sync,
|
|
|
|
|
trailers, webhooks (and maybe more).
|
|
|
|
|
photoAutoTag (bool): True if photo `auto-tagging <https://support.plex.tv/hc/en-us
|
|
|
|
|
/articles/234976627-Auto-Tagging-of-Photos>`_ is enabled.
|
|
|
|
|
platform (str): Platform the server is hosted on (ex: Linux)
|
|
|
|
|
platformVersion (str): Platform version (ex: '6.1 (Build 7601)', '4.4.0-59-generic').
|
|
|
|
|
pluginHost (bool): Unknown
|
|
|
|
|
readOnlyLibraries (bool): Unknown
|
|
|
|
|
requestParametersInCookie (bool): Unknown
|
|
|
|
|
streamingBrainVersion (bool): Current `Streaming Brain <https://www.plex.tv/blog
|
|
|
|
|
/mcstreamy-brain-take-world-two-easy-steps/>`_ version.
|
|
|
|
|
sync (bool): True if `syncing to a device <https://support.plex.tv/hc/en-us/articles
|
|
|
|
|
/201053678-Sync-Media-to-a-Device>`_ is enabled.
|
|
|
|
|
transcoderActiveVideoSessions (int): Number of active video transcoding sessions.
|
|
|
|
|
transcoderAudio (bool): True if audio transcoding audio is available.
|
|
|
|
|
transcoderLyrics (bool): True if audio transcoding lyrics is available.
|
|
|
|
|
transcoderPhoto (bool): True if audio transcoding photos is available.
|
|
|
|
|
transcoderSubtitles (bool): True if audio transcoding subtitles is available.
|
|
|
|
|
transcoderVideo (bool): True if audio transcoding video is available.
|
|
|
|
|
transcoderVideoBitrates (bool): List of video bitrates.
|
|
|
|
|
transcoderVideoQualities (bool): List of video qualities.
|
|
|
|
|
transcoderVideoResolutions (bool): List of video resolutions.
|
|
|
|
|
updatedAt (int): Datetime the server was updated.
|
|
|
|
|
updater (bool): Unknown
|
|
|
|
|
version (str): Current Plex version (ex: 1.3.2.3112-1751929)
|
|
|
|
|
voiceSearch (bool): True if voice search is enabled. (is this Google Voice search?)
|
2017-06-05 02:01:07 +00:00
|
|
|
|
_baseurl (str): HTTP address of the client.
|
|
|
|
|
_token (str): Token used to access this client.
|
|
|
|
|
_session (obj): Requests session object used to access this client.
|
2016-12-15 23:06:12 +00:00
|
|
|
|
"""
|
2017-02-06 04:52:10 +00:00
|
|
|
|
key = '/'
|
|
|
|
|
|
2017-04-24 02:59:22 +00:00
|
|
|
|
def __init__(self, baseurl=None, token=None, session=None, timeout=None):
|
2017-02-22 06:22:10 +00:00
|
|
|
|
self._baseurl = baseurl or CONFIG.get('auth.server_baseurl', 'http://localhost:32400')
|
2019-01-19 22:05:12 +00:00
|
|
|
|
self._baseurl = self._baseurl.rstrip('/')
|
2017-02-20 03:18:23 +00:00
|
|
|
|
self._token = logfilter.add_secret(token or CONFIG.get('auth.server_token'))
|
2018-01-05 02:44:35 +00:00
|
|
|
|
self._showSecrets = CONFIG.get('log.show_secrets', '').lower() == 'true'
|
2017-02-06 04:52:10 +00:00
|
|
|
|
self._session = session or requests.Session()
|
2017-02-23 06:33:30 +00:00
|
|
|
|
self._library = None # cached library
|
|
|
|
|
self._settings = None # cached settings
|
2017-05-27 02:35:33 +00:00
|
|
|
|
self._myPlexAccount = None # cached myPlexAccount
|
2017-04-24 02:59:22 +00:00
|
|
|
|
data = self.query(self.key, timeout=timeout)
|
|
|
|
|
super(PlexServer, self).__init__(self, data, self.key)
|
2017-02-03 06:29:19 +00:00
|
|
|
|
|
|
|
|
|
def _loadData(self, data):
|
|
|
|
|
""" Load attribute values from Plex XML response. """
|
2017-02-04 08:08:47 +00:00
|
|
|
|
self._data = data
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.allowCameraUpload = cast(bool, data.attrib.get('allowCameraUpload'))
|
|
|
|
|
self.allowChannelAccess = cast(bool, data.attrib.get('allowChannelAccess'))
|
|
|
|
|
self.allowMediaDeletion = cast(bool, data.attrib.get('allowMediaDeletion'))
|
|
|
|
|
self.allowSharing = cast(bool, data.attrib.get('allowSharing'))
|
|
|
|
|
self.allowSync = cast(bool, data.attrib.get('allowSync'))
|
|
|
|
|
self.backgroundProcessing = cast(bool, data.attrib.get('backgroundProcessing'))
|
|
|
|
|
self.certificate = cast(bool, data.attrib.get('certificate'))
|
|
|
|
|
self.companionProxy = cast(bool, data.attrib.get('companionProxy'))
|
2017-02-03 16:39:46 +00:00
|
|
|
|
self.diagnostics = utils.toList(data.attrib.get('diagnostics'))
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.eventStream = cast(bool, data.attrib.get('eventStream'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.friendlyName = data.attrib.get('friendlyName')
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.hubSearch = cast(bool, data.attrib.get('hubSearch'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.machineIdentifier = data.attrib.get('machineIdentifier')
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.multiuser = cast(bool, data.attrib.get('multiuser'))
|
|
|
|
|
self.myPlex = cast(bool, data.attrib.get('myPlex'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.myPlexMappingState = data.attrib.get('myPlexMappingState')
|
|
|
|
|
self.myPlexSigninState = data.attrib.get('myPlexSigninState')
|
2017-08-11 19:14:32 +00:00
|
|
|
|
self.myPlexSubscription = cast(bool, data.attrib.get('myPlexSubscription'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.myPlexUsername = data.attrib.get('myPlexUsername')
|
2017-02-03 16:39:46 +00:00
|
|
|
|
self.ownerFeatures = utils.toList(data.attrib.get('ownerFeatures'))
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.photoAutoTag = cast(bool, data.attrib.get('photoAutoTag'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.platform = data.attrib.get('platform')
|
|
|
|
|
self.platformVersion = data.attrib.get('platformVersion')
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.pluginHost = cast(bool, data.attrib.get('pluginHost'))
|
|
|
|
|
self.readOnlyLibraries = cast(int, data.attrib.get('readOnlyLibraries'))
|
|
|
|
|
self.requestParametersInCookie = cast(bool, data.attrib.get('requestParametersInCookie'))
|
|
|
|
|
self.streamingBrainVersion = data.attrib.get('streamingBrainVersion')
|
|
|
|
|
self.sync = cast(bool, data.attrib.get('sync'))
|
2015-06-15 02:45:22 +00:00
|
|
|
|
self.transcoderActiveVideoSessions = int(data.attrib.get('transcoderActiveVideoSessions', 0))
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.transcoderAudio = cast(bool, data.attrib.get('transcoderAudio'))
|
|
|
|
|
self.transcoderLyrics = cast(bool, data.attrib.get('transcoderLyrics'))
|
|
|
|
|
self.transcoderPhoto = cast(bool, data.attrib.get('transcoderPhoto'))
|
|
|
|
|
self.transcoderSubtitles = cast(bool, data.attrib.get('transcoderSubtitles'))
|
|
|
|
|
self.transcoderVideo = cast(bool, data.attrib.get('transcoderVideo'))
|
2017-02-03 16:39:46 +00:00
|
|
|
|
self.transcoderVideoBitrates = utils.toList(data.attrib.get('transcoderVideoBitrates'))
|
|
|
|
|
self.transcoderVideoQualities = utils.toList(data.attrib.get('transcoderVideoQualities'))
|
|
|
|
|
self.transcoderVideoResolutions = utils.toList(data.attrib.get('transcoderVideoResolutions'))
|
2017-02-04 17:43:50 +00:00
|
|
|
|
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.updater = cast(bool, data.attrib.get('updater'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
self.version = data.attrib.get('version')
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.voiceSearch = cast(bool, data.attrib.get('voiceSearch'))
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
2017-02-06 04:52:10 +00:00
|
|
|
|
def _headers(self, **kwargs):
|
|
|
|
|
""" Returns dict containing base headers for all requests to the server. """
|
|
|
|
|
headers = BASE_HEADERS.copy()
|
|
|
|
|
if self._token:
|
|
|
|
|
headers['X-Plex-Token'] = self._token
|
|
|
|
|
headers.update(kwargs)
|
|
|
|
|
return headers
|
|
|
|
|
|
2014-12-29 03:21:58 +00:00
|
|
|
|
@property
|
|
|
|
|
def library(self):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Library to browse or search your media. """
|
2016-04-12 02:43:21 +00:00
|
|
|
|
if not self._library:
|
2017-07-28 20:20:30 +00:00
|
|
|
|
try:
|
|
|
|
|
data = self.query(Library.key)
|
|
|
|
|
self._library = Library(self, data)
|
|
|
|
|
except BadRequest:
|
2017-08-18 18:32:27 +00:00
|
|
|
|
data = self.query('/library/sections/')
|
2017-07-28 20:20:30 +00:00
|
|
|
|
# Only the owner has access to /library
|
|
|
|
|
# so just return the library without the data.
|
2017-08-18 18:32:27 +00:00
|
|
|
|
return Library(self, data)
|
2016-04-12 02:43:21 +00:00
|
|
|
|
return self._library
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
2017-02-23 06:33:30 +00:00
|
|
|
|
@property
|
|
|
|
|
def settings(self):
|
|
|
|
|
""" Returns a list of all server settings. """
|
|
|
|
|
if not self._settings:
|
|
|
|
|
data = self.query(Settings.key)
|
|
|
|
|
self._settings = Settings(self, data)
|
|
|
|
|
return self._settings
|
|
|
|
|
|
2014-12-29 03:21:58 +00:00
|
|
|
|
def account(self):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Returns the :class:`~plexapi.server.Account` object this server belongs to. """
|
2017-02-09 04:29:17 +00:00
|
|
|
|
data = self.query(Account.key)
|
2016-04-07 05:39:04 +00:00
|
|
|
|
return Account(self, data)
|
2019-06-29 20:16:55 +00:00
|
|
|
|
|
2020-03-16 18:25:26 +00:00
|
|
|
|
def agents(self, mediaType=None):
|
2020-03-16 17:51:36 +00:00
|
|
|
|
""" Returns the `:class:`~plexapi.media.Agent` objects this server has available. """
|
2020-03-10 20:07:29 +00:00
|
|
|
|
key = '/system/agents'
|
2020-03-16 18:25:26 +00:00
|
|
|
|
if mediaType:
|
|
|
|
|
key += '?mediaType=%s' % mediaType
|
2020-03-16 17:23:33 +00:00
|
|
|
|
return self.fetchItems(key)
|
2020-03-10 20:07:29 +00:00
|
|
|
|
|
2019-06-29 20:16:55 +00:00
|
|
|
|
def createToken(self, type='delegation', scope='all'):
|
|
|
|
|
"""Create a temp access token for the server."""
|
2020-04-16 19:06:36 +00:00
|
|
|
|
if not self._token:
|
|
|
|
|
# Handle unclaimed servers
|
|
|
|
|
return None
|
2019-06-29 20:16:55 +00:00
|
|
|
|
q = self.query('/security/token?type=%s&scope=%s' % (type, scope))
|
|
|
|
|
return q.attrib.get('token')
|
|
|
|
|
|
2019-06-03 04:44:21 +00:00
|
|
|
|
def systemAccounts(self):
|
|
|
|
|
""" Returns the :class:`~plexapi.server.SystemAccounts` objects this server contains. """
|
|
|
|
|
accounts = []
|
|
|
|
|
for elem in self.query('/accounts'):
|
|
|
|
|
accounts.append(SystemAccount(self, data=elem))
|
|
|
|
|
return accounts
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
2017-05-19 03:04:57 +00:00
|
|
|
|
def myPlexAccount(self):
|
|
|
|
|
""" Returns a :class:`~plexapi.myplex.MyPlexAccount` object using the same
|
|
|
|
|
token to access this server. If you are not the owner of this PlexServer
|
|
|
|
|
you're likley to recieve an authentication error calling this.
|
|
|
|
|
"""
|
2017-05-27 02:35:33 +00:00
|
|
|
|
if self._myPlexAccount is None:
|
|
|
|
|
from plexapi.myplex import MyPlexAccount
|
|
|
|
|
self._myPlexAccount = MyPlexAccount(token=self._token)
|
|
|
|
|
return self._myPlexAccount
|
2017-05-19 03:04:57 +00:00
|
|
|
|
|
|
|
|
|
def _myPlexClientPorts(self):
|
2017-05-27 02:35:33 +00:00
|
|
|
|
""" Sometimes the PlexServer does not properly advertise port numbers required
|
|
|
|
|
to connect. This attemps to look up device port number from plex.tv.
|
|
|
|
|
See issue #126: Make PlexServer.clients() more user friendly.
|
|
|
|
|
https://github.com/pkkid/python-plexapi/issues/126
|
|
|
|
|
"""
|
2017-05-19 03:04:57 +00:00
|
|
|
|
try:
|
|
|
|
|
ports = {}
|
|
|
|
|
account = self.myPlexAccount()
|
|
|
|
|
for device in account.devices():
|
|
|
|
|
if device.connections and ':' in device.connections[0][6:]:
|
|
|
|
|
ports[device.clientIdentifier] = device.connections[0].split(':')[-1]
|
|
|
|
|
return ports
|
|
|
|
|
except Exception as err:
|
2017-07-30 18:49:06 +00:00
|
|
|
|
log.warning('Unable to fetch client ports from myPlex: %s', err)
|
2017-05-19 03:04:57 +00:00
|
|
|
|
return ports
|
|
|
|
|
|
2014-12-29 03:21:58 +00:00
|
|
|
|
def clients(self):
|
2017-04-28 01:21:40 +00:00
|
|
|
|
""" Returns list of all :class:`~plexapi.client.PlexClient` objects connected to server. """
|
2014-12-29 03:21:58 +00:00
|
|
|
|
items = []
|
2017-05-19 03:04:57 +00:00
|
|
|
|
ports = None
|
2017-02-09 04:29:17 +00:00
|
|
|
|
for elem in self.query('/clients'):
|
2017-02-26 21:47:40 +00:00
|
|
|
|
port = elem.attrib.get('port')
|
2017-05-19 03:04:57 +00:00
|
|
|
|
if not port:
|
2017-07-30 18:49:06 +00:00
|
|
|
|
log.warning('%s did not advertise a port, checking plex.tv.', elem.attrib.get('name'))
|
2017-05-19 03:04:57 +00:00
|
|
|
|
ports = self._myPlexClientPorts() if ports is None else ports
|
|
|
|
|
port = ports.get(elem.attrib.get('machineIdentifier'))
|
2017-02-26 21:47:40 +00:00
|
|
|
|
baseurl = 'http://%s:%s' % (elem.attrib['host'], port)
|
2017-07-30 18:49:06 +00:00
|
|
|
|
items.append(PlexClient(baseurl=baseurl, server=self,
|
|
|
|
|
token=self._token, data=elem, connect=False))
|
|
|
|
|
|
2014-12-29 03:21:58 +00:00
|
|
|
|
return items
|
|
|
|
|
|
|
|
|
|
def client(self, name):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Returns the :class:`~plexapi.client.PlexClient` that matches the specified name.
|
2016-12-15 23:55:48 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
Parameters:
|
|
|
|
|
name (str): Name of the client to return.
|
2016-12-15 23:06:12 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
Raises:
|
2018-10-03 10:09:43 +00:00
|
|
|
|
:class:`plexapi.exceptions.NotFound`: Unknown client name
|
2016-12-15 23:06:12 +00:00
|
|
|
|
"""
|
2017-07-30 18:49:06 +00:00
|
|
|
|
for client in self.clients():
|
|
|
|
|
if client and client.title == name:
|
|
|
|
|
return client
|
|
|
|
|
|
2014-12-29 03:21:58 +00:00
|
|
|
|
raise NotFound('Unknown client name: %s' % name)
|
|
|
|
|
|
2018-11-16 22:47:49 +00:00
|
|
|
|
def createPlaylist(self, title, items=None, section=None, limit=None, smart=None, **kwargs):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Creates and returns a new :class:`~plexapi.playlist.Playlist`.
|
2017-02-14 21:12:56 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
Parameters:
|
|
|
|
|
title (str): Title of the playlist to be created.
|
|
|
|
|
items (list<Media>): List of media items to include in the playlist.
|
2016-12-15 23:55:48 +00:00
|
|
|
|
"""
|
2018-11-16 22:47:49 +00:00
|
|
|
|
return Playlist.create(self, title, items=items, limit=limit, section=section, smart=smart, **kwargs)
|
2016-04-11 03:49:23 +00:00
|
|
|
|
|
2017-02-14 21:12:56 +00:00
|
|
|
|
def createPlayQueue(self, item, **kwargs):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Creates and returns a new :class:`~plexapi.playqueue.PlayQueue`.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
item (Media or Playlist): Media or playlist to add to PlayQueue.
|
2017-02-15 04:29:22 +00:00
|
|
|
|
kwargs (dict): See `~plexapi.playerque.PlayQueue.create`.
|
2017-02-03 06:29:19 +00:00
|
|
|
|
"""
|
2017-02-14 21:12:56 +00:00
|
|
|
|
return PlayQueue.create(self, item, **kwargs)
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
2017-02-27 04:59:46 +00:00
|
|
|
|
def downloadDatabases(self, savepath=None, unpack=False):
|
2017-05-27 02:35:33 +00:00
|
|
|
|
""" Download databases.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
savepath (str): Defaults to current working dir.
|
|
|
|
|
unpack (bool): Unpack the zip file.
|
|
|
|
|
"""
|
2017-02-27 04:59:46 +00:00
|
|
|
|
url = self.url('/diagnostics/databases')
|
2018-01-05 02:44:35 +00:00
|
|
|
|
filepath = utils.download(url, self._token, None, savepath, self._session, unpack=unpack)
|
2017-02-27 04:59:46 +00:00
|
|
|
|
return filepath
|
|
|
|
|
|
|
|
|
|
def downloadLogs(self, savepath=None, unpack=False):
|
2017-05-27 02:35:33 +00:00
|
|
|
|
""" Download server logs.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
savepath (str): Defaults to current working dir.
|
|
|
|
|
unpack (bool): Unpack the zip file.
|
|
|
|
|
"""
|
2017-02-27 04:59:46 +00:00
|
|
|
|
url = self.url('/diagnostics/logs')
|
2018-01-05 02:44:35 +00:00
|
|
|
|
filepath = utils.download(url, self._token, None, savepath, self._session, unpack=unpack)
|
2017-02-27 04:59:46 +00:00
|
|
|
|
return filepath
|
|
|
|
|
|
2017-07-18 15:59:23 +00:00
|
|
|
|
def check_for_update(self, force=True, download=False):
|
2017-07-30 04:43:54 +00:00
|
|
|
|
""" Returns a :class:`~plexapi.base.Release` object containing release info.
|
2017-07-18 15:59:23 +00:00
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
force (bool): Force server to check for new releases
|
|
|
|
|
download (bool): Download if a update is available.
|
|
|
|
|
"""
|
|
|
|
|
part = '/updater/check?download=%s' % (1 if download else 0)
|
|
|
|
|
if force:
|
|
|
|
|
self.query(part, method=self._session.put)
|
2018-09-14 18:03:23 +00:00
|
|
|
|
releases = self.fetchItems('/updater/status')
|
|
|
|
|
if len(releases):
|
|
|
|
|
return releases[0]
|
2017-07-18 15:59:23 +00:00
|
|
|
|
|
2017-07-17 23:34:28 +00:00
|
|
|
|
def isLatest(self):
|
2017-07-30 04:43:54 +00:00
|
|
|
|
""" Check if the installed version of PMS is the latest. """
|
2017-07-18 15:59:23 +00:00
|
|
|
|
release = self.check_for_update(force=True)
|
2018-09-14 18:03:23 +00:00
|
|
|
|
return release is None
|
2017-07-18 15:59:23 +00:00
|
|
|
|
|
|
|
|
|
def installUpdate(self):
|
2017-07-30 05:05:27 +00:00
|
|
|
|
""" Install the newest version of Plex Media Server. """
|
2017-07-18 21:20:49 +00:00
|
|
|
|
# We can add this but dunno how useful this is since it sometimes
|
|
|
|
|
# requires user action using a gui.
|
2017-09-30 06:44:24 +00:00
|
|
|
|
part = '/updater/apply'
|
2017-07-18 15:59:23 +00:00
|
|
|
|
release = self.check_for_update(force=True, download=True)
|
2017-07-30 05:05:27 +00:00
|
|
|
|
if release and release.version != self.version:
|
2017-07-18 15:59:23 +00:00
|
|
|
|
# figure out what method this is..
|
|
|
|
|
return self.query(part, method=self._session.put)
|
2017-07-17 23:34:28 +00:00
|
|
|
|
|
2019-11-16 21:35:20 +00:00
|
|
|
|
def history(self, maxresults=9999999, mindate=None, ratingKey=None, accountID=None, librarySectionID=None):
|
2019-06-03 03:12:07 +00:00
|
|
|
|
""" Returns a list of media items from watched history. If there are many results, they will
|
|
|
|
|
be fetched from the server in batches of X_PLEX_CONTAINER_SIZE amounts. If you're only
|
|
|
|
|
looking for the first <num> results, it would be wise to set the maxresults option to that
|
|
|
|
|
amount so this functions doesn't iterate over all results on the server.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
maxresults (int): Only return the specified number of results (optional).
|
2019-06-29 20:16:55 +00:00
|
|
|
|
mindate (datetime): Min datetime to return results from. This really helps speed
|
2019-06-03 03:12:07 +00:00
|
|
|
|
up the result listing. For example: datetime.now() - timedelta(days=7)
|
2019-11-14 22:28:46 +00:00
|
|
|
|
ratingKey (int/str) Request history for a specific ratingKey item.
|
2019-11-16 21:35:20 +00:00
|
|
|
|
accountID (int/str) Request history for a specific account ID.
|
|
|
|
|
librarySectionID (int/str) Request history for a specific library section ID.
|
2019-06-03 03:12:07 +00:00
|
|
|
|
"""
|
|
|
|
|
results, subresults = [], '_init'
|
2019-08-06 20:55:03 +00:00
|
|
|
|
args = {'sort': 'viewedAt:desc'}
|
2019-11-14 17:21:49 +00:00
|
|
|
|
if ratingKey:
|
|
|
|
|
args['metadataItemID'] = ratingKey
|
2019-11-16 21:35:20 +00:00
|
|
|
|
if accountID:
|
|
|
|
|
args['accountID'] = accountID
|
|
|
|
|
if librarySectionID:
|
|
|
|
|
args['librarySectionID'] = librarySectionID
|
2019-06-03 03:12:07 +00:00
|
|
|
|
if mindate:
|
|
|
|
|
args['viewedAt>'] = int(mindate.timestamp())
|
|
|
|
|
args['X-Plex-Container-Start'] = 0
|
|
|
|
|
args['X-Plex-Container-Size'] = min(X_PLEX_CONTAINER_SIZE, maxresults)
|
|
|
|
|
while subresults and maxresults > len(results):
|
|
|
|
|
key = '/status/sessions/history/all%s' % utils.joinArgs(args)
|
|
|
|
|
subresults = self.fetchItems(key)
|
|
|
|
|
results += subresults[:maxresults - len(results)]
|
|
|
|
|
args['X-Plex-Container-Start'] += args['X-Plex-Container-Size']
|
|
|
|
|
return results
|
2016-12-15 23:06:12 +00:00
|
|
|
|
|
2016-03-22 03:52:58 +00:00
|
|
|
|
def playlists(self):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Returns a list of all :class:`~plexapi.playlist.Playlist` objects saved on the server. """
|
2016-04-11 03:49:23 +00:00
|
|
|
|
# TODO: Add sort and type options?
|
|
|
|
|
# /playlists/all?type=15&sort=titleSort%3Aasc&playlistType=video&smart=0
|
2017-02-07 06:20:49 +00:00
|
|
|
|
return self.fetchItems('/playlists')
|
2016-12-15 23:06:12 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
def playlist(self, title):
|
|
|
|
|
""" Returns the :class:`~plexapi.client.Playlist` that matches the specified title.
|
2016-12-15 23:55:48 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
Parameters:
|
|
|
|
|
title (str): Title of the playlist to return.
|
2016-12-15 23:55:48 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
Raises:
|
2018-10-03 10:09:43 +00:00
|
|
|
|
:class:`plexapi.exceptions.NotFound`: Invalid playlist title
|
2016-12-15 23:55:48 +00:00
|
|
|
|
"""
|
2017-02-07 06:20:49 +00:00
|
|
|
|
return self.fetchItem('/playlists', title=title)
|
2014-12-29 03:21:58 +00:00
|
|
|
|
|
2020-01-29 14:15:45 +00:00
|
|
|
|
def optimizedItems(self, removeAll=None):
|
2019-10-10 14:43:52 +00:00
|
|
|
|
""" Returns list of all :class:`~plexapi.media.Optimized` objects connected to server. """
|
2020-01-29 14:15:45 +00:00
|
|
|
|
if removeAll is True:
|
|
|
|
|
key = '/playlists/generators?type=42'
|
|
|
|
|
self.query(key, method=self._server._session.delete)
|
|
|
|
|
else:
|
|
|
|
|
backgroundProcessing = self.fetchItem('/playlists?type=42')
|
|
|
|
|
return self.fetchItems('%s/items' % backgroundProcessing.key, cls=Optimized)
|
2019-10-09 03:27:23 +00:00
|
|
|
|
|
2020-01-30 15:45:14 +00:00
|
|
|
|
def optimizedItem(self, optimizedID):
|
|
|
|
|
""" Returns single queued optimized item :class:`~plexapi.media.Video` object.
|
|
|
|
|
Allows for using optimized item ID to connect back to source item.
|
|
|
|
|
"""
|
2019-10-09 03:27:23 +00:00
|
|
|
|
|
2020-01-27 19:17:23 +00:00
|
|
|
|
backgroundProcessing = self.fetchItem('/playlists?type=42')
|
2020-01-30 15:45:14 +00:00
|
|
|
|
return self.fetchItem('%s/items/%s/items' % (backgroundProcessing.key, optimizedID))
|
2019-10-09 03:27:23 +00:00
|
|
|
|
|
2020-01-29 14:16:13 +00:00
|
|
|
|
def conversions(self, pause=None):
|
2019-10-10 15:12:34 +00:00
|
|
|
|
""" Returns list of all :class:`~plexapi.media.Conversion` objects connected to server. """
|
2020-01-29 14:16:13 +00:00
|
|
|
|
if pause is True:
|
|
|
|
|
self.query('/:/prefs?BackgroundQueueIdlePaused=1', method=self._server._session.put)
|
|
|
|
|
elif pause is False:
|
|
|
|
|
self.query('/:/prefs?BackgroundQueueIdlePaused=0', method=self._server._session.put)
|
|
|
|
|
else:
|
|
|
|
|
return self.fetchItems('/playQueues/1', cls=Conversion)
|
2019-10-10 15:12:34 +00:00
|
|
|
|
|
2020-01-29 14:11:07 +00:00
|
|
|
|
def currentBackgroundProcess(self):
|
|
|
|
|
""" Returns list of all :class:`~plexapi.media.TranscodeJob` objects running or paused on server. """
|
|
|
|
|
return self.fetchItems('/status/sessions/background')
|
2019-10-10 15:12:34 +00:00
|
|
|
|
|
2017-04-24 02:59:22 +00:00
|
|
|
|
def query(self, key, method=None, headers=None, timeout=None, **kwargs):
|
2017-02-09 04:29:17 +00:00
|
|
|
|
""" Main method used to handle HTTPS requests to the Plex server. This method helps
|
|
|
|
|
by encoding the response to utf-8 and parsing the returned XML into and
|
|
|
|
|
ElementTree object. Returns None if no data exists in the response.
|
|
|
|
|
"""
|
2017-04-15 00:47:59 +00:00
|
|
|
|
url = self.url(key)
|
2017-02-09 04:29:17 +00:00
|
|
|
|
method = method or self._session.get
|
2017-04-24 02:59:22 +00:00
|
|
|
|
timeout = timeout or TIMEOUT
|
2017-02-09 04:29:17 +00:00
|
|
|
|
log.debug('%s %s', method.__name__.upper(), url)
|
|
|
|
|
headers = self._headers(**headers or {})
|
2017-04-24 02:59:22 +00:00
|
|
|
|
response = method(url, headers=headers, timeout=timeout, **kwargs)
|
2017-02-09 04:29:17 +00:00
|
|
|
|
if response.status_code not in (200, 201):
|
|
|
|
|
codename = codes.get(response.status_code)[0]
|
2017-05-27 02:35:33 +00:00
|
|
|
|
errtext = response.text.replace('\n', ' ')
|
2020-04-09 20:56:26 +00:00
|
|
|
|
message = '(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext)
|
|
|
|
|
if response.status_code == 401:
|
|
|
|
|
raise Unauthorized(message)
|
2020-04-15 22:09:27 +00:00
|
|
|
|
elif response.status_code == 404:
|
|
|
|
|
raise NotFound(message)
|
2020-04-09 20:56:26 +00:00
|
|
|
|
else:
|
|
|
|
|
raise BadRequest(message)
|
2017-02-09 04:29:17 +00:00
|
|
|
|
data = response.text.encode('utf8')
|
2017-02-25 07:37:30 +00:00
|
|
|
|
return ElementTree.fromstring(data) if data.strip() else None
|
2017-02-09 04:29:17 +00:00
|
|
|
|
|
2017-02-03 06:29:19 +00:00
|
|
|
|
def search(self, query, mediatype=None, limit=None):
|
|
|
|
|
""" Returns a list of media items or filter categories from the resulting
|
|
|
|
|
`Hub Search <https://www.plex.tv/blog/seek-plex-shall-find-leveling-web-app/>`_
|
|
|
|
|
against all items in your Plex library. This searches genres, actors, directors,
|
|
|
|
|
playlists, as well as all the obvious media titles. It performs spell-checking
|
|
|
|
|
against your search terms (because KUROSAWA is hard to spell). It also provides
|
|
|
|
|
contextual search results. So for example, if you search for 'Pernice', it’ll
|
|
|
|
|
return 'Pernice Brothers' as the artist result, but we’ll also go ahead and
|
|
|
|
|
return your most-listened to albums and tracks from the artist. If you type
|
|
|
|
|
'Arnold' you’ll get a result for the actor, but also the most recently added
|
|
|
|
|
movies he’s in.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
query (str): Query to use when searching your library.
|
|
|
|
|
mediatype (str): Optionally limit your search to the specified media type.
|
|
|
|
|
limit (int): Optionally limit to the specified number of results per Hub.
|
2017-01-03 22:58:35 +00:00
|
|
|
|
"""
|
2017-02-03 06:29:19 +00:00
|
|
|
|
results = []
|
|
|
|
|
params = {'query': query}
|
2016-01-28 12:09:36 +00:00
|
|
|
|
if mediatype:
|
2017-02-03 06:29:19 +00:00
|
|
|
|
params['section'] = utils.SEARCHTYPES[mediatype]
|
2017-01-03 22:58:35 +00:00
|
|
|
|
if limit:
|
2017-02-03 06:29:19 +00:00
|
|
|
|
params['limit'] = limit
|
2017-02-06 06:28:58 +00:00
|
|
|
|
key = '/hubs/search?%s' % urlencode(params)
|
2017-02-13 02:55:55 +00:00
|
|
|
|
for hub in self.fetchItems(key, Hub):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
results += hub.items
|
|
|
|
|
return results
|
2016-01-28 12:09:36 +00:00
|
|
|
|
|
2015-02-17 20:35:17 +00:00
|
|
|
|
def sessions(self):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Returns a list of all active session (currently playing) media objects. """
|
2017-02-07 06:20:49 +00:00
|
|
|
|
return self.fetchItems('/status/sessions')
|
2016-04-07 05:39:04 +00:00
|
|
|
|
|
2017-02-25 04:50:58 +00:00
|
|
|
|
def startAlertListener(self, callback=None):
|
2017-02-11 04:26:09 +00:00
|
|
|
|
""" Creates a websocket connection to the Plex Server to optionally recieve
|
|
|
|
|
notifications. These often include messages from Plex about media scans
|
|
|
|
|
as well as updates to currently running Transcode Sessions.
|
|
|
|
|
|
|
|
|
|
NOTE: You need websocket-client installed in order to use this feature.
|
|
|
|
|
>> pip install websocket-client
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
callback (func): Callback function to call on recieved messages.
|
|
|
|
|
|
|
|
|
|
raises:
|
2018-10-03 10:09:43 +00:00
|
|
|
|
:class:`plexapi.exception.Unsupported`: Websocket-client not installed.
|
2017-02-11 04:26:09 +00:00
|
|
|
|
"""
|
2017-02-25 04:50:58 +00:00
|
|
|
|
notifier = AlertListener(self, callback)
|
2017-02-11 04:08:36 +00:00
|
|
|
|
notifier.start()
|
|
|
|
|
return notifier
|
|
|
|
|
|
2017-01-02 21:19:07 +00:00
|
|
|
|
def transcodeImage(self, media, height, width, opacity=100, saturation=100):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Returns the URL for a transcoded image from the specified media object.
|
2017-02-04 17:43:50 +00:00
|
|
|
|
Returns None if no media specified (needed if user tries to pass thumb
|
|
|
|
|
or art directly).
|
2017-02-03 06:29:19 +00:00
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
height (int): Height to transcode the image to.
|
|
|
|
|
width (int): Width to transcode the image to.
|
|
|
|
|
opacity (int): Opacity of the resulting image (possibly deprecated).
|
|
|
|
|
saturation (int): Saturating of the resulting image.
|
2017-01-02 21:19:07 +00:00
|
|
|
|
"""
|
|
|
|
|
if media:
|
|
|
|
|
transcode_url = '/photo/:/transcode?height=%s&width=%s&opacity=%s&saturation=%s&url=%s' % (
|
2017-02-03 06:29:19 +00:00
|
|
|
|
height, width, opacity, saturation, media)
|
2018-01-05 02:44:35 +00:00
|
|
|
|
return self.url(transcode_url, includeToken=True)
|
2017-01-02 21:19:07 +00:00
|
|
|
|
|
2018-01-05 02:44:35 +00:00
|
|
|
|
def url(self, key, includeToken=None):
|
|
|
|
|
""" Build a URL string with proper token argument. Token will be appended to the URL
|
|
|
|
|
if either includeToken is True or CONFIG.log.show_secrets is 'true'.
|
|
|
|
|
"""
|
|
|
|
|
if self._token and (includeToken or self._showSecrets):
|
2017-02-13 02:55:55 +00:00
|
|
|
|
delim = '&' if '?' in key else '?'
|
|
|
|
|
return '%s%s%sX-Plex-Token=%s' % (self._baseurl, key, delim, self._token)
|
|
|
|
|
return '%s%s' % (self._baseurl, key)
|
2017-03-06 22:18:10 +00:00
|
|
|
|
|
2018-09-08 15:25:16 +00:00
|
|
|
|
def refreshSynclist(self):
|
|
|
|
|
""" Force PMS to download new SyncList from Plex.tv. """
|
|
|
|
|
return self.query('/sync/refreshSynclists', self._session.put)
|
|
|
|
|
|
|
|
|
|
def refreshContent(self):
|
|
|
|
|
""" Force PMS to refresh content for known SyncLists. """
|
|
|
|
|
return self.query('/sync/refreshContent', self._session.put)
|
|
|
|
|
|
|
|
|
|
def refreshSync(self):
|
|
|
|
|
""" Calls :func:`~plexapi.server.PlexServer.refreshSynclist` and
|
|
|
|
|
:func:`~plexapi.server.PlexServer.refreshContent`, just like the Plex Web UI does when you click 'refresh'.
|
|
|
|
|
"""
|
|
|
|
|
self.refreshSynclist()
|
|
|
|
|
self.refreshContent()
|
|
|
|
|
|
2020-02-26 13:55:24 +00:00
|
|
|
|
def _allowMediaDeletion(self, toggle=False):
|
2020-02-25 21:39:49 +00:00
|
|
|
|
""" Toggle allowMediaDeletion.
|
|
|
|
|
Parameters:
|
|
|
|
|
toggle (bool): True enables Media Deletion
|
2020-02-26 13:55:44 +00:00
|
|
|
|
False or None disable Media Deletion (Default)
|
2020-02-25 21:39:49 +00:00
|
|
|
|
"""
|
2020-02-26 13:56:29 +00:00
|
|
|
|
if self.allowMediaDeletion and toggle is False:
|
|
|
|
|
log.debug('Plex is currently allowed to delete media. Toggling off.')
|
|
|
|
|
elif self.allowMediaDeletion and toggle is True:
|
|
|
|
|
log.debug('Plex is currently allowed to delete media. Toggle set to allow, exiting.')
|
|
|
|
|
raise BadRequest('Plex is currently allowed to delete media. Toggle set to allow, exiting.')
|
|
|
|
|
elif self.allowMediaDeletion is None and toggle is True:
|
|
|
|
|
log.debug('Plex is currently not allowed to delete media. Toggle set to allow.')
|
|
|
|
|
else:
|
|
|
|
|
log.debug('Plex is currently not allowed to delete media. Toggle set to not allow, exiting.')
|
|
|
|
|
raise BadRequest('Plex is currently not allowed to delete media. Toggle set to not allow, exiting.')
|
2020-02-25 21:39:49 +00:00
|
|
|
|
value = 1 if toggle is True else 0
|
|
|
|
|
return self.query('/:/prefs?allowMediaDeletion=%s' % value, self._session.put)
|
|
|
|
|
|
2017-01-02 21:19:07 +00:00
|
|
|
|
|
2017-02-06 04:52:10 +00:00
|
|
|
|
class Account(PlexObject):
|
2017-02-03 06:29:19 +00:00
|
|
|
|
""" Contains the locally cached MyPlex account information. The properties provided don't
|
|
|
|
|
match the :class:`~plexapi.myplex.MyPlexAccount` object very well. I believe this exists
|
|
|
|
|
because access to myplex is not required to get basic plex information. I can't imagine
|
|
|
|
|
object is terribly useful except unless you were needed this information while offline.
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
server (:class:`~plexapi.server.PlexServer`): PlexServer this account is connected to (optional)
|
|
|
|
|
data (ElementTree): Response from PlexServer used to build this object (optional).
|
|
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
|
authToken (str): Plex authentication token to access the server.
|
|
|
|
|
mappingError (str): Unknown
|
|
|
|
|
mappingErrorMessage (str): Unknown
|
|
|
|
|
mappingState (str): Unknown
|
|
|
|
|
privateAddress (str): Local IP address of the Plex server.
|
|
|
|
|
privatePort (str): Local port of the Plex server.
|
|
|
|
|
publicAddress (str): Public IP address of the Plex server.
|
|
|
|
|
publicPort (str): Public port of the Plex server.
|
|
|
|
|
signInState (str): Signin state for this account (ex: ok).
|
|
|
|
|
subscriptionActive (str): True if the account subscription is active.
|
|
|
|
|
subscriptionFeatures (str): List of features allowed by the server for this account.
|
|
|
|
|
This may be based on your PlexPass subscription. Features include: camera_upload,
|
|
|
|
|
cloudsync, content_filter, dvr, hardware_transcoding, home, lyrics, music_videos,
|
|
|
|
|
pass, photo_autotags, premium_music_metadata, session_bandwidth_restrictions,
|
|
|
|
|
sync, trailers, webhooks' (and maybe more).
|
|
|
|
|
subscriptionState (str): 'Active' if this subscription is active.
|
|
|
|
|
username (str): Plex account username (user@example.com).
|
2016-12-15 23:06:12 +00:00
|
|
|
|
"""
|
2017-02-06 04:52:10 +00:00
|
|
|
|
key = '/myplex/account'
|
|
|
|
|
|
|
|
|
|
def _loadData(self, data):
|
2017-02-04 08:08:47 +00:00
|
|
|
|
self._data = data
|
2016-04-07 05:39:04 +00:00
|
|
|
|
self.authToken = data.attrib.get('authToken')
|
|
|
|
|
self.username = data.attrib.get('username')
|
|
|
|
|
self.mappingState = data.attrib.get('mappingState')
|
|
|
|
|
self.mappingError = data.attrib.get('mappingError')
|
|
|
|
|
self.mappingErrorMessage = data.attrib.get('mappingErrorMessage')
|
|
|
|
|
self.signInState = data.attrib.get('signInState')
|
|
|
|
|
self.publicAddress = data.attrib.get('publicAddress')
|
|
|
|
|
self.publicPort = data.attrib.get('publicPort')
|
|
|
|
|
self.privateAddress = data.attrib.get('privateAddress')
|
|
|
|
|
self.privatePort = data.attrib.get('privatePort')
|
2017-02-03 16:39:46 +00:00
|
|
|
|
self.subscriptionFeatures = utils.toList(data.attrib.get('subscriptionFeatures'))
|
2017-02-03 06:29:19 +00:00
|
|
|
|
self.subscriptionActive = cast(bool, data.attrib.get('subscriptionActive'))
|
2016-04-07 05:39:04 +00:00
|
|
|
|
self.subscriptionState = data.attrib.get('subscriptionState')
|
2019-06-03 04:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemAccount(PlexObject):
|
|
|
|
|
""" Minimal api to list system accounts. """
|
|
|
|
|
key = '/accounts'
|
|
|
|
|
|
|
|
|
|
def _loadData(self, data):
|
|
|
|
|
self._data = data
|
2019-06-03 04:50:02 +00:00
|
|
|
|
self.accountID = cast(int, data.attrib.get('id'))
|
2019-06-03 04:44:21 +00:00
|
|
|
|
self.accountKey = data.attrib.get('key')
|
|
|
|
|
self.name = data.attrib.get('name')
|