Merge pull request #88 from Hellowlol/omg

Fix all, fix thumb.
This commit is contained in:
Hellowlol 2017-01-02 22:53:01 +01:00 committed by GitHub
commit 04d2a4b6d7
4 changed files with 45 additions and 13 deletions

View file

@ -64,7 +64,8 @@ class Audio(PlexPartialObject):
@property
def thumbUrl(self):
"""Return url to thumb image."""
return self.server.url(self.thumb)
if self.thumb:
return self.server.url(self.thumb)
def refresh(self):
"""Refresh the metadata."""
@ -308,7 +309,8 @@ class Track(Audio, Playable):
@property
def thumbUrl(self):
"""Return url to thumb image."""
return self.server.url(self.parentThumb)
if self.parentThumb:
return self.server.url(self.parentThumb)
def album(self):
"""Return this track's Album."""

View file

@ -52,7 +52,8 @@ class Library(object):
return self._sectionsByID[sectionID]
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):
return utils.listItems(self.server, '/library/onDeck')

View file

@ -236,6 +236,28 @@ class PlexServer(object):
return '%s%s%sX-Plex-Token=%s' % (self.baseurl, path, delim, self.token)
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):
"""This is the locally cached MyPlex account information.
@ -264,8 +286,8 @@ class Account(object):
"""Set attrs.
Args:
server (Plexclient):
data (xml.etree.ElementTree.Element): used to set the class attributes.
server (Plexclient):
data (xml.etree.ElementTree.Element): used to set the class attributes.
"""
self.authToken = data.attrib.get('authToken')
self.username = data.attrib.get('username')

View file

@ -44,7 +44,8 @@ class Video(PlexPartialObject):
@property
def thumbUrl(self):
"""Return url to thumb image."""
return self.server.url(self.thumb)
if self.thumb:
return self.server.url(self.thumb)
def analyze(self):
"""The primary purpose of media analysis is to gather information about
@ -169,11 +170,11 @@ class Show(Video):
self.viewedLeafCount = utils.cast(
int, data.attrib.get('viewedLeafCount', NA))
self.year = utils.cast(int, data.attrib.get('year', NA))
if self.isFullObject():
self.genres = [media.Genre(self.server, e)
for e in data if e.tag == media.Genre.TYPE]
self.roles = [media.Role(self.server, e)
for e in data if e.tag == media.Role.TYPE]
#if self.isFullObject(): # will be fixed with docs.
self.genres = [media.Genre(self.server, e)
for e in data if e.tag == media.Genre.TYPE]
self.roles = [media.Role(self.server, e)
for e in data if e.tag == media.Role.TYPE]
@property
def actors(self):
@ -263,6 +264,11 @@ class Season(Video):
Args:
watched (bool): Defaults to None. Exclude watched episodes
Returns:
list: of Episode
"""
childrenKey = '/library/metadata/%s/children' % self.ratingKey
return utils.listItems(self.server, childrenKey, watched=watched)
@ -280,7 +286,7 @@ class Season(Video):
return utils.findItem(self.server, path, title)
def get(self, title):
"""Get a episode witha mathcing title
"""Get a episode witha matching title
Args:
title (str): fx Secret santa
@ -368,7 +374,8 @@ class Episode(Video, Playable):
@property
def thumbUrl(self):
"""Return url to thumb image."""
return self.server.url(self.grandparentThumb)
if self.grandparentThumb:
return self.server.url(self.grandparentThumb)
def season(self):
"""Return this episode Season"""