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/media
modules/myplex
modules/notify
modules/photo
modules/playlist
modules/playqueue

View file

@ -7,11 +7,6 @@ class Audio(PlexPartialObject):
""" Base class for audio :class:`~plexapi.audio.Artist`, :class:`~plexapi.audio.Album`
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:
addedAt (datetime): Datetime this item was added to the library.
index (sting): Index Number (often the track number).
@ -57,12 +52,9 @@ class Audio(PlexPartialObject):
class Artist(Audio):
""" 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:
TAG (str): 'Directory'
TYPE (str): 'artist'
art (str): Artist artwork (/library/metadata/<ratingkey>/art/<artid>)
countries (list): List of :class:`~plexapi.media.Country` 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):
""" 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:
TAG (str): 'Directory'
TYPE (str): 'album'
art (str): Album artwork (/library/metadata/<ratingkey>/art/<artid>)
genres (list): List of :class:`~plexapi.media.Genre` objects this album respresents.
key (str): API URL (/library/metadata/<ratingkey>).
@ -220,12 +209,9 @@ class Album(Audio):
class Track(Audio, Playable):
""" 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:
TAG (str): 'Directory'
TYPE (str): 'track'
art (str): Track artwork (/library/metadata/<ratingkey>/art/<artid>)
chapterSource (TYPE): Unknown
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,
and if the specified value you request is None it will fetch the full object
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):
return other is not None and self.key == other.key
@ -344,13 +339,13 @@ class Playable(object):
Albums which are all not playable.
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.
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
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).
playlistItemID (int): Playlist item ID (only populated for :class:`~plexapi.playlist.Playlist` items).
"""
def _loadData(self, data):
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
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.
token (str): X-Plex-Token used for authenication (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:
TAG (str): 'Player'
key (str): '/resources'
baseurl (str): HTTP address of the client
device (str): Best guess on the type of device this is (PS, iPhone, Linux, 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.
Attributes:
key (str): '/library'
identifier (str): Unknown ('com.plexapp.plugins.library').
mediaTagVersion (str): Unknown (/system/bundle/media/flags/)
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to.
@ -132,12 +133,10 @@ class Library(PlexObject):
class LibrarySection(PlexObject):
""" 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:
ALLOWED_FILTERS (tuple): ()
ALLOWED_SORT (tuple): ()
BOOLEAN_FILTERS (tuple<str>): ('unwatched', 'duplicate')
server (:class:`~plexapi.server.PlexServer`): Server this client is connected to.
initpath (str): Path requested when building this object.
agent (str): Unknown (com.plexapp.agents.imdb, etc)
@ -471,6 +470,7 @@ class FilterChoice(PlexObject):
:func:`~plexapi.library.LibrarySection.listChoices()`.
Attributes:
TAG (str): 'Directory'
server (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to.
initpath (str): Relative path requested when retrieving specified `data` (optional).
fastKey (str): API path to quickly list all items in this filter
@ -483,6 +483,7 @@ class FilterChoice(PlexObject):
TAG = 'Directory'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.fastKey = data.attrib.get('fastKey')
self.key = data.attrib.get('key')
@ -493,10 +494,20 @@ class FilterChoice(PlexObject):
@utils.registerPlexObject
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'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.hubIdentifier = data.attrib.get('hubIdentifier')
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
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:
TAG (str): 'Media'
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
initpath (str): Relative path requested when retrieving specified data.
video (str): Video this media belongs to.
@ -39,6 +34,7 @@ class Media(PlexObject):
TAG = 'Media'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.aspectRatio = cast(float, data.attrib.get('aspectRatio'))
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.
Attributes:
TAG (str): 'Part'
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
initpath (str): Relative path requested when retrieving specified data.
media (:class:`~plexapi.media.Media`): Media object this part belongs to.
@ -76,6 +73,7 @@ class MediaPart(PlexObject):
TAG = 'Part'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.container = data.attrib.get('container')
self.duration = cast(int, data.attrib.get('duration'))
@ -95,14 +93,17 @@ class MediaPart(PlexObject):
@property
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]
@property
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]
@property
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]
@ -124,8 +125,8 @@ class MediaPartStream(PlexObject):
2=:class:`~plexapi.media.AudioStream`, 3=:class:`~plexapi.media.SubtitleStream`).
type (int): Alias for streamType.
"""
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.codec = data.attrib.get('codec')
self.codecID = data.attrib.get('codecID')
@ -151,6 +152,8 @@ class VideoStream(MediaPartStream):
""" Respresents a video stream within a :class:`~plexapi.media.MediaPart`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 1
bitDepth (int): Bit depth (ex: 8).
bitrate (int): Bitrate (ex: 1169)
cabac (int): Unknown
@ -172,6 +175,7 @@ class VideoStream(MediaPartStream):
STREAMTYPE = 1
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(VideoStream, self)._loadData(data)
self.bitDepth = cast(int, data.attrib.get('bitDepth'))
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`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 2
audioChannelLayout (str): Audio channel layout (ex: 5.1(side)).
bitDepth (int): Bit depth (ex: 16).
bitrate (int): Audio bitrate (ex: 448).
@ -210,6 +216,7 @@ class AudioStream(MediaPartStream):
STREAMTYPE = 2
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(AudioStream, self)._loadData(data)
self.audioChannelLayout = data.attrib.get('audioChannelLayout')
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`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 3
format (str): Subtitle format (ex: srt).
key (str): Key of this subtitle stream (ex: /library/streams/212284).
title (str): Title of this subtitle stream.
@ -235,6 +244,7 @@ class SubtitleStream(MediaPartStream):
STREAMTYPE = 3
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(SubtitleStream, self)._loadData(data)
self.format = data.attrib.get('format')
self.key = data.attrib.get('key')
@ -244,11 +254,15 @@ class SubtitleStream(MediaPartStream):
@utils.registerPlexObject
class TranscodeSession(PlexObject):
""" Represents a current transcode session.
TODO: Document this.
Attributes:
TAG (str): 'TranscodeSession'
TODO: Document this.
"""
TAG = 'TranscodeSession'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.audioChannels = cast(int, data.attrib.get('audioChannels'))
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
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:
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).
@ -295,6 +305,7 @@ class MediaTag(PlexObject):
* thumb (str): URL to thumbnail image.
"""
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.id = cast(int, data.attrib.get('id'))
self.role = data.attrib.get('role')
@ -318,51 +329,110 @@ class MediaTag(PlexObject):
@utils.registerPlexObject
class Collection(MediaTag):
""" Represents a single Collection media tag.
Attributes:
TAG (str): 'Collection'
FILTER (str): 'collection'
"""
TAG = 'Collection'
FILTER = 'collection'
@utils.registerPlexObject
class Country(MediaTag):
""" Represents a single Country media tag.
Attributes:
TAG (str): 'Country'
FILTER (str): 'country'
"""
TAG = 'Country'
FILTER = 'country'
@utils.registerPlexObject
class Director(MediaTag):
""" Represents a single Director media tag.
Attributes:
TAG (str): 'Director'
FILTER (str): 'director'
"""
TAG = 'Director'
FILTER = 'director'
@utils.registerPlexObject
class Genre(MediaTag):
""" Represents a single Genre media tag.
Attributes:
TAG (str): 'Genre'
FILTER (str): 'genre'
"""
TAG = 'Genre'
FILTER = 'genre'
@utils.registerPlexObject
class Mood(MediaTag):
""" Represents a single Mood media tag.
Attributes:
TAG (str): 'Mood'
FILTER (str): 'mood'
"""
TAG = 'Mood'
FILTER = 'mood'
@utils.registerPlexObject
class Producer(MediaTag):
""" Represents a single Producer media tag.
Attributes:
TAG (str): 'Producer'
FILTER (str): 'producer'
"""
TAG = 'Producer'
FILTER = 'producer'
@utils.registerPlexObject
class Role(MediaTag):
""" Represents a single Role (actor/actress) media tag.
Attributes:
TAG (str): 'Role'
FILTER (str): 'role'
"""
TAG = 'Role'
FILTER = 'role'
@utils.registerPlexObject
class Similar(MediaTag):
""" Represents a single Similar media tag.
Attributes:
TAG (str): 'Similar'
FILTER (str): 'similar'
"""
TAG = 'Similar'
FILTER = 'similar'
@utils.registerPlexObject
class Writer(MediaTag):
""" Represents a single Writer media tag.
Attributes:
TAG (str): 'Writer'
FILTER (str): 'writer'
"""
TAG = 'Writer'
FILTER = 'writer'
@utils.registerPlexObject
class Field(PlexObject):
""" Represents a single Field.
Attributes:
TAG (str): 'Field'
"""
TAG = 'Field'
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.
Attributes:
SIGNIN (str): 'https://my.plexapp.com/users/sign_in.xml'
key (str): 'https://plex.tv/users/account'
authenticationToken (str): <Unknown>
certificateVersion (str): <Unknown>
cloudSyncDevice (str):
@ -56,6 +58,7 @@ class MyPlexAccount(PlexObject):
super(MyPlexAccount, self).__init__(self, data, self.SIGNIN)
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self._token = logfilter.add_secret(data.attrib.get('authenticationToken'))
self.authenticationToken = self._token
@ -157,28 +160,31 @@ class MyPlexUser(PlexObject):
can be found at: https://plex.tv/api/users/
Attributes:
allowCameraUpload (bool): True if this user can upload images
allowChannels (bool): True if this user has access to channels
allowSync (bool): True if this user can sync
email (str): User's email address (user@gmail.com)
filterAll (str): Unknown
filterMovies (str): Unknown
filterMusic (str): Unknown
filterPhotos (str): Unknown
filterTelevision (str): Unknown
home (bool): Unknown
TAG (str): 'User'
key (str): 'https://plex.tv/api/users/'
allowCameraUpload (bool): True if this user can upload images.
allowChannels (bool): True if this user has access to channels.
allowSync (bool): True if this user can sync.
email (str): User's email address (user@gmail.com).
filterAll (str): Unknown.
filterMovies (str): Unknown.
filterMusic (str): Unknown.
filterPhotos (str): Unknown.
filterTelevision (str): Unknown.
home (bool): Unknown.
id (int): User's Plex account ID.
protected (False): Unknown (possibly SSL enabled?)
recommendationsPlaylistId (str): Unknown
restricted (str): Unknown
thumb (str): Link to the users avatar
title (str): Seems to be an aliad for username
username (str): User's username
protected (False): Unknown (possibly SSL enabled?).
recommendationsPlaylistId (str): Unknown.
restricted (str): Unknown.
thumb (str): Link to the users avatar.
title (str): Seems to be an aliad for username.
username (str): User's username.
"""
TAG = 'User'
key = 'https://plex.tv/api/users/'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.allowCameraUpload = utils.cast(bool, data.attrib.get('allowCameraUpload'))
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
Attributes:
TAG (str): 'Device'
key (str): 'https://plex.tv/api/resources?includeHttps=1'
accessToken (str): This resources accesstoken.
clientIdentifier (str): Unique ID for this resource.
connections (list): List of :class:`~myplex.ResourceConnection` objects
@ -300,6 +308,7 @@ class ResourceConnection(PlexObject):
:class:`~myplex.MyPlexResource` objects.
Attributes:
TAG (str): 'Connection'
address (str): Local IP address
httpuri (str): Full local address
local (bool): True if local
@ -326,6 +335,8 @@ class MyPlexDevice(PlexObject):
https://plex.tv/devices.xml
Attributes:
TAG (str): 'Device'
key (str): 'https://plex.tv/devices.xml'
clientIdentifier (str): Unique ID for this resource.
connections (list): List of connection URIs for the device.
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):
""" 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:
TAG (str): 'Directory'
TYPE (str): 'photo'
addedAt (datetime): Datetime this item was added to the library.
art (str): Photo art (/library/metadata/<ratingkey>/art/<artid>)
composite (str): Unknown
@ -66,12 +63,9 @@ class Photoalbum(PlexPartialObject):
class Photo(PlexPartialObject):
""" 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:
TAG (str): 'Photo'
TYPE (str): 'photo'
addedAt (datetime): Datetime this item was added to the library.
index (sting): Index number of this photo.
key (str): API URL (/library/metadata/<ratingkey>).

View file

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

View file

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