mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
more update shit
This commit is contained in:
parent
67468578bf
commit
43cb60d440
2 changed files with 45 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
from plexapi import log, utils
|
||||
from plexapi.compat import quote_plus, urlencode
|
||||
from plexapi.exceptions import BadRequest, NotFound, UnknownType, Unsupported
|
||||
|
@ -452,3 +453,17 @@ class Playable(object):
|
|||
""" Stop playback for a media item. """
|
||||
key = '/status/sessions/terminate?sessionId=%s&reason=%s' % (self.session[0].id, quote_plus(reason))
|
||||
return self._server.query(key)
|
||||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Release(PlexObject):
|
||||
TAG = 'Release'
|
||||
key = '/updater/status'
|
||||
|
||||
def _loadData(self, data):
|
||||
self.download_key = data.attrib.get('key')
|
||||
self.version = data.attrib.get('version')
|
||||
self.added = data.attrib.get('added')
|
||||
self.fixed = data.attrib.get('fixed')
|
||||
self.downloadURL = data.attrib.get('downloadURL')
|
||||
self.state = data.attrib.get('state')
|
||||
|
|
|
@ -278,12 +278,37 @@ class PlexServer(PlexObject):
|
|||
filepath = utils.download(url, None, savepath, self._session, unpack=unpack)
|
||||
return filepath
|
||||
|
||||
def isLatest(self):
|
||||
return self.query('/updater/status') # get
|
||||
def check_for_update(self, force=True, download=False):
|
||||
"""Get release info.
|
||||
|
||||
def canUpdate(self): # fix names, it just so i dont forget.
|
||||
# check plexpass
|
||||
return self.query('/updater/check?download=0') # put
|
||||
Parameters:
|
||||
force (bool): Force server to check for new releases
|
||||
download (bool): Download if a update is available.
|
||||
|
||||
Returns: :class:`~plexapi.base.Release` object.
|
||||
|
||||
"""
|
||||
part = '/updater/check?download=%s' % (1 if download else 0)
|
||||
if force:
|
||||
self.query(part, method=self._session.put)
|
||||
return self.fetchItem('/updater/status')
|
||||
|
||||
def isLatest(self):
|
||||
"""Check if the installed version of PMS is the latest.
|
||||
Returns: bool
|
||||
"""
|
||||
release = self.check_for_update(force=True)
|
||||
return bool(release.version == self.version)
|
||||
|
||||
def installUpdate(self):
|
||||
# We can add this but dunno how usefull this is since it sometimes requires user
|
||||
# action using a gui.
|
||||
part = 'updater/apply'
|
||||
|
||||
release = self.check_for_update(force=True, download=True)
|
||||
if release and release.version != pms.version:
|
||||
# figure out what method this is..
|
||||
return self.query(part, method=self._session.put)
|
||||
|
||||
def history(self):
|
||||
""" Returns a list of media items from watched history. """
|
||||
|
|
Loading…
Reference in a new issue