From b9cb7102c44badcbbb0812126e3849b86e715a03 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:58:55 -0800 Subject: [PATCH] Add plex_slug and plex_watch_url to nofication parameters --- plexpy/common.py | 2 ++ plexpy/notification_handler.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/plexpy/common.py b/plexpy/common.py index 59c8aeaa..d55674ea 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -557,6 +557,8 @@ NOTIFICATION_PARAMETERS = [ {'name': 'Poster URL', 'type': 'str', 'value': 'poster_url', 'description': 'A URL for the movie, TV show, or album poster.'}, {'name': 'Plex ID', 'type': 'str', 'value': 'plex_id', 'description': 'The Plex ID for the item.', 'example': 'e.g. 5d7769a9594b2b001e6a6b7e'}, {'name': 'Plex URL', 'type': 'str', 'value': 'plex_url', 'description': 'The Plex URL to your server for the item.'}, + {'name': 'Plex Slug', 'type': 'str', 'value': 'plex_slug', 'description': 'The Plex URL slug for the item.'}, + {'name': 'Plex Watch URL', 'type': 'str', 'value': 'plex_watch_url', 'description': 'The Plex URL to watch.plex.tv for the item.'}, {'name': 'IMDB ID', 'type': 'str', 'value': 'imdb_id', 'description': 'The IMDB ID for the movie or TV show.', 'example': 'e.g. tt2488496'}, {'name': 'IMDB URL', 'type': 'str', 'value': 'imdb_url', 'description': 'The IMDB URL for the movie or TV show.'}, {'name': 'TVDB ID', 'type': 'int', 'value': 'thetvdb_id', 'description': 'The TVDB ID for the movie or TV show.', 'example': 'e.g. 121361'}, diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 4afd8638..56ac9df6 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -824,16 +824,19 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m poster_thumb = notify_params['thumb'] poster_key = notify_params['rating_key'] poster_title = notify_params['title'] + plex_slug = notify_params['slug'] elif notify_params['media_type'] in ('season', 'album'): poster_thumb = notify_params['thumb'] or notify_params['parent_thumb'] poster_key = notify_params['rating_key'] poster_title = '%s - %s' % (notify_params['parent_title'], notify_params['title']) + plex_slug = notify_params['parent_slug'] elif notify_params['media_type'] in ('episode', 'track'): poster_thumb = notify_params['parent_thumb'] or notify_params['grandparent_thumb'] poster_key = notify_params['parent_rating_key'] poster_title = '%s - %s' % (notify_params['grandparent_title'], notify_params['parent_title']) + plex_slug = notify_params['grandparent_slug'] elif notify_params['media_type'] == 'clip': if notify_params['extra_type']: poster_thumb = notify_params['art'].replace('/art', '/thumb') or notify_params['thumb'] @@ -841,10 +844,19 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m poster_thumb = notify_params['parent_thumb'] or notify_params['thumb'] poster_key = notify_params['rating_key'] poster_title = notify_params['title'] + plex_slug = notify_params['slug'] else: poster_thumb = '' poster_key = '' poster_title = '' + plex_slug = '' + + if notify_params['media_type'] == 'movie': + plex_watch_url = f'https://watch.plex.tv/movie/{plex_slug}' + elif notify_params['media_type'] in ('show', 'season', 'episode'): + plex_watch_url = f'https://watch.plex.tv/show/{plex_slug}' + else: + plex_watch_url = '' img_service = helpers.get_img_service(include_self=True) fallback = 'poster-live' if notify_params['live'] else 'poster' @@ -1154,6 +1166,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m 'poster_url': notify_params['poster_url'], 'plex_id': notify_params['plex_id'], 'plex_url': notify_params['plex_url'], + 'plex_slug': plex_slug, + 'plex_watch_url': plex_watch_url, 'imdb_id': notify_params['imdb_id'], 'imdb_url': notify_params['imdb_url'], 'thetvdb_id': notify_params['thetvdb_id'],