jellyfin / jellyfin-plugin-webhook

GNU General Public License v3.0
141 stars 45 forks source link

template for Gotify, supports more notification types, with limitations #131

Open pdfrg opened 2 years ago

pdfrg commented 2 years ago

The included Gotify template is written only for adding items to the library. There is no code for for playback or other notifications. In addition, when cut and pasted directly into the webhook configuration, none of the provider links (imdb, tmdb, etc.) worked for me, even though I have those providers enabled in my settings. I searched github, reddit, etc. and found minimal if any usable templates. I am no programmer, just some guy who loves jellyfin and gotify and like to mess around with them. So I cobbled together my own template, which has been only minimally tested. For me, confirmed working for item added, playback start and stop notifications for both TV episodes and movies. Though I included cases for all notification types, I strongly advise that you do not enable "generic", "playback progress", or "user data saved" under webhook settings, because when these are enabled, redundant (generic) or continuous (playback progress, user data saved) notifications are produced. Probably there is some way to construct the template to avoid this behavior -- I don't know, haven't tried. I'm sure this is horribly inefficient and could be much improved. Again, no coding background here. It just works for me, at least better than the included template, so I thought perhaps someone might find it helpful. I know this may not be the place for it, but honestly I'm not sure where else to put it. I'm not going to learn how to fork the repository and make pull requests for something so simple. Thanks for reading. Any comments and/or improvements appreciated.

{
    "extras":{
        "client::display": {
            "contentType": "text/markdown"
        }
    },
    "message": "![](http://YOUR JELLYFIN SERVER ADDRESS:PORT HERE/Items/{{ItemId}}/Images/Primary)\n
    {{~#if_equals NotificationType 'ItemAdded'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) {{RunTime}}\n
        {{~/if_equals~}}    
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'Generic'~}}
        {{{Name}}} {{NotificationType}}, {{NotificationUsername}} {{ClientName}} on {{DeviceName}}\n {{! no documentation on generic notifications.  Redundant notifications if others enabled.  Recommend disabling in webhook settings}}  
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PlaybackStart'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) {{RunTime}}\n       
        {{~/if_equals~}}
    {{~/if_equals~}}   
    {{~#if_equals NotificationType 'PlaybackProgress'~}}  {{! WARNING: as is, outputs continuous notifications.  Recommend disabling under webhook settings pending rewrite.}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}, at {{PlaybackPosition}} out of {{RunTime}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) at {{PlaybackPosition}} out of {{RunTime}}\n
        {{~/if_equals~}}
    {{~/if_equals~}} 
    {{~#if_equals NotificationType 'PlaybackStop'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}})\n
        {{~/if_equals~}}
        {{~#if_equals PlayedToCompletion 'true'~}}
            was completed\n
        {{~/if_equals~}}
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'SubtitleDownloadFailure'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}})\n
        {{~/if_equals~}}       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationFailure'~}}
        {{ClientName}} on {{DeviceName}}, check server logs for details\n
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationSuccess'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'SessionStart'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PendingRestart'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'TaskCompleted'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n        
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationCancelled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationFailed'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details - server restart needed to apply\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalling'~}}
        {{ServerName}} {{ServerVersion}}, standby\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUninstalled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUpdated'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserCreated'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDeleted'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserLockedOut'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserPasswordChanged'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserUpdated'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDataSaved'~}}  {{! Outputs continuous notifications during playback.  Recommend disabling under webhook settings.}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    ",
    "priority": {{Priority}},
    {{~#if_equals NotificationType 'ItemAdded'~}}
            "title": "Item added to Jellyfin"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'Generic'~}}
            "title": "Jellyfin notification"  {{! unsure what a generic notification is, no documentation.  Outputs redundant notifications if others enabled.  Recommend disabling under webhook settings.}}    
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PlaybackStart'~}}
            "title": "{{NotificationUsername}} started playing, {{ClientName}} on {{DeviceName}}"       
    {{~/if_equals~}}   
    {{~#if_equals NotificationType 'PlaybackProgress'~}}  {{! WARNING: as is, outputs continuous notifications.  Recommend disabling in webhook settings pending rewrite.}}
            "title": "{{NotificationUsername}} is playing, {{ClientName}} on {{DeviceName}}"
    {{~/if_equals~}} 
    {{~#if_equals NotificationType 'PlaybackStop'~}}
            "title": "{{NotificationUsername}} stopped playing, {{ClientName}} on {{DeviceName}}"
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'SubtitleDownloadFailure'~}}
            "title": "Warning: Subtitle failed to download"       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationFailure'~}}
            "title": "Warning: {{NotificationUsername}} failed to authenticate"       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationSuccess'~}}
            "title": "{{NotificationUsername}} successfully logged on"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'SessionStart'~}}
            "title": "{{NotificationUsername}} now active"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PendingRestart'~}}
            "title": "Notice: Jellyfin server needs to be restarted" {{! unsure if needs manual restart, or just informing that restart is in process}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'TaskCompleted'~}}
            "title": "Jellyfin task complete" {{! no documentation on task types}} 
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationCancelled'~}}
            "title": "Plugin installation cancelled" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationFailed'~}}
            "title": "Plugin installation failed" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalled'~}}
            "title": "Plugin successfully installed" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalling'~}}
            "title": "Plugin is installing now" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUninstalled'~}}
            "title": "Plugin was removed successfully" {{! no documentation on plugin ID}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUpdated'~}}
            "title": "Plugin was successfully updated" {{! no documentation on plugin ID}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserCreated'~}}
            "title": "{{NotificationUsername}} was added successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDeleted'~}}
            "title": "{{NotificationUsername}} was deleted"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserLockedOut'~}}
            "title": "Warning: {{NotificationUsername}} was locked out"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserPasswordChanged'~}}
            "title": "{{NotificationUsername}} password changed successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserUpdated'~}}
            "title": "{{NotificationUsername}} was updated successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDataSaved'~}}  {{! Outputs continuous notifications during playback.  Recommend disabling under webhook settings.}}
            "title": "{{NotificationUsername}} data was saved"       
    {{~/if_equals~}}
}
pdfrg commented 2 years ago

OK, I have been working with the template, testing and enhancing. Now with working links to TMDB, IMDb, tvdb, and MusicBrainz where appropriate. Also with audio and video codec information, tagline and overview. Working notifications for audio playback, stop, and item added. Some work yet to do:

  1. See issue #132 - no album art available for audio playback notifications. Currently just gives artist, album, track name, duration, and codec. Album art is available for ItemAdded when ItemType = MusicAlbum. But when ItemType = Audio, the image link does not work. On webhook.site, I cannot use any of the available data to link to an image. Could use some help here.
  2. For ItemAdded notification, ItemType = MusicAlbum, Provider_musicbrainzartist and Provider_musicbrainzalbumartist are not returned. Also, no audio codec info is returned.
  3. When adding an album to the library, notifications for each individual track are generated, plus another notification for the album itself. For each individual track, ItemType = Audio, Provider_musicbrainzartist is returned, so link to the artist can be generated for each track. Plus codec info is available here. I think the preferred behavior would be to generate a single notification for adding an album, not a per track notification. If under plugin settings, I untick "songs", then when I play music, I don't get playback notifications either.
  4. When adding an album to the library, for an artist that does not already exist in the library, there is no is no ItemAdded notification for ItemType = MusicArtist.
  5. When stopping music playback, PlayedToCompletion is always true.
{
    "extras":{
        "client::display": {
            "contentType": "text/markdown"
        }
    },
    "message": "![](http://YOUR JELLYFIN SERVER ADDRESS:PORT HERE/Items/{{ItemId}}/Images/Primary)\n\n
    {{~#if_equals NotificationType 'ItemAdded'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=episode&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Season'~}}
            {{{SeriesName}}} Season {{SeasonNumber}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=series&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'Series'~}}
            {{{SeriesName}}}\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=series&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tmdb~}}
                [TMDB](https://www.themoviedb.org/movie/{{Provider_tmdb}})\n\n
            {{~/if_exist~}}    
            {{~#if_exist Provider_imdb~}}    
                [IMDb](https://www.imdb.com/title/{{Provider_imdb}}/)\n\n
            {{~/if_exist~}}    
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'MusicAlbum'~}}
            {{{Artist}}} - {{{Name}}} ({{Year}})\n\n{{RunTime}}\n\n
            {{~#if_exist Provider_musicbrainzreleasegroup~}}          
                [MusicBrainz Release Group](https://musicbrainz.org/release-group/{{Provider_musicbrainzreleasegroup}})\n\n
            {{~/if_exist~}}            
            {{~#if_exist Provider_musicbrainzalbum~}}          
                [MusicBrainz Album](https://musicbrainz.org/release/{{Provider_musicbrainzalbum}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
            {{{Name}}} - {{RunTime}}\n\n{{{Artist}}} - {{{Album}}} ({{Year}})\n\n{{Audio_0_Title}}\n\n
            {{~#if_exist Provider_musicbrainzartist~}}          
                [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'MusicArtist'~}}
            {{{Artist}}}\n\n
            {{~#if_exist Provider_musicbrainzartist~}}          
                [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'MusicVideo'~}}
            {{{Artist}}} - {{{Name}}} ({{Year}})\n\n
        {{~/if_equals~}}    
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'Generic'~}}
        {{{Name}}} {{NotificationType}}, {{NotificationUsername}} {{ClientName}} on {{DeviceName}}\n {{! no documentation on generic notifications.  Redundant notifications if others enabled.  Recommend disabling in webhook settings}}  
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PlaybackStart'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=episode&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}            
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tmdb~}}
                [TMDB](https://www.themoviedb.org/movie/{{Provider_tmdb}})\n\n
            {{~/if_exist~}}    
            {{~#if_exist Provider_imdb~}}    
                [IMDb](https://www.imdb.com/title/{{Provider_imdb}}/)\n\n
            {{~/if_exist~}}                
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
           {{{Name}}} {{RunTime}}\n\n{{{Artist}}} - {{{Album}}} ({{Year}})\n\n{{Audio_0_Title}}\n\n
                {{~#if_exist Provider_musicbrainzalbum~}}          
                    [MusicBrainz Album](https://musicbrainz.org/release/{{Provider_musicbrainzalbum}})\n\n
                {{~/if_exist~}}
                {{~#if_exist Provider_musicbrainzartist~}}   
                    [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
                {{~/if_exist~}}    
        {{~/if_equals~}}
    {{~/if_equals~}}   
    {{~#if_equals NotificationType 'PlaybackProgress'~}}  {{! WARNING: as is, outputs continuous notifications.  Recommend disabling under webhook settings pending rewrite.}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}, at {{PlaybackPosition}} out of {{RunTime}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) at {{PlaybackPosition}} out of {{RunTime}}\n
        {{~/if_equals~}}
    {{~/if_equals~}} 
    {{~#if_equals NotificationType 'PlaybackStop'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} {{RunTime}}\n\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}}) {{RunTime}}\n\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
           {{{Name}}} {{RunTime}}, {{{Artist}}} - {{{Album}}} ({{Year}})\n\n
        {{~/if_equals~}}
        {{~#if_equals PlayedToCompletion 'true'~}}
            was completed\n\n
        {{~else~}}
            was stopped at {{PlaybackPosition}}\n\n
        {{~/if_equals~}}
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'SubtitleDownloadFailure'~}}
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}})\n
        {{~/if_equals~}}       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationFailure'~}}
        {{ClientName}} on {{DeviceName}}, check server logs for details\n
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationSuccess'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'SessionStart'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PendingRestart'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'TaskCompleted'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n        
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationCancelled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationFailed'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details - server restart needed to apply\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalling'~}}
        {{ServerName}} {{ServerVersion}}, standby\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUninstalled'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUpdated'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserCreated'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDeleted'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserLockedOut'~}}
        {{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserPasswordChanged'~}}
        {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserUpdated'~}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDataSaved'~}}  {{! Outputs continuous notifications during playback.  Recommend disabling under webhook settings.}}
        {{ServerName}} {{ServerVersion}}, check logs for details\n       
    {{~/if_equals~}}
    {{{Timestamp}}}",

    "priority": {{Priority}},

    {{~#if_equals NotificationType 'ItemAdded'~}}
            "title": "Item added to Jellyfin server {{ServerName}}"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'Generic'~}}
            "title": "Jellyfin notification"  {{! unsure what a generic notification is, no documentation.  Outputs redundant notifications if others enabled.  Recommend disabling under webhook settings.}}    
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PlaybackStart'~}}
            "title": "{{NotificationUsername}} started playing,\n{{ClientName}} on {{DeviceName}}"       
    {{~/if_equals~}}   
    {{~#if_equals NotificationType 'PlaybackProgress'~}}  {{! WARNING: as is, outputs continuous notifications.  Recommend disabling in webhook settings pending rewrite.}}
            "title": "{{NotificationUsername}} is playing, {{ClientName}} on {{DeviceName}}"
    {{~/if_equals~}} 
    {{~#if_equals NotificationType 'PlaybackStop'~}}
            "title": "{{NotificationUsername}} stopped playing,\n{{ClientName}} on {{DeviceName}}"
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'SubtitleDownloadFailure'~}}
            "title": "Warning: Subtitle failed to download"       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationFailure'~}}
            "title": "Warning: {{NotificationUsername}} failed to authenticate"       
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationSuccess'~}}
            "title": "{{NotificationUsername}} successfully logged on"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'SessionStart'~}}
            "title": "{{NotificationUsername}} now active"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PendingRestart'~}}
            "title": "Notice: Jellyfin server needs to be restarted" {{! unsure if needs manual restart, or just informing that restart is in process}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'TaskCompleted'~}}
            "title": "Jellyfin task complete" {{! no documentation on task types}} 
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationCancelled'~}}
            "title": "Plugin installation cancelled" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationFailed'~}}
            "title": "Plugin installation failed" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalled'~}}
            "title": "Plugin successfully installed" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalling'~}}
            "title": "Plugin is installing now" {{! no documentation on plugin ID}}       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUninstalled'~}}
            "title": "Plugin was removed successfully" {{! no documentation on plugin ID}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUpdated'~}}
            "title": "Plugin was successfully updated" {{! no documentation on plugin ID}}
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserCreated'~}}
            "title": "{{NotificationUsername}} was added successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDeleted'~}}
            "title": "{{NotificationUsername}} was deleted"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserLockedOut'~}}
            "title": "Warning: {{NotificationUsername}} was locked out"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserPasswordChanged'~}}
            "title": "{{NotificationUsername}} password changed successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserUpdated'~}}
            "title": "{{NotificationUsername}} was updated successfully"       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDataSaved'~}}  {{! Outputs continuous notifications during playback.  Recommend disabling under webhook settings.}}
            "title": "{{NotificationUsername}} data was saved"       
    {{~/if_equals~}}
}
pdfrg commented 1 year ago

Latest revision of my Gotify template.

  1. Incorporated workaround of point 1 in above comment, using coverartarchive.org.
  2. Reorganized template to combine title and message for each type of notification, making template much shorter.
  3. Included image link for all notification types. Many are linked to web resources, definitely not ideal. Did not include specific links in template. Just did image search and inserted links. Found images have no consistent theme, couldn't locate a themed set that worked for all types. Could try to link to local file like [](/another/dir/filename.ext) Could also create photo library in Jellyfin of desired images and link to those.
  4. Slight reformat of some notifications, including bold text and increased font size.

Overall pretty happy with how this one is working. Again, not every notification type tested, so still may have some errors.

{
    "extras":{
        "client::display": {
            "contentType": "text/markdown"
        }
    },
    {{~#if_equals NotificationType 'ItemAdded'~}}
        "title": "Item added to Jellyfin server {{ServerName}}",
        "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n
        {{~#if_equals ItemType 'Episode'~}}           
            ### {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=episode&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Season'~}}
            ### {{{SeriesName}}} Season {{SeasonNumber}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=series&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'Series'~}}
            ### {{{SeriesName}}}\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=series&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'Movie'~}}
            ### {{{Name}}} ({{Year}}) {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tmdb~}}
                [TMDB](https://www.themoviedb.org/movie/{{Provider_tmdb}})\n\n
            {{~/if_exist~}}    
            {{~#if_exist Provider_imdb~}}    
                [IMDb](https://www.imdb.com/title/{{Provider_imdb}}/)\n\n
            {{~/if_exist~}}    
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'MusicAlbum'~}}
            ### {{{Artist}}} - {{{Name}}} ({{Year}})\n\n{{RunTime}}\n\n
            {{~#if_exist Provider_musicbrainzreleasegroup~}}          
                [MusicBrainz Release Group](https://musicbrainz.org/release-group/{{Provider_musicbrainzreleasegroup}})\n\n
            {{~/if_exist~}}            
            {{~#if_exist Provider_musicbrainzalbum~}}          
                [MusicBrainz Album](https://musicbrainz.org/release/{{Provider_musicbrainzalbum}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
            ### {{{Name}}} - {{RunTime}}\n\n### {{{Artist}}} - {{{Album}}} ({{Year}})\n\n{{Audio_0_Title}}\n\n
            {{~#if_exist Provider_musicbrainzartist~}}          
                [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}
        {{~#if_equals ItemType 'MusicArtist'~}}
            ### {{{Artist}}}\n\n
            {{~#if_exist Provider_musicbrainzartist~}}          
                [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
            {{~/if_exist~}}
        {{~/if_equals~}}    
        {{~#if_equals ItemType 'MusicVideo'~}}
            ### {{{Artist}}} - {{{Name}}} ({{Year}})\n\n
        {{~/if_equals~}}    
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PlaybackStart'~}}
        "title": "{{NotificationUsername}} started playing,\n{{ClientName}} on {{DeviceName}}",
        {{~#if_equals ItemType 'Episode'~}}
            "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n### {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tvdb~}}
                [tvdb](https://www.thetvdb.com/?tab=episode&id={{Provider_tvdb}})\n\n
            {{~/if_exist~}}            
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n### {{{Name}}} ({{Year}}) {{RunTime}}\n\n{{Video_0_Title}} {{Video_0_Profile}} {{Video_0_Width}}x{{Video_0_Height}}\n\n{{Audio_0_Title}} {{Audio_0_Codec}}, {{Audio_0_Channels}} channels\n\n{{{Tagline}}}\n\n{{{Overview}}}\n\n
            {{~#if_exist Provider_tmdb~}}
                [TMDB](https://www.themoviedb.org/movie/{{Provider_tmdb}})\n\n
            {{~/if_exist~}}    
            {{~#if_exist Provider_imdb~}}    
                [IMDb](https://www.imdb.com/title/{{Provider_imdb}}/)\n\n
            {{~/if_exist~}}                
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
           "message": "![](https://coverartarchive.org/release/{{Provider_musicbrainzalbum}}/front-500)\n\n### {{{Name}}} {{RunTime}}\n\n### {{{Artist}}} - {{{Album}}} ({{Year}})\n\n{{Audio_0_Title}}\n\n
                {{~#if_exist Provider_musicbrainzalbum~}}          
                    [MusicBrainz Album](https://musicbrainz.org/release/{{Provider_musicbrainzalbum}})\n\n
                {{~/if_exist~}}
                {{~#if_exist Provider_musicbrainzartist~}}   
                    [MusicBrainz Artist](https://musicbrainz.org/artist/{{Provider_musicbrainzartist}})\n\n
                {{~/if_exist~}}    
        {{~/if_equals~}}
    {{~/if_equals~}}   
    {{~#if_equals NotificationType 'PlaybackStop'~}}
        "title": "{{NotificationUsername}} stopped playing,\n{{ClientName}} on {{DeviceName}}",
        {{~#if_equals ItemType 'Episode'~}}
            "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n### {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} {{RunTime}}\n\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n### {{{Name}}} ({{Year}}) {{RunTime}}\n\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Audio'~}}
            "message": "![](https://coverartarchive.org/release/{{Provider_musicbrainzalbum}}/front-500)\n\n### {{{Name}}} {{RunTime}}\n\n### {{{Artist}}} - {{{Album}}} ({{Year}})\n\n
        {{~/if_equals~}}
        {{~#if_equals PlayedToCompletion 'true'~}}
            was completed\n\n
        {{~else~}}
            was stopped at {{PlaybackPosition}}\n\n
        {{~/if_equals~}}
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'SubtitleDownloadFailure'~}}
        "title": "WARNING: Subtitle failed to download",
        "message": "![](http://SERVER_IP:PORT/Items/{{ItemId}}/Images/Primary)\n\n
        {{~#if_equals ItemType 'Episode'~}}
            {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}}\n\n
        {{~/if_equals~}}
        {{~#if_equals ItemType 'Movie'~}}
            {{{Name}}} ({{Year}})\n\n
        {{~/if_equals~}}       
        ### Check logs for details\n
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationFailure'~}}
        "title": "WARNING: {{NotificationUsername}} failed to authenticate",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{ClientName}} on {{DeviceName}}\n\n
        ### Check logs for details\n
    {{~/if_equals~}}    
    {{~#if_equals NotificationType 'AuthenticationSuccess'~}}
        "title": "{{NotificationUsername}} successfully logged on",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'SessionStart'~}}
        "title": "{{NotificationUsername}} now active",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{ClientName}} on {{DeviceName}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PendingRestart'~}}
        "title": "Notice: Jellyfin server needs to be restarted",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'TaskCompleted'~}}
        "title": "Jellyfin task complete",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{ServerName}} {{ServerVersion}}\n\nCheck logs for details\n        
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationCancelled'~}}
        "title": "Plugin installation cancelled!",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\non {{ServerName}} {{ServerVersion}}\n\nCheck logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstallationFailed'~}}
        "title": "WARNING: Plugin installation failed",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\n{{{PluginChangelog}}}\n\non {{ServerName}} {{ServerVersion}}\n\n### Check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalled'~}}
        "title": "Plugin successfully installed",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\n{{{PluginChangelog}}}\n\non {{ServerName}} {{ServerVersion}}\n\n\### NOTICE: Server restart required to apply changes!\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginInstalling'~}}
        "title": "Plugin is installing now",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\n{{{PluginChangelog}}}\n\non {{ServerName}} {{ServerVersion}}\n\nStandby...\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUninstalled'~}}
        "title": "Plugin was uninstalled successfully",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\n\on {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'PluginUpdated'~}}
        "title": "Plugin was successfully updated",
        "message": "![](https://LINK_TO_IMAGE)\n\n{{PluginName}} {{PluginVersion}}\n\n{{{PluginChangelog}}}\n\non {{ServerName}} {{ServerVersion}}\n\n### NOTICE: Server restart required to apply changes!\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserCreated'~}}
        "title": "{{NotificationUsername}} was added successfully",
        "message": "![](https://LINK_TO_IMAGE)\n\nOn {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserDeleted'~}}
        "title": "{{NotificationUsername}} was deleted",
        "message": "![](https://LINK_TO_IMAGE)\n\nOn {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserLockedOut'~}}
        "title": "WARNING: {{NotificationUsername}} was locked out",
        "message": "![](https://LINK_TO_IMAGE)\n\nOn {{ClientName}} on {{DeviceName}}\n\n### Check logs for details\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserPasswordChanged'~}}
        "title": "{{NotificationUsername}} password changed successfully",
        "message": "![](https://LINK_TO_IMAGE)\n\nOn {{ServerName}} {{ServerVersion}}\n       
    {{~/if_equals~}}
    {{~#if_equals NotificationType 'UserUpdated'~}}
        "title": "{{NotificationUsername}} was updated successfully",
        "message": "![](https://LINK_TO_IMAGE)\n\nOn {{ServerName}} {{ServerVersion}}\n\nCheck logs for details\n       
    {{~/if_equals~}}    
    {{{Timestamp}}}",
    "priority": {{Priority}}    
}
iluvatyr commented 1 year ago

Thank you for this template. I downloaded the webhook plugin and was confused why I always had errors in the logs with no notifications coming. It does not state anywhere in the webhook plugin, that one should put his own template into the field, or I just missed it.

Copying your template made it work now. Thank you for that.

Maybe it should get documented somewhere in the webhook plugins destination configuration, that one has to add a template for it to work

pdfrg commented 1 year ago

I'm glad you found it useful. I'm still using the template above without additional modifications.

There is a brief line on the plugin homepage https://github.com/jellyfin/jellyfin-plugin-webhook that says "See Templates for sample templates." Of course, not everyone is going to check the github page after installing the plugin in Jellyfin.

I agree it would be useful if the Jellyfin plugin configuration page gave some instructions. Perhaps preloaded a default template and values, and instructed user to "paste Gotify server URL here" and "paste Gotify Jellyfin app token here".

If you follow the link, then there is another link to "gotify.handlebars" https://github.com/jellyfin/jellyfin-plugin-webhook/blob/master/Jellyfin.Plugin.Webhook/Templates/Gotify.handlebars

However, this example template is very basic, just a starting point for crafting your own template. As not everyone who uses the plugin will be inclined or able to write their own, perhaps the example template could be updated?

iluvatyr commented 1 year ago

I fully agree with you. In my opinion, it would be best to add a default template that works and also put as a comment some lines there, that say where templates are that can be added.

I even went to the github page of it several times, but that line is very easy to miss. I think this plugin should just work by default without additional searching and copying of a template by having a default template and then users that want extras can change it as they want, by editing said template or copying in another one

Im not 100% sure how the webhook plugin works, but since it is possible to tick different options that should be notified for, I'm not sure if there can be added just a template that works for most (or all) of the different events, since then it can be ticked on or off via the webhook plugins UI.

sabamimi commented 1 year ago

So glad to have found your work ! It did work at first attempt . Thanks again !

OdinVex commented 6 months ago

You can use {{ServerUrl}} instead of http://SERVER_IP:PORT. Edit: I think there should be a default fully-fleshed template assumed if one isn't using a custom one, or a warning that the plugin alone won't be useful without a template.

frenzis01 commented 6 months ago

@pdfrg your template is awesome. However, I'm having trouble with AuthenticationFailure/Success. It seems like no notifications are produced for these events. Did you experience similar issues? Lines in your template regarding such notification types look ok, but still something isn't working (at least for me).

May be unrelated, but what is that LINK_TO_IMAGE used for?

pdfrg commented 5 months ago

You can use {{ServerUrl}} instead of http://SERVER_IP:PORT. Edit: I think there should be a default fully-fleshed template assumed if one isn't using a custom one, or a warning that the plugin alone won't be useful without a template.

Yes, thanks, I should have implemented {{ServerUrl}}

I agree the default template should be updated.

pdfrg commented 5 months ago

@pdfrg your template is awesome. However, I'm having trouble with AuthenticationFailure/Success. It seems like no notifications are produced for these events. Did you experience similar issues? Lines in your template regarding such notification types look ok, but still something isn't working (at least for me).

May be unrelated, but what is that LINK_TO_IMAGE used for?

Thanks you. TBH, I didn't really troubleshoot the AuthenticationFailure/Success webhooks. I just tried to include every possible notification in the template. I really don't need them myself.

LINK_TO_IMAGE is a placeholder. It is not needed and can be removed to generate a text only message. Personally, I have replaced these with links to images on the web that I find go well with each specific notification. I didn't want to provide the links that I use here. I just did a google image search for each message and linked the images I liked best. I was trying to figure out how to link to a specific local file, but couldn't work it out. I have seen file:///path/to/image.jpg type syntax but couldn't get it to work. If you have your own web server/photo server you could include a direct link to the file here instead. It may be possible to create a Jellyfin photo library and link to the images there. I haven't tried. I really just use the template for item added and start/stop playing notifications.