class Playlist(Descriptor): composite = Property key = Property type = Property playlist_type = Property('playlistType') guid = Property rating_key = Property('ratingKey') title = Property title_sort = Property('titleSort') summary = Property duration = Property(type=int) duration_seconds = Property('durationInSeconds', int) rating_count = Property('ratingCount', int) view_count = Property('viewCount', int) leaf_count = Property('leafCount', int) smart = Property(type=(int, bool)) added_at = Property('addedAt', int) last_viewed_at = Property('lastViewedAt', int) updated_at = Property('updatedAt', int) def add(self, item_uri): return Plex['playlists/*/items'].add(self.rating_key, item_uri=item_uri) def delete(self): return Plex['playlists'].delete(self.rating_key) def items(self, include_related=None, start=None, size=None): return Plex['playlists/*/items'].all(self.rating_key, include_related=include_related, start=start, size=size) def move(self, item_id, after=None): return Plex['playlists/*/items'].move(self.rating_key, item_id=item_id, after=after) def remove(self, item_id): return Plex['playlists/*/items'].remove(self.rating_key, item_id=item_id) def update(self, title=None, summary=None): return Plex['library/metadata'].update(self.rating_key, title=title, summary=summary)
class Detail(Container): myplex = Property(resolver=lambda: Detail.construct_myplex) transcoder = Property(resolver=lambda: Detail.construct_transcoder) friendly_name = Property('friendlyName') machine_identifier = Property('machineIdentifier') version = Property platform = Property platform_version = Property('platformVersion') allow_camera_upload = Property('allowCameraUpload', (int, bool)) allow_channel_access = Property('allowChannelAccess', (int, bool)) allow_media_deletion = Property('allowMediaDeletion', (int, bool)) allow_sharing = Property('allowSharing', (int, bool)) allow_sync = Property('allowSync', (int, bool)) background_processing = Property('backgroundProcessing', (int, bool)) companion_proxy = Property('companionProxy', (int, bool)) event_stream = Property('eventStream', (int, bool)) hub_search = Property('hubSearch', (int, bool)) plugin_host = Property('pluginHost', (int, bool)) read_only_libraries = Property('readOnlyLibraries', (int, bool)) updater = Property('updater', (int, bool)) certificate = Property(type=(int, bool)) multiuser = Property(type=(int, bool)) owner_features = Property('ownerFeatures') sync = Property(type=(int, bool)) start_state = Property('startState') silverlight = Property('silverlightInstalled', (int, bool)) soundflower = Property('soundflowerInstalled', (int, bool)) flash = Property('flashInstalled', (int, bool)) webkit = Property(type=(int, bool)) cookie_parameters = Property('requestParametersInCookie', (int, bool)) @staticmethod def construct_myplex(client, node): return MyPlexDetail.construct(client, node, child=True) @staticmethod def construct_transcoder(client, node): return TranscoderDetail.construct(client, node, child=True)
class Stream(Descriptor): id = Property(type=int) index = Property(type=int) stream_type = Property('streamType', int) selected = Property(type=bool) title = Property duration = Property(type=(float, int)) language = Property language_code = Property('languageCode') codec = Property codec_id = Property('codecID') bit_depth = Property('bitDepth', int) chroma_subsampling = Property('chromaSubsampling') color_space = Property('colorSpace') width = Property(type=int) height = Property(type=int) bitrate = Property(type=int) bitrate_mode = Property('bitrateMode') channels = Property(type=int) sampling_rate = Property('samplingRate', int) frame_rate = Property('frameRate') profile = Property scan_type = Property('scanType') bvop = Property(type=int) gmc = Property(type=int) level = Property qpel = Property(type=int) @classmethod def from_node(cls, client, node): items = [] for genre in cls.helpers.findall(node, 'Stream'): _, obj = Stream.construct(client, genre, child=True) items.append(obj) return [], items
class Detail(Container): myplex = Property(resolver=lambda: Detail.construct_myplex) transcoder = Property(resolver=lambda: Detail.construct_transcoder) friendly_name = Property('friendlyName') machine_identifier = Property('machineIdentifier') version = Property platform = Property platform_version = Property('platformVersion') allow_camera_upload = Property('allowCameraUpload', [int, bool]) allow_channel_access = Property('allowChannelAccess', [int, bool]) allow_sync = Property('allowSync', [int, bool]) certificate = Property(type=[int, bool]) multiuser = Property(type=[int, bool]) sync = Property(type=[int, bool]) start_state = Property('startState') silverlight = Property('silverlightInstalled', [int, bool]) soundflower = Property('soundflowerInstalled', [int, bool]) flash = Property('flashInstalled', [int, bool]) webkit = Property(type=[int, bool]) cookie_parameters = Property('requestParametersInCookie', [int, bool]) @staticmethod def construct_myplex(client, node): return MyPlexDetail.construct(client, node, child=True) @staticmethod def construct_transcoder(client, node): return TranscoderDetail.construct(client, node, child=True)
class Media(Descriptor): parts = Property(resolver=lambda: Part.from_node) id = Property(type=int) video_codec = Property('videoCodec') video_frame_rate = Property('videoFrameRate') video_resolution = Property('videoResolution') audio_channels = Property('audioChannels', type=int) audio_codec = Property('audioCodec') container = Property width = Property(type=int) height = Property(type=int) aspect_ratio = Property('aspectRatio', type=float) bitrate = Property(type=int) duration = Property(type=int) #@classmethod #def from_node(cls, client, node): # return cls.construct(client, cls.helpers.find(node, 'Media'), child=True) @classmethod def from_node(cls, client, node): items = [] for genre in cls.helpers.findall(node, 'Media'): _, obj = Media.construct(client, genre, child=True) items.append(obj) return [], items
class Clip(Video, Metadata): extra_type = Property('extraType', type=int) index = Property(type=int)
class Metadata(Descriptor): section = Property(resolver=lambda: Metadata.construct_section) key = Property guid = Property rating_key = Property('ratingKey') extra_key = Property('primaryExtraKey') title = Property title_sort = Property('titleSort') title_sort_saved = Property('titleSortSaved') title_original = Property('originalTitle') audience_rating = Property('audienceRating', float) audience_rating_image = Property('audienceRatingImage') content_rating = Property('contentRating') content_rating_age = Property('contentRatingAge', int) rating = Property(type=float) rating_count = Property('ratingCount') rating_image = Property('ratingImage') studio = Property summary = Property tagline = Property year = Property(type=int) thumb = Property source_icon = Property('sourceIcon') source_title = Property('sourceTitle') url = Property('url') deferred = Property(type=(int, bool)) added_at = Property('addedAt', int) created_at_accuracy = Property('createdAtAccuracy') created_at_tzoffset = Property('createdAtTZOffset', int) deleted_at = Property('deletedAt', int) first_scan_added_at = Property('firstScanAddedAt', int) last_viewed_at = Property('lastViewedAt', int) originally_available_at = Property('originallyAvailableAt') @staticmethod def construct_section(client, node): attribute_map = { 'key': 'librarySectionID', 'id': 'librarySectionID', 'uuid': 'librarySectionUUID', 'path': 'librarySectionKey', 'title': 'librarySectionTitle' } return Section.construct(client, node, attribute_map, child=True)
class MediaContainer(Container): section = Property(resolver=lambda: MediaContainer.construct_section) title1 = Property title2 = Property identifier = Property art = Property thumb = Property view_group = Property('viewGroup') view_mode = Property('viewMode', int) leaf_count_added = Property('leafCountAdded', int) leaf_count_requested = Property('leafCountRequested', int) media_tag_prefix = Property('mediaTagPrefix') media_tag_version = Property('mediaTagVersion') allow_sync = Property('allowSync', bool) mixed_parents = Property('mixedParents', bool) no_cache = Property('nocache', bool) sort_asc = Property('sortAsc', bool) @staticmethod def construct_section(client, node): attribute_map = { 'key': 'librarySectionID', 'uuid': 'librarySectionUUID', 'title': 'librarySectionTitle' } return Section.construct(client, node, attribute_map, child=True) def __iter__(self): for item in super(MediaContainer, self).__iter__(): item.section = self.section yield item