mirror of
https://github.com/pkkid/python-plexapi
synced 2025-02-16 21:08:27 +00:00
commit
04d2a4b6d7
4 changed files with 45 additions and 13 deletions
|
@ -64,7 +64,8 @@ class Audio(PlexPartialObject):
|
||||||
@property
|
@property
|
||||||
def thumbUrl(self):
|
def thumbUrl(self):
|
||||||
"""Return url to thumb image."""
|
"""Return url to thumb image."""
|
||||||
return self.server.url(self.thumb)
|
if self.thumb:
|
||||||
|
return self.server.url(self.thumb)
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
"""Refresh the metadata."""
|
"""Refresh the metadata."""
|
||||||
|
@ -308,7 +309,8 @@ class Track(Audio, Playable):
|
||||||
@property
|
@property
|
||||||
def thumbUrl(self):
|
def thumbUrl(self):
|
||||||
"""Return url to thumb image."""
|
"""Return url to thumb image."""
|
||||||
return self.server.url(self.parentThumb)
|
if self.parentThumb:
|
||||||
|
return self.server.url(self.parentThumb)
|
||||||
|
|
||||||
def album(self):
|
def album(self):
|
||||||
"""Return this track's Album."""
|
"""Return this track's Album."""
|
||||||
|
|
|
@ -52,7 +52,8 @@ class Library(object):
|
||||||
return self._sectionsByID[sectionID]
|
return self._sectionsByID[sectionID]
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
return utils.listItems(self.server, '/library/all')
|
return [item for section in self.library.sections()
|
||||||
|
for item in section.all()]
|
||||||
|
|
||||||
def onDeck(self):
|
def onDeck(self):
|
||||||
return utils.listItems(self.server, '/library/onDeck')
|
return utils.listItems(self.server, '/library/onDeck')
|
||||||
|
|
|
@ -236,6 +236,28 @@ class PlexServer(object):
|
||||||
return '%s%s%sX-Plex-Token=%s' % (self.baseurl, path, delim, self.token)
|
return '%s%s%sX-Plex-Token=%s' % (self.baseurl, path, delim, self.token)
|
||||||
return '%s%s' % (self.baseurl, path)
|
return '%s%s' % (self.baseurl, path)
|
||||||
|
|
||||||
|
def transcodeImage(self, media, height, width, opacity=100, saturation=100):
|
||||||
|
"""Transcode a image.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
height (int): height off image
|
||||||
|
width (int): width off image
|
||||||
|
opacity (int): Dont seems to be in use anymore # check it
|
||||||
|
saturation (int): transparency
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
transcoded_image_url or None
|
||||||
|
|
||||||
|
"""
|
||||||
|
# check for NA incase any tries to pass thumb, or art directly.
|
||||||
|
if media:
|
||||||
|
transcode_url = '/photo/:/transcode?height=%s&width=%s&opacity=%s&saturation=%s&url=%s' % (
|
||||||
|
height, width, opacity, saturation, media)
|
||||||
|
|
||||||
|
return self.url(transcode_url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Account(object):
|
class Account(object):
|
||||||
"""This is the locally cached MyPlex account information.
|
"""This is the locally cached MyPlex account information.
|
||||||
|
@ -264,8 +286,8 @@ class Account(object):
|
||||||
"""Set attrs.
|
"""Set attrs.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
server (Plexclient):
|
server (Plexclient):
|
||||||
data (xml.etree.ElementTree.Element): used to set the class attributes.
|
data (xml.etree.ElementTree.Element): used to set the class attributes.
|
||||||
"""
|
"""
|
||||||
self.authToken = data.attrib.get('authToken')
|
self.authToken = data.attrib.get('authToken')
|
||||||
self.username = data.attrib.get('username')
|
self.username = data.attrib.get('username')
|
||||||
|
|
|
@ -44,7 +44,8 @@ class Video(PlexPartialObject):
|
||||||
@property
|
@property
|
||||||
def thumbUrl(self):
|
def thumbUrl(self):
|
||||||
"""Return url to thumb image."""
|
"""Return url to thumb image."""
|
||||||
return self.server.url(self.thumb)
|
if self.thumb:
|
||||||
|
return self.server.url(self.thumb)
|
||||||
|
|
||||||
def analyze(self):
|
def analyze(self):
|
||||||
"""The primary purpose of media analysis is to gather information about
|
"""The primary purpose of media analysis is to gather information about
|
||||||
|
@ -169,11 +170,11 @@ class Show(Video):
|
||||||
self.viewedLeafCount = utils.cast(
|
self.viewedLeafCount = utils.cast(
|
||||||
int, data.attrib.get('viewedLeafCount', NA))
|
int, data.attrib.get('viewedLeafCount', NA))
|
||||||
self.year = utils.cast(int, data.attrib.get('year', NA))
|
self.year = utils.cast(int, data.attrib.get('year', NA))
|
||||||
if self.isFullObject():
|
#if self.isFullObject(): # will be fixed with docs.
|
||||||
self.genres = [media.Genre(self.server, e)
|
self.genres = [media.Genre(self.server, e)
|
||||||
for e in data if e.tag == media.Genre.TYPE]
|
for e in data if e.tag == media.Genre.TYPE]
|
||||||
self.roles = [media.Role(self.server, e)
|
self.roles = [media.Role(self.server, e)
|
||||||
for e in data if e.tag == media.Role.TYPE]
|
for e in data if e.tag == media.Role.TYPE]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def actors(self):
|
def actors(self):
|
||||||
|
@ -263,6 +264,11 @@ class Season(Video):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
watched (bool): Defaults to None. Exclude watched episodes
|
watched (bool): Defaults to None. Exclude watched episodes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: of Episode
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
childrenKey = '/library/metadata/%s/children' % self.ratingKey
|
childrenKey = '/library/metadata/%s/children' % self.ratingKey
|
||||||
return utils.listItems(self.server, childrenKey, watched=watched)
|
return utils.listItems(self.server, childrenKey, watched=watched)
|
||||||
|
@ -280,7 +286,7 @@ class Season(Video):
|
||||||
return utils.findItem(self.server, path, title)
|
return utils.findItem(self.server, path, title)
|
||||||
|
|
||||||
def get(self, title):
|
def get(self, title):
|
||||||
"""Get a episode witha mathcing title
|
"""Get a episode witha matching title
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title (str): fx Secret santa
|
title (str): fx Secret santa
|
||||||
|
@ -368,7 +374,8 @@ class Episode(Video, Playable):
|
||||||
@property
|
@property
|
||||||
def thumbUrl(self):
|
def thumbUrl(self):
|
||||||
"""Return url to thumb image."""
|
"""Return url to thumb image."""
|
||||||
return self.server.url(self.grandparentThumb)
|
if self.grandparentThumb:
|
||||||
|
return self.server.url(self.grandparentThumb)
|
||||||
|
|
||||||
def season(self):
|
def season(self):
|
||||||
"""Return this episode Season"""
|
"""Return this episode Season"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue