import new Conversion class and return active Conversions

This commit is contained in:
blacktwin 2019-10-10 11:12:34 -04:00
parent c29563632b
commit 45df6b57cf

View file

@ -13,7 +13,7 @@ from plexapi.settings import Settings
from plexapi.playlist import Playlist from plexapi.playlist import Playlist
from plexapi.playqueue import PlayQueue from plexapi.playqueue import PlayQueue
from plexapi.utils import cast from plexapi.utils import cast
from plexapi.media import Optimized from plexapi.media import Optimized, Conversion
# Need these imports to populate utils.PLEXOBJECTS # Need these imports to populate utils.PLEXOBJECTS
from plexapi import (audio as _audio, video as _video, # noqa: F401 from plexapi import (audio as _audio, video as _video, # noqa: F401
@ -376,6 +376,18 @@ class PlexServer(PlexObject):
return items return items
def conversions(self):
""" Returns list of all :class:`~plexapi.media.Conversion` objects connected to server. """
items = []
backgroundProcessing = self.query('/playQueues?type=42')
for elem in backgroundProcessing:
key = elem.attrib.get('id')
for elem in self.query('/playQueues/%s' % key):
items.append(Conversion(server=self, data=elem))
return items
def query(self, key, method=None, headers=None, timeout=None, **kwargs): def query(self, key, method=None, headers=None, timeout=None, **kwargs):
""" Main method used to handle HTTPS requests to the Plex server. This method helps """ Main method used to handle HTTPS requests to the Plex server. This method helps
by encoding the response to utf-8 and parsing the returned XML into and by encoding the response to utf-8 and parsing the returned XML into and