Skip to content

Commit b831aae

Browse files
authored
Add slug attributes to Movie, Show, Season, and Episode (#1317)
* Add slug attributes to videos * Add tests for slug attributes
1 parent 6e4ef6b commit b831aae

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

plexapi/video.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ class Movie(
368368
ratingImage (str): Key to critic rating image (rottentomatoes://image.rating.rotten).
369369
ratings (List<:class:`~plexapi.media.Rating`>): List of rating objects.
370370
roles (List<:class:`~plexapi.media.Role`>): List of role objects.
371+
slug (str): The clean watch.plex.tv URL identifier for the movie.
371372
similar (List<:class:`~plexapi.media.Similar`>): List of Similar objects.
372373
studio (str): Studio that created movie (Di Bonaventura Pictures; 21 Laps Entertainment).
373374
tagline (str): Movie tag line (Back 2 Work; Who says men can't change?).
@@ -411,6 +412,7 @@ def _loadData(self, data):
411412
self.ratingImage = data.attrib.get('ratingImage')
412413
self.ratings = self.findItems(data, media.Rating)
413414
self.roles = self.findItems(data, media.Role)
415+
self.slug = data.attrib.get('slug')
414416
self.similar = self.findItems(data, media.Similar)
415417
self.studio = data.attrib.get('studio')
416418
self.tagline = data.attrib.get('tagline')
@@ -531,6 +533,7 @@ class Show(
531533
(None = Library default, tmdbAiring = The Movie Database (Aired),
532534
aired = TheTVDB (Aired), dvd = TheTVDB (DVD), absolute = TheTVDB (Absolute)).
533535
similar (List<:class:`~plexapi.media.Similar`>): List of Similar objects.
536+
slug (str): The clean watch.plex.tv URL identifier for the show.
534537
studio (str): Studio that created show (Di Bonaventura Pictures; 21 Laps Entertainment).
535538
subtitleLanguage (str): Setting that indicates the preferred subtitle language.
536539
subtitleMode (int): Setting that indicates the auto-select subtitle mode.
@@ -580,6 +583,7 @@ def _loadData(self, data):
580583
self.seasonCount = utils.cast(int, data.attrib.get('seasonCount', self.childCount))
581584
self.showOrdering = data.attrib.get('showOrdering')
582585
self.similar = self.findItems(data, media.Similar)
586+
self.slug = data.attrib.get('slug')
583587
self.studio = data.attrib.get('studio')
584588
self.subtitleLanguage = data.attrib.get('subtitleLanguage', '')
585589
self.subtitleMode = utils.cast(int, data.attrib.get('subtitleMode', '-1'))
@@ -717,6 +721,7 @@ class Season(
717721
parentIndex (int): Plex index number for the show.
718722
parentKey (str): API URL of the show (/library/metadata/<parentRatingKey>).
719723
parentRatingKey (int): Unique key identifying the show.
724+
parentSlug (str): The clean watch.plex.tv URL identifier for the show.
720725
parentStudio (str): Studio that created show.
721726
parentTheme (str): URL to show theme resource (/library/metadata/<parentRatingkey>/theme/<themeid>).
722727
parentThumb (str): URL to show thumbnail image (/library/metadata/<parentRatingKey>/thumb/<thumbid>).
@@ -746,6 +751,7 @@ def _loadData(self, data):
746751
self.parentIndex = utils.cast(int, data.attrib.get('parentIndex'))
747752
self.parentKey = data.attrib.get('parentKey')
748753
self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey'))
754+
self.parentSlug = data.attrib.get('parentSlug')
749755
self.parentStudio = data.attrib.get('parentStudio')
750756
self.parentTheme = data.attrib.get('parentTheme')
751757
self.parentThumb = data.attrib.get('parentThumb')
@@ -877,6 +883,7 @@ class Episode(
877883
grandparentGuid (str): Plex GUID for the show (plex://show/5d9c086fe9d5a1001f4d9fe6).
878884
grandparentKey (str): API URL of the show (/library/metadata/<grandparentRatingKey>).
879885
grandparentRatingKey (int): Unique key identifying the show.
886+
grandparentSlug (str): The clean watch.plex.tv URL identifier for the show.
880887
grandparentTheme (str): URL to show theme resource (/library/metadata/<grandparentRatingkey>/theme/<themeid>).
881888
grandparentThumb (str): URL to show thumbnail image (/library/metadata/<grandparentRatingKey>/thumb/<thumbid>).
882889
grandparentTitle (str): Name of the show for the episode.
@@ -922,6 +929,7 @@ def _loadData(self, data):
922929
self.grandparentGuid = data.attrib.get('grandparentGuid')
923930
self.grandparentKey = data.attrib.get('grandparentKey')
924931
self.grandparentRatingKey = utils.cast(int, data.attrib.get('grandparentRatingKey'))
932+
self.grandparentSlug = data.attrib.get('grandparentSlug')
925933
self.grandparentTheme = data.attrib.get('grandparentTheme')
926934
self.grandparentThumb = data.attrib.get('grandparentThumb')
927935
self.grandparentTitle = data.attrib.get('grandparentTitle')

tests/test_video.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def test_video_Movie_attrs(movies):
9292
assert utils.is_metadata(movie.primaryExtraKey)
9393
assert movie.ratingKey >= 1
9494
assert movie._server._baseurl == utils.SERVER_BASEURL
95+
assert movie.slug == "sita-sings-the-blues"
9596
assert movie.studio == "Nina Paley"
9697
assert utils.is_string(movie.summary, gte=100)
9798
assert movie.tagline == "The Greatest Break-Up Story Ever Told."
@@ -788,6 +789,7 @@ def test_video_Show_attrs(show):
788789
assert show._server._baseurl == utils.SERVER_BASEURL
789790
assert utils.is_int(show.seasonCount)
790791
assert show.showOrdering in (None, 'aired')
792+
assert show.slug == "game-of-thrones"
791793
assert show.studio == "Revolution Sun Studios"
792794
assert utils.is_string(show.summary, gte=100)
793795
assert show.subtitleLanguage == ''
@@ -1006,6 +1008,7 @@ def test_video_Season_attrs(show):
10061008
assert season.parentIndex == 1
10071009
assert utils.is_metadata(season.parentKey)
10081010
assert utils.is_int(season.parentRatingKey)
1011+
assert season.parentSlug == "game-of-thrones"
10091012
assert season.parentStudio == "Revolution Sun Studios"
10101013
assert utils.is_metadata(season.parentTheme)
10111014
if season.parentThumb:
@@ -1182,6 +1185,7 @@ def test_video_Episode_attrs(episode):
11821185
assert episode.grandparentGuid == "plex://show/5d9c086c46115600200aa2fe"
11831186
assert utils.is_metadata(episode.grandparentKey)
11841187
assert utils.is_int(episode.grandparentRatingKey)
1188+
assert episode.grandparentSlug == "game-of-thrones"
11851189
assert utils.is_metadata(episode.grandparentTheme)
11861190
if episode.grandparentThumb:
11871191
assert utils.is_thumb(episode.grandparentThumb)

0 commit comments

Comments
 (0)