Go over documentation a bit more; This will never end.

This commit is contained in:
Michael Shepanski 2017-02-13 23:32:27 -05:00
parent 2f0c053538
commit de69ace19f
11 changed files with 164 additions and 88 deletions

5
docs/modules/notify.py Normal file
View file

@ -0,0 +1,5 @@
Notify (plexapi.notify)
---------------------
.. automodule:: plexapi.notify
:members:
:show-inheritance:

View file

@ -19,6 +19,7 @@
modules/library modules/library
modules/media modules/media
modules/myplex modules/myplex
modules/notify
modules/photo modules/photo
modules/playlist modules/playlist
modules/playqueue modules/playqueue

View file

@ -7,11 +7,6 @@ class Audio(PlexPartialObject):
""" Base class for audio :class:`~plexapi.audio.Artist`, :class:`~plexapi.audio.Album` """ Base class for audio :class:`~plexapi.audio.Artist`, :class:`~plexapi.audio.Album`
and :class:`~plexapi.audio.Track` objects. and :class:`~plexapi.audio.Track` objects.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
addedAt (datetime): Datetime this item was added to the library. addedAt (datetime): Datetime this item was added to the library.
index (sting): Index Number (often the track number). index (sting): Index Number (often the track number).
@ -57,12 +52,9 @@ class Audio(PlexPartialObject):
class Artist(Audio): class Artist(Audio):
""" Represents a single audio artist. """ Represents a single audio artist.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
TAG (str): 'Directory'
TYPE (str): 'artist'
art (str): Artist artwork (/library/metadata/<ratingkey>/art/<artid>) art (str): Artist artwork (/library/metadata/<ratingkey>/art/<artid>)
countries (list): List of :class:`~plexapi.media.Country` objects this artist respresents. countries (list): List of :class:`~plexapi.media.Country` objects this artist respresents.
genres (list): List of :class:`~plexapi.media.Genre` objects this artist respresents. genres (list): List of :class:`~plexapi.media.Genre` objects this artist respresents.
@ -141,12 +133,9 @@ class Artist(Audio):
class Album(Audio): class Album(Audio):
""" Represents a single audio album. """ Represents a single audio album.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
TAG (str): 'Directory'
TYPE (str): 'album'
art (str): Album artwork (/library/metadata/<ratingkey>/art/<artid>) art (str): Album artwork (/library/metadata/<ratingkey>/art/<artid>)
genres (list): List of :class:`~plexapi.media.Genre` objects this album respresents. genres (list): List of :class:`~plexapi.media.Genre` objects this album respresents.
key (str): API URL (/library/metadata/<ratingkey>). key (str): API URL (/library/metadata/<ratingkey>).
@ -220,12 +209,9 @@ class Album(Audio):
class Track(Audio, Playable): class Track(Audio, Playable):
""" Represents a single audio track. """ Represents a single audio track.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): XML response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
TAG (str): 'Directory'
TYPE (str): 'track'
art (str): Track artwork (/library/metadata/<ratingkey>/art/<artid>) art (str): Track artwork (/library/metadata/<ratingkey>/art/<artid>)
chapterSource (TYPE): Unknown chapterSource (TYPE): Unknown
duration (int): Length of this album in seconds. duration (int): Length of this album in seconds.

View file

@ -249,11 +249,6 @@ class PlexPartialObject(PlexObject):
for the object. This object will allow you to assume each object is complete, for the object. This object will allow you to assume each object is complete,
and if the specified value you request is None it will fetch the full object and if the specified value you request is None it will fetch the full object
automatically and update itself. automatically and update itself.
Attributes:
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
""" """
def __eq__(self, other): def __eq__(self, other):
return other is not None and self.key == other.key return other is not None and self.key == other.key
@ -344,13 +339,13 @@ class Playable(object):
Albums which are all not playable. Albums which are all not playable.
Attributes: Attributes:
player (:class:`~plexapi.client.PlexClient`): Client object playing this item (for active sessions).
playlistItemID (int): Playlist item ID (only populated for :class:`~plexapi.playlist.Playlist` items).
sessionKey (int): Active session key. sessionKey (int): Active session key.
username (str): Username of the person playing this item (for active sessions).
players (:class:`~plexapi.client.PlexClient`): Client objects playing this item (for active sessions).
transcodeSession (:class:`~plexapi.media.TranscodeSession`): Transcode Session object transcodeSession (:class:`~plexapi.media.TranscodeSession`): Transcode Session object
if item is being transcoded (None otherwise). if item is being transcoded (None otherwise).
username (str): Username of the person playing this item (for active sessions).
viewedAt (datetime): Datetime item was last viewed (history). viewedAt (datetime): Datetime item was last viewed (history).
playlistItemID (int): Playlist item ID (only populated for :class:`~plexapi.playlist.Playlist` items).
""" """
def _loadData(self, data): def _loadData(self, data):
self.sessionKey = utils.cast(int, data.attrib.get('sessionKey')) # session self.sessionKey = utils.cast(int, data.attrib.get('sessionKey')) # session

View file

@ -16,13 +16,16 @@ class PlexClient(PlexObject):
https://github.com/plexinc/plex-media-player/wiki/Remote-control-API https://github.com/plexinc/plex-media-player/wiki/Remote-control-API
Parameters: Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional).
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Path used to generate data.
baseurl (str): HTTP URL to connect dirrectly to this client. baseurl (str): HTTP URL to connect dirrectly to this client.
token (str): X-Plex-Token used for authenication (optional). token (str): X-Plex-Token used for authenication (optional).
session (:class:`~requests.Session`): requests.Session object if you want more control (optional). session (:class:`~requests.Session`): requests.Session object if you want more control (optional).
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
Attributes: Attributes:
TAG (str): 'Player'
key (str): '/resources'
baseurl (str): HTTP address of the client baseurl (str): HTTP address of the client
device (str): Best guess on the type of device this is (PS, iPhone, Linux, etc). device (str): Best guess on the type of device this is (PS, iPhone, Linux, etc).
deviceClass (str): Device class (pc, phone, etc). deviceClass (str): Device class (pc, phone, etc).

View file

@ -11,6 +11,7 @@ class Library(PlexObject):
in your Plex server including video, shows and audio. in your Plex server including video, shows and audio.
Attributes: Attributes:
key (str): '/library'
identifier (str): Unknown ('com.plexapp.plugins.library'). identifier (str): Unknown ('com.plexapp.plugins.library').
mediaTagVersion (str): Unknown (/system/bundle/media/flags/) mediaTagVersion (str): Unknown (/system/bundle/media/flags/)
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to. server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to.
@ -132,12 +133,10 @@ class Library(PlexObject):
class LibrarySection(PlexObject): class LibrarySection(PlexObject):
""" Base class for a single library section. """ Base class for a single library section.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer object this library section is from.
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
ALLOWED_FILTERS (tuple): ()
ALLOWED_SORT (tuple): ()
BOOLEAN_FILTERS (tuple<str>): ('unwatched', 'duplicate')
server (:class:`~plexapi.server.PlexServer`): Server this client is connected to. server (:class:`~plexapi.server.PlexServer`): Server this client is connected to.
initpath (str): Path requested when building this object. initpath (str): Path requested when building this object.
agent (str): Unknown (com.plexapp.agents.imdb, etc) agent (str): Unknown (com.plexapp.agents.imdb, etc)
@ -471,6 +470,7 @@ class FilterChoice(PlexObject):
:func:`~plexapi.library.LibrarySection.listChoices()`. :func:`~plexapi.library.LibrarySection.listChoices()`.
Attributes: Attributes:
TAG (str): 'Directory'
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to. server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to.
initpath (str): Relative path requested when retrieving specified `data` (optional). initpath (str): Relative path requested when retrieving specified `data` (optional).
fastKey (str): API path to quickly list all items in this filter fastKey (str): API path to quickly list all items in this filter
@ -483,6 +483,7 @@ class FilterChoice(PlexObject):
TAG = 'Directory' TAG = 'Directory'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.fastKey = data.attrib.get('fastKey') self.fastKey = data.attrib.get('fastKey')
self.key = data.attrib.get('key') self.key = data.attrib.get('key')
@ -493,10 +494,20 @@ class FilterChoice(PlexObject):
@utils.registerPlexObject @utils.registerPlexObject
class Hub(PlexObject): class Hub(PlexObject):
FILTERTYPES = {'genre':Genre, 'director':Director, 'actor':Role} """ Represents a single Hub (or category) in the PlexServer search.
Attributes:
TAG (str): 'Hub'
hubIdentifier (str): Unknown.
size (int): Number of items found.
title (str): Title of this Hub.
type (str): Type of items in the Hub.
items (str): List of items in the Hub.
"""
TAG = 'Hub' TAG = 'Hub'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.hubIdentifier = data.attrib.get('hubIdentifier') self.hubIdentifier = data.attrib.get('hubIdentifier')
self.size = utils.cast(int, data.attrib.get('size')) self.size = utils.cast(int, data.attrib.get('size'))

View file

@ -10,13 +10,8 @@ class Media(PlexObject):
""" Container object for all MediaPart objects. Provides useful data about the """ Container object for all MediaPart objects. Provides useful data about the
video this media belong to such as video framerate, resolution, etc. video this media belong to such as video framerate, resolution, etc.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to.
data (ElementTree): Response from PlexServer used to build this object.
initpath (str): Relative path requested when retrieving specified `data`.
video (:class:`~plexapi.video.Video`): Video this media belongs to.
Attributes: Attributes:
TAG (str): 'Media'
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from. server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
initpath (str): Relative path requested when retrieving specified data. initpath (str): Relative path requested when retrieving specified data.
video (str): Video this media belongs to. video (str): Video this media belongs to.
@ -39,6 +34,7 @@ class Media(PlexObject):
TAG = 'Media' TAG = 'Media'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.aspectRatio = cast(float, data.attrib.get('aspectRatio')) self.aspectRatio = cast(float, data.attrib.get('aspectRatio'))
self.audioChannels = cast(int, data.attrib.get('audioChannels')) self.audioChannels = cast(int, data.attrib.get('audioChannels'))
@ -62,6 +58,7 @@ class MediaPart(PlexObject):
""" Represents a single media part (often a single file) for the media this belongs to. """ Represents a single media part (often a single file) for the media this belongs to.
Attributes: Attributes:
TAG (str): 'Part'
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from. server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
initpath (str): Relative path requested when retrieving specified data. initpath (str): Relative path requested when retrieving specified data.
media (:class:`~plexapi.media.Media`): Media object this part belongs to. media (:class:`~plexapi.media.Media`): Media object this part belongs to.
@ -76,6 +73,7 @@ class MediaPart(PlexObject):
TAG = 'Part' TAG = 'Part'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.container = data.attrib.get('container') self.container = data.attrib.get('container')
self.duration = cast(int, data.attrib.get('duration')) self.duration = cast(int, data.attrib.get('duration'))
@ -95,14 +93,17 @@ class MediaPart(PlexObject):
@property @property
def videoStreams(self): def videoStreams(self):
""" Returns a list of :class:`~plexapi.media.VideoStream` objects in this MediaPart. """
return [s for s in self.streams if s.streamType == VideoStream.STREAMTYPE] return [s for s in self.streams if s.streamType == VideoStream.STREAMTYPE]
@property @property
def audioStreams(self): def audioStreams(self):
""" Returns a list of :class:`~plexapi.media.AudioStream` objects in this MediaPart. """
return [s for s in self.streams if s.streamType == AudioStream.STREAMTYPE] return [s for s in self.streams if s.streamType == AudioStream.STREAMTYPE]
@property @property
def subtitleStreams(self): def subtitleStreams(self):
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects in this MediaPart. """
return [s for s in self.streams if s.streamType == SubtitleStream.STREAMTYPE] return [s for s in self.streams if s.streamType == SubtitleStream.STREAMTYPE]
@ -124,8 +125,8 @@ class MediaPartStream(PlexObject):
2=:class:`~plexapi.media.AudioStream`, 3=:class:`~plexapi.media.SubtitleStream`). 2=:class:`~plexapi.media.AudioStream`, 3=:class:`~plexapi.media.SubtitleStream`).
type (int): Alias for streamType. type (int): Alias for streamType.
""" """
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.codec = data.attrib.get('codec') self.codec = data.attrib.get('codec')
self.codecID = data.attrib.get('codecID') self.codecID = data.attrib.get('codecID')
@ -151,6 +152,8 @@ class VideoStream(MediaPartStream):
""" Respresents a video stream within a :class:`~plexapi.media.MediaPart`. """ Respresents a video stream within a :class:`~plexapi.media.MediaPart`.
Attributes: Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 1
bitDepth (int): Bit depth (ex: 8). bitDepth (int): Bit depth (ex: 8).
bitrate (int): Bitrate (ex: 1169) bitrate (int): Bitrate (ex: 1169)
cabac (int): Unknown cabac (int): Unknown
@ -172,6 +175,7 @@ class VideoStream(MediaPartStream):
STREAMTYPE = 1 STREAMTYPE = 1
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(VideoStream, self)._loadData(data) super(VideoStream, self)._loadData(data)
self.bitDepth = cast(int, data.attrib.get('bitDepth')) self.bitDepth = cast(int, data.attrib.get('bitDepth'))
self.bitrate = cast(int, data.attrib.get('bitrate')) self.bitrate = cast(int, data.attrib.get('bitrate'))
@ -196,6 +200,8 @@ class AudioStream(MediaPartStream):
""" Respresents a audio stream within a :class:`~plexapi.media.MediaPart`. """ Respresents a audio stream within a :class:`~plexapi.media.MediaPart`.
Attributes: Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 2
audioChannelLayout (str): Audio channel layout (ex: 5.1(side)). audioChannelLayout (str): Audio channel layout (ex: 5.1(side)).
bitDepth (int): Bit depth (ex: 16). bitDepth (int): Bit depth (ex: 16).
bitrate (int): Audio bitrate (ex: 448). bitrate (int): Audio bitrate (ex: 448).
@ -210,6 +216,7 @@ class AudioStream(MediaPartStream):
STREAMTYPE = 2 STREAMTYPE = 2
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(AudioStream, self)._loadData(data) super(AudioStream, self)._loadData(data)
self.audioChannelLayout = data.attrib.get('audioChannelLayout') self.audioChannelLayout = data.attrib.get('audioChannelLayout')
self.bitDepth = cast(int, data.attrib.get('bitDepth')) self.bitDepth = cast(int, data.attrib.get('bitDepth'))
@ -227,6 +234,8 @@ class SubtitleStream(MediaPartStream):
""" Respresents a audio stream within a :class:`~plexapi.media.MediaPart`. """ Respresents a audio stream within a :class:`~plexapi.media.MediaPart`.
Attributes: Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 3
format (str): Subtitle format (ex: srt). format (str): Subtitle format (ex: srt).
key (str): Key of this subtitle stream (ex: /library/streams/212284). key (str): Key of this subtitle stream (ex: /library/streams/212284).
title (str): Title of this subtitle stream. title (str): Title of this subtitle stream.
@ -235,6 +244,7 @@ class SubtitleStream(MediaPartStream):
STREAMTYPE = 3 STREAMTYPE = 3
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(SubtitleStream, self)._loadData(data) super(SubtitleStream, self)._loadData(data)
self.format = data.attrib.get('format') self.format = data.attrib.get('format')
self.key = data.attrib.get('key') self.key = data.attrib.get('key')
@ -244,11 +254,15 @@ class SubtitleStream(MediaPartStream):
@utils.registerPlexObject @utils.registerPlexObject
class TranscodeSession(PlexObject): class TranscodeSession(PlexObject):
""" Represents a current transcode session. """ Represents a current transcode session.
TODO: Document this.
Attributes:
TAG (str): 'TranscodeSession'
TODO: Document this.
""" """
TAG = 'TranscodeSession' TAG = 'TranscodeSession'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.audioChannels = cast(int, data.attrib.get('audioChannels')) self.audioChannels = cast(int, data.attrib.get('audioChannels'))
self.audioCodec = data.attrib.get('audioCodec') self.audioCodec = data.attrib.get('audioCodec')
@ -273,10 +287,6 @@ class MediaTag(PlexObject):
items or navigating the metadata of media items in your library. Tags are items or navigating the metadata of media items in your library. Tags are
the construct used for things such as Country, Director, Genre, etc. the construct used for things such as Country, Director, Genre, etc.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
Attributes: Attributes:
server (:class:`~plexapi.server.PlexServer`): Server this client is connected to. server (:class:`~plexapi.server.PlexServer`): Server this client is connected to.
id (id): Tag ID (This seems meaningless except to use it as a unique id). id (id): Tag ID (This seems meaningless except to use it as a unique id).
@ -295,6 +305,7 @@ class MediaTag(PlexObject):
* thumb (str): URL to thumbnail image. * thumb (str): URL to thumbnail image.
""" """
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.id = cast(int, data.attrib.get('id')) self.id = cast(int, data.attrib.get('id'))
self.role = data.attrib.get('role') self.role = data.attrib.get('role')
@ -318,51 +329,110 @@ class MediaTag(PlexObject):
@utils.registerPlexObject @utils.registerPlexObject
class Collection(MediaTag): class Collection(MediaTag):
""" Represents a single Collection media tag.
Attributes:
TAG (str): 'Collection'
FILTER (str): 'collection'
"""
TAG = 'Collection' TAG = 'Collection'
FILTER = 'collection' FILTER = 'collection'
@utils.registerPlexObject @utils.registerPlexObject
class Country(MediaTag): class Country(MediaTag):
""" Represents a single Country media tag.
Attributes:
TAG (str): 'Country'
FILTER (str): 'country'
"""
TAG = 'Country' TAG = 'Country'
FILTER = 'country' FILTER = 'country'
@utils.registerPlexObject @utils.registerPlexObject
class Director(MediaTag): class Director(MediaTag):
""" Represents a single Director media tag.
Attributes:
TAG (str): 'Director'
FILTER (str): 'director'
"""
TAG = 'Director' TAG = 'Director'
FILTER = 'director' FILTER = 'director'
@utils.registerPlexObject @utils.registerPlexObject
class Genre(MediaTag): class Genre(MediaTag):
""" Represents a single Genre media tag.
Attributes:
TAG (str): 'Genre'
FILTER (str): 'genre'
"""
TAG = 'Genre' TAG = 'Genre'
FILTER = 'genre' FILTER = 'genre'
@utils.registerPlexObject @utils.registerPlexObject
class Mood(MediaTag): class Mood(MediaTag):
""" Represents a single Mood media tag.
Attributes:
TAG (str): 'Mood'
FILTER (str): 'mood'
"""
TAG = 'Mood' TAG = 'Mood'
FILTER = 'mood' FILTER = 'mood'
@utils.registerPlexObject @utils.registerPlexObject
class Producer(MediaTag): class Producer(MediaTag):
""" Represents a single Producer media tag.
Attributes:
TAG (str): 'Producer'
FILTER (str): 'producer'
"""
TAG = 'Producer' TAG = 'Producer'
FILTER = 'producer' FILTER = 'producer'
@utils.registerPlexObject @utils.registerPlexObject
class Role(MediaTag): class Role(MediaTag):
""" Represents a single Role (actor/actress) media tag.
Attributes:
TAG (str): 'Role'
FILTER (str): 'role'
"""
TAG = 'Role' TAG = 'Role'
FILTER = 'role' FILTER = 'role'
@utils.registerPlexObject @utils.registerPlexObject
class Similar(MediaTag): class Similar(MediaTag):
""" Represents a single Similar media tag.
Attributes:
TAG (str): 'Similar'
FILTER (str): 'similar'
"""
TAG = 'Similar' TAG = 'Similar'
FILTER = 'similar' FILTER = 'similar'
@utils.registerPlexObject @utils.registerPlexObject
class Writer(MediaTag): class Writer(MediaTag):
""" Represents a single Writer media tag.
Attributes:
TAG (str): 'Writer'
FILTER (str): 'writer'
"""
TAG = 'Writer' TAG = 'Writer'
FILTER = 'writer' FILTER = 'writer'
@utils.registerPlexObject @utils.registerPlexObject
class Field(PlexObject): class Field(PlexObject):
""" Represents a single Field.
Attributes:
TAG (str): 'Field'
"""
TAG = 'Field' TAG = 'Field'
def _loadData(self, data): def _loadData(self, data):

View file

@ -17,6 +17,8 @@ class MyPlexAccount(PlexObject):
the myplex.tv servers at the url https://plex.tv/users/account. the myplex.tv servers at the url https://plex.tv/users/account.
Attributes: Attributes:
SIGNIN (str): 'https://my.plexapp.com/users/sign_in.xml'
key (str): 'https://plex.tv/users/account'
authenticationToken (str): <Unknown> authenticationToken (str): <Unknown>
certificateVersion (str): <Unknown> certificateVersion (str): <Unknown>
cloudSyncDevice (str): cloudSyncDevice (str):
@ -56,6 +58,7 @@ class MyPlexAccount(PlexObject):
super(MyPlexAccount, self).__init__(self, data, self.SIGNIN) super(MyPlexAccount, self).__init__(self, data, self.SIGNIN)
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self._token = logfilter.add_secret(data.attrib.get('authenticationToken')) self._token = logfilter.add_secret(data.attrib.get('authenticationToken'))
self.authenticationToken = self._token self.authenticationToken = self._token
@ -157,28 +160,31 @@ class MyPlexUser(PlexObject):
can be found at: https://plex.tv/api/users/ can be found at: https://plex.tv/api/users/
Attributes: Attributes:
allowCameraUpload (bool): True if this user can upload images TAG (str): 'User'
allowChannels (bool): True if this user has access to channels key (str): 'https://plex.tv/api/users/'
allowSync (bool): True if this user can sync allowCameraUpload (bool): True if this user can upload images.
email (str): User's email address (user@gmail.com) allowChannels (bool): True if this user has access to channels.
filterAll (str): Unknown allowSync (bool): True if this user can sync.
filterMovies (str): Unknown email (str): User's email address (user@gmail.com).
filterMusic (str): Unknown filterAll (str): Unknown.
filterPhotos (str): Unknown filterMovies (str): Unknown.
filterTelevision (str): Unknown filterMusic (str): Unknown.
home (bool): Unknown filterPhotos (str): Unknown.
filterTelevision (str): Unknown.
home (bool): Unknown.
id (int): User's Plex account ID. id (int): User's Plex account ID.
protected (False): Unknown (possibly SSL enabled?) protected (False): Unknown (possibly SSL enabled?).
recommendationsPlaylistId (str): Unknown recommendationsPlaylistId (str): Unknown.
restricted (str): Unknown restricted (str): Unknown.
thumb (str): Link to the users avatar thumb (str): Link to the users avatar.
title (str): Seems to be an aliad for username title (str): Seems to be an aliad for username.
username (str): User's username username (str): User's username.
""" """
TAG = 'User' TAG = 'User'
key = 'https://plex.tv/api/users/' key = 'https://plex.tv/api/users/'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data self._data = data
self.allowCameraUpload = utils.cast(bool, data.attrib.get('allowCameraUpload')) self.allowCameraUpload = utils.cast(bool, data.attrib.get('allowCameraUpload'))
self.allowChannels = utils.cast(bool, data.attrib.get('allowChannels')) self.allowChannels = utils.cast(bool, data.attrib.get('allowChannels'))
@ -205,6 +211,8 @@ class MyPlexResource(PlexObject):
for the data presented here can be found at: https://plex.tv/api/resources?includeHttps=1 for the data presented here can be found at: https://plex.tv/api/resources?includeHttps=1
Attributes: Attributes:
TAG (str): 'Device'
key (str): 'https://plex.tv/api/resources?includeHttps=1'
accessToken (str): This resources accesstoken. accessToken (str): This resources accesstoken.
clientIdentifier (str): Unique ID for this resource. clientIdentifier (str): Unique ID for this resource.
connections (list): List of :class:`~myplex.ResourceConnection` objects connections (list): List of :class:`~myplex.ResourceConnection` objects
@ -300,6 +308,7 @@ class ResourceConnection(PlexObject):
:class:`~myplex.MyPlexResource` objects. :class:`~myplex.MyPlexResource` objects.
Attributes: Attributes:
TAG (str): 'Connection'
address (str): Local IP address address (str): Local IP address
httpuri (str): Full local address httpuri (str): Full local address
local (bool): True if local local (bool): True if local
@ -326,6 +335,8 @@ class MyPlexDevice(PlexObject):
https://plex.tv/devices.xml https://plex.tv/devices.xml
Attributes: Attributes:
TAG (str): 'Device'
key (str): 'https://plex.tv/devices.xml'
clientIdentifier (str): Unique ID for this resource. clientIdentifier (str): Unique ID for this resource.
connections (list): List of connection URIs for the device. connections (list): List of connection URIs for the device.
device (str): Best guess on the type of device this is (Linux, iPad, AFTB, etc). device (str): Best guess on the type of device this is (Linux, iPad, AFTB, etc).

View file

@ -8,12 +8,9 @@ from plexapi.exceptions import NotFound
class Photoalbum(PlexPartialObject): class Photoalbum(PlexPartialObject):
""" Represents a photoalbum (collection of photos). """ Represents a photoalbum (collection of photos).
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
TAG (str): 'Directory'
TYPE (str): 'photo'
addedAt (datetime): Datetime this item was added to the library. addedAt (datetime): Datetime this item was added to the library.
art (str): Photo art (/library/metadata/<ratingkey>/art/<artid>) art (str): Photo art (/library/metadata/<ratingkey>/art/<artid>)
composite (str): Unknown composite (str): Unknown
@ -66,12 +63,9 @@ class Photoalbum(PlexPartialObject):
class Photo(PlexPartialObject): class Photo(PlexPartialObject):
""" Represents a single photo. """ Represents a single photo.
Parameters:
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional)
data (ElementTree): Response from PlexServer used to build this object (optional).
initpath (str): Relative path requested when retrieving specified `data` (optional).
Attributes: Attributes:
TAG (str): 'Photo'
TYPE (str): 'photo'
addedAt (datetime): Datetime this item was added to the library. addedAt (datetime): Datetime this item was added to the library.
index (sting): Index number of this photo. index (sting): Index number of this photo.
key (str): API URL (/library/metadata/<ratingkey>). key (str): API URL (/library/metadata/<ratingkey>).

View file

@ -8,10 +8,14 @@ from plexapi.utils import cast, toDatetime
@utils.registerPlexObject @utils.registerPlexObject
class Playlist(PlexPartialObject, Playable): class Playlist(PlexPartialObject, Playable):
""" Represents a single Playlist object.
# TODO: Document attributes
"""
TAG = 'Playlist' TAG = 'Playlist'
TYPE = 'playlist' TYPE = 'playlist'
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """
Playable._loadData(self, data) Playable._loadData(self, data)
self.addedAt = toDatetime(data.attrib.get('addedAt')) self.addedAt = toDatetime(data.attrib.get('addedAt'))
self.composite = data.attrib.get('composite') # url to thumbnail self.composite = data.attrib.get('composite') # url to thumbnail
@ -35,7 +39,7 @@ class Playlist(PlexPartialObject, Playable):
return self.fetchItems(key) return self.fetchItems(key)
def addItems(self, items): def addItems(self, items):
"""Add items to a playlist.""" """ Add items to a playlist. """
if not isinstance(items, (list, tuple)): if not isinstance(items, (list, tuple)):
items = [items] items = [items]
ratingKeys = [] ratingKeys = []
@ -51,24 +55,24 @@ class Playlist(PlexPartialObject, Playable):
return self._server.query(key, method=self._server._session.put) return self._server.query(key, method=self._server._session.put)
def removeItem(self, item): def removeItem(self, item):
"""Remove a file from a playlist.""" """ Remove a file from a playlist. """
key = '%s/items/%s' % (self.key, item.playlistItemID) key = '%s/items/%s' % (self.key, item.playlistItemID)
return self._server.query(key, method=self._server._session.delete) return self._server.query(key, method=self._server._session.delete)
def moveItem(self, item, after=None): def moveItem(self, item, after=None):
"""Move a to a new position in playlist.""" """ Move a to a new position in playlist. """
key = '%s/items/%s/move' % (self.key, item.playlistItemID) key = '%s/items/%s/move' % (self.key, item.playlistItemID)
if after: if after:
key += '?after=%s' % after.playlistItemID key += '?after=%s' % after.playlistItemID
return self._server.query(key, method=self._server._session.put) return self._server.query(key, method=self._server._session.put)
def edit(self, title=None, summary=None): def edit(self, title=None, summary=None):
"""Edit playlist.""" """ Edit playlist. """
key = '/library/metadata/%s%s' % (self.ratingKey, utils.joinArgs({'title':title, 'summary':summary})) key = '/library/metadata/%s%s' % (self.ratingKey, utils.joinArgs({'title':title, 'summary':summary}))
return self._server.query(key, method=self._server._session.put) return self._server.query(key, method=self._server._session.put)
def delete(self): def delete(self):
"""Delete playlist.""" """ Delete playlist. """
return self._server.query(self.key, method=self._server._session.delete) return self._server.query(self.key, method=self._server._session.delete)
def playQueue(self, *args, **kwargs): def playQueue(self, *args, **kwargs):
@ -77,7 +81,7 @@ class Playlist(PlexPartialObject, Playable):
@classmethod @classmethod
def create(cls, server, title, items): def create(cls, server, title, items):
"""Create a playlist.""" """ Create a playlist. """
if not isinstance(items, (list, tuple)): if not isinstance(items, (list, tuple)):
items = [items] items = [items]
ratingKeys = [] ratingKeys = []

View file

@ -265,7 +265,7 @@ class Show(Video):
episode (int): Episode number (default:None; required if title not specified). episode (int): Episode number (default:None; required if title not specified).
Raises: Raises:
ValueError: If season and episode is missing. BadRequest: If season and episode is missing.
NotFound: If the episode is missing. NotFound: If the episode is missing.
""" """
if title: if title:
@ -276,7 +276,7 @@ class Show(Video):
if results: if results:
return results[0] return results[0]
raise NotFound('Couldnt find %s S%s E%s' % (self.title, season, episode)) raise NotFound('Couldnt find %s S%s E%s' % (self.title, season, episode))
raise TypeError('Missing argument: title or season and episode are required') raise BadRequest('Missing argument: title or season and episode are required')
def watched(self): def watched(self):
""" Returns list of watched :class:`~plexapi.video.Episode` objects. """ """ Returns list of watched :class:`~plexapi.video.Episode` objects. """
@ -361,13 +361,9 @@ class Season(Video):
def episode(self, title=None, episode=None): def episode(self, title=None, episode=None):
""" Returns the episode with the given title or number. """ Returns the episode with the given title or number.
Parameters: Parameters:
title (str): Title of the episode to return. title (str): Title of the episode to return.
episode (int): Episode number (default:None; required if title not specified). episode (int): Episode number (default:None; required if title not specified).
Raises:
TypeError: If title and episode is missing.
NotFound: If that episode cant be found.
""" """
if not title and not episode: if not title and not episode:
raise BadRequest('Missing argument, you need to use title or episode.') raise BadRequest('Missing argument, you need to use title or episode.')