Skip to content

Commit 9d9dca8

Browse files
glenscJonnyWong16
andauthored
Feature: Add source property to playlist items to support remote playlist entries (#1335)
* Add source property to Video A Playlist entry if added a remote server item has field "source" initialized with value like `server://<server_id>/com.plexapp.plugins.library` * Add source to Episode * Fix flake8 error E261 at least two spaces before inline comment * Add source to Track * Add source to Photo * Rename the field to sourceURI * Update plexapi/audio.py Co-authored-by: JonnyWong16 <[email protected]> * Update plexapi/photo.py Co-authored-by: JonnyWong16 <[email protected]> * Update plexapi/video.py Co-authored-by: JonnyWong16 <[email protected]> * Update plexapi/video.py Co-authored-by: JonnyWong16 <[email protected]> * Fix flake line length issue --------- Co-authored-by: JonnyWong16 <[email protected]>
1 parent 284a577 commit 9d9dca8

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

plexapi/audio.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ class Track(
450450
primaryExtraKey (str) API URL for the primary extra for the track.
451451
ratingCount (int): Number of listeners who have scrobbled this track, as reported by Last.fm.
452452
skipCount (int): Number of times the track has been skipped.
453+
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
454+
(remote playlist item only).
453455
viewOffset (int): View offset in milliseconds.
454456
year (int): Year the track was released.
455457
"""
@@ -485,6 +487,7 @@ def _loadData(self, data):
485487
self.primaryExtraKey = data.attrib.get('primaryExtraKey')
486488
self.ratingCount = utils.cast(int, data.attrib.get('ratingCount'))
487489
self.skipCount = utils.cast(int, data.attrib.get('skipCount'))
490+
self.sourceURI = data.attrib.get('source') # remote playlist item
488491
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
489492
self.year = utils.cast(int, data.attrib.get('year'))
490493

plexapi/photo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class Photo(
180180
parentThumb (str): URL to photo album thumbnail image (/library/metadata/<parentRatingKey>/thumb/<thumbid>).
181181
parentTitle (str): Name of the photo album for the photo.
182182
ratingKey (int): Unique key identifying the photo.
183+
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
184+
(remote playlist item only).
183185
summary (str): Summary of the photo.
184186
tags (List<:class:`~plexapi.media.Tag`>): List of tag objects.
185187
thumb (str): URL to thumbnail image (/library/metadata/<ratingKey>/thumb/<thumbid>).
@@ -218,6 +220,7 @@ def _loadData(self, data):
218220
self.parentThumb = data.attrib.get('parentThumb')
219221
self.parentTitle = data.attrib.get('parentTitle')
220222
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
223+
self.sourceURI = data.attrib.get('source') # remote playlist item
221224
self.summary = data.attrib.get('summary')
222225
self.tags = self.findItems(data, media.Tag)
223226
self.thumb = data.attrib.get('thumb')

plexapi/video.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ class Movie(
370370
roles (List<:class:`~plexapi.media.Role`>): List of role objects.
371371
slug (str): The clean watch.plex.tv URL identifier for the movie.
372372
similar (List<:class:`~plexapi.media.Similar`>): List of Similar objects.
373+
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
374+
(remote playlist item only).
373375
studio (str): Studio that created movie (Di Bonaventura Pictures; 21 Laps Entertainment).
374376
tagline (str): Movie tag line (Back 2 Work; Who says men can't change?).
375377
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
@@ -414,6 +416,7 @@ def _loadData(self, data):
414416
self.roles = self.findItems(data, media.Role)
415417
self.slug = data.attrib.get('slug')
416418
self.similar = self.findItems(data, media.Similar)
419+
self.sourceURI = data.attrib.get('source') # remote playlist item
417420
self.studio = data.attrib.get('studio')
418421
self.tagline = data.attrib.get('tagline')
419422
self.theme = data.attrib.get('theme')
@@ -905,6 +908,8 @@ class Episode(
905908
ratings (List<:class:`~plexapi.media.Rating`>): List of rating objects.
906909
roles (List<:class:`~plexapi.media.Role`>): List of role objects.
907910
skipParent (bool): True if the show's seasons are set to hidden.
911+
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
912+
(remote playlist item only).
908913
viewOffset (int): View offset in milliseconds.
909914
writers (List<:class:`~plexapi.media.Writer`>): List of writers objects.
910915
year (int): Year the episode was released.
@@ -948,6 +953,7 @@ def _loadData(self, data):
948953
self.ratings = self.findItems(data, media.Rating)
949954
self.roles = self.findItems(data, media.Role)
950955
self.skipParent = utils.cast(bool, data.attrib.get('skipParent', '0'))
956+
self.sourceURI = data.attrib.get('source') # remote playlist item
951957
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
952958
self.writers = self.findItems(data, media.Writer)
953959
self.year = utils.cast(int, data.attrib.get('year'))

0 commit comments

Comments
 (0)