Add custom Plex Web URL override for track, photo, and playlist

This commit is contained in:
JonnyWong16 2021-08-02 20:37:29 -07:00
parent 0811e5334c
commit 9483e4d9c9
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 36 additions and 0 deletions

View file

@ -415,3 +415,12 @@ class Track(Audio, Playable, ArtUrlMixin, PosterUrlMixin, RatingMixin,
def _defaultSyncTitle(self):
""" Returns str, default title for a new syncItem. """
return '%s - %s - %s' % (self.grandparentTitle, self.parentTitle, self.title)
def getWebURL(self, base=None):
""" Returns the Plex Web URL for the track's album.
Parameters:
base (str): The base URL before the fragment (``#!``).
Default is https://app.plex.tv/desktop.
"""
return self._buildWebURL(base=base, key=self.parentKey)

View file

@ -137,6 +137,15 @@ class Photoalbum(PlexPartialObject, ArtMixin, PosterMixin, RatingMixin):
filepaths.append(filepath)
return filepaths
def getWebURL(self, base=None):
""" Returns the Plex Web URL for the photoalbum.
Parameters:
base (str): The base URL before the fragment (``#!``).
Default is https://app.plex.tv/desktop.
"""
return self._buildWebURL(base=base, legacy=True)
@utils.registerPlexObject
class Photo(PlexPartialObject, Playable, ArtUrlMixin, PosterUrlMixin, RatingMixin, TagMixin):
@ -301,3 +310,12 @@ class Photo(PlexPartialObject, Playable, ArtUrlMixin, PosterUrlMixin, RatingMixi
if filepath:
filepaths.append(filepath)
return filepaths
def getWebURL(self, base=None):
""" Returns the Plex Web URL for the photo's photoalbum.
Parameters:
base (str): The base URL before the fragment (``#!``).
Default is https://app.plex.tv/desktop.
"""
return self._buildWebURL(base=base, key=self.parentKey, legacy=True)

View file

@ -459,3 +459,12 @@ class Playlist(PlexPartialObject, Playable, ArtMixin, PosterMixin, SmartFilterMi
raise Unsupported('Unsupported playlist content')
return myplex.sync(sync_item, client=client, clientId=clientId)
def getWebURL(self, base=None):
""" Returns the Plex Web URL for the playlist.
Parameters:
base (str): The base URL before the fragment (``#!``).
Default is https://app.plex.tv/desktop.
"""
return self._buildWebURL(base=base, endpoint='playlist')