Skip to content

Commit c3e16b2

Browse files
authored
Merge pull request #388 from pkkid/conversions
conversions
2 parents ddcc6dc + 6aca1e5 commit c3e16b2

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

plexapi/media.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,61 @@ def _loadData(self, data):
349349
self.width = cast(int, data.attrib.get('width'))
350350

351351

352+
@utils.registerPlexObject
353+
class Optimized(PlexObject):
354+
""" Represents a Optimized item. """
355+
TAG = 'Item'
356+
357+
def _loadData(self, data):
358+
self._data = data
359+
self.id = data.attrib.get('id')
360+
self.composite = data.attrib.get('composite')
361+
self.title = data.attrib.get('title')
362+
self.type = data.attrib.get('type')
363+
self.target = data.attrib.get('target')
364+
self.targetTagID = data.attrib.get('targetTagID')
365+
366+
367+
@utils.registerPlexObject
368+
class Conversion(PlexObject):
369+
""" Represents a Conversion item. """
370+
TAG = 'Video'
371+
372+
def _loadData(self, data):
373+
self._data = data
374+
self.addedAt = data.attrib.get('addedAt')
375+
self.art = data.attrib.get('art')
376+
self.chapterSource = data.attrib.get('chapterSource')
377+
self.contentRating = data.attrib.get('contentRating')
378+
self.duration = data.attrib.get('duration')
379+
self.generatorID = data.attrib.get('generatorID')
380+
self.generatorType = data.attrib.get('generatorType')
381+
self.guid = data.attrib.get('guid')
382+
self.key = data.attrib.get('key')
383+
self.lastViewedAt = data.attrib.get('lastViewedAt')
384+
self.librarySectionID = data.attrib.get('librarySectionID')
385+
self.librarySectionKey = data.attrib.get('librarySectionKey')
386+
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
387+
self.originallyAvailableAt = data.attrib.get('originallyAvailableAt')
388+
self.playQueueItemID = data.attrib.get('playQueueItemID')
389+
self.playlistID = data.attrib.get('playlistID')
390+
self.primaryExtraKey = data.attrib.get('primaryExtraKey')
391+
self.rating = data.attrib.get('rating')
392+
self.ratingKey = data.attrib.get('ratingKey')
393+
self.studio = data.attrib.get('studio')
394+
self.summary = data.attrib.get('summary')
395+
self.tagline = data.attrib.get('tagline')
396+
self.target = data.attrib.get('target')
397+
self.thumb = data.attrib.get('thumb')
398+
self.title = data.attrib.get('title')
399+
self.type = data.attrib.get('type')
400+
self.updatedAt = data.attrib.get('updatedAt')
401+
self.userID = data.attrib.get('userID')
402+
self.username = data.attrib.get('username')
403+
self.viewOffset = data.attrib.get('viewOffset')
404+
self.year = data.attrib.get('year')
405+
406+
352407
class MediaTag(PlexObject):
353408
""" Base class for media tags used for filtering and searching your library
354409
items or navigating the metadata of media items in your library. Tags are

plexapi/server.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from plexapi.playlist import Playlist
1414
from plexapi.playqueue import PlayQueue
1515
from plexapi.utils import cast
16+
from plexapi.media import Optimized, Conversion
1617

1718
# Need these imports to populate utils.PLEXOBJECTS
1819
from plexapi import (audio as _audio, video as _video, # noqa: F401
@@ -372,6 +373,17 @@ def playlist(self, title):
372373
"""
373374
return self.fetchItem('/playlists', title=title)
374375

376+
def optimizedItems(self):
377+
""" Returns list of all :class:`~plexapi.media.Optimized` objects connected to server. """
378+
379+
backgroundProcessing = self.fetchItem('/playlists?type=42')
380+
return self.fetchItems('%s/items' % backgroundProcessing.key, cls=Optimized)
381+
382+
def conversions(self):
383+
""" Returns list of all :class:`~plexapi.media.Conversion` objects connected to server. """
384+
385+
return self.fetchItems('/playQueues/1', cls=Conversion)
386+
375387
def query(self, key, method=None, headers=None, timeout=None, **kwargs):
376388
""" Main method used to handle HTTPS requests to the Plex server. This method helps
377389
by encoding the response to utf-8 and parsing the returned XML into and

0 commit comments

Comments
 (0)