Skip to content

Commit

Permalink
Support for more variables (#194)
Browse files Browse the repository at this point in the history
* Support for AirTime, PremiereDate and Genres

Adds `AirTime`, `PremiereDate` and `Genres`.

* Support for AirTime, PremiereDate and Genres

* Support for more variables

Support for `AirTime`, `EpisodePremiereDate`, `SeriesPremiereDate` and `Genres`
  • Loading branch information
zeroquinc authored Sep 27, 2023
1 parent 477c6bd commit 4543c0c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Jellyfin.Plugin.Webhook/Helpers/DataObjectHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public static Dictionary<string, object> AddBaseItemData(this Dictionary<string,
dataObject["Year"] = item.ProductionYear;
}

if (item.Genres is not null && item.Genres.Length > 0)
{
dataObject["Genres"] = string.Join(", ", item.Genres);
}

switch (item)
{
case Season season:
Expand Down Expand Up @@ -98,6 +103,11 @@ public static Dictionary<string, object> AddBaseItemData(this Dictionary<string,
dataObject["SeasonId"] = episode.SeasonId;
}

if (episode.Series?.PremiereDate is not null)
{
dataObject["SeriesPremiereDate"] = episode.Series.PremiereDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
}

if (episode.Season?.IndexNumber is not null)
{
dataObject["SeasonNumber"] = episode.Season.IndexNumber;
Expand All @@ -119,11 +129,21 @@ public static Dictionary<string, object> AddBaseItemData(this Dictionary<string,
dataObject["EpisodeNumberEnd000"] = episode.IndexNumberEnd.Value.ToString("000", CultureInfo.InvariantCulture);
}

if (episode.PremiereDate is not null)
{
dataObject["EpisodePremiereDate"] = episode.PremiereDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
}

if (episode.Series?.ProductionYear is not null)
{
dataObject["Year"] = episode.Series.ProductionYear;
}

if (episode.Series?.AirTime is not null)
{
dataObject["AirTime"] = episode.Series.AirTime;
}

break;
case Audio audio:
if (!string.IsNullOrEmpty(audio.Album))
Expand Down Expand Up @@ -362,4 +382,4 @@ public static Dictionary<string, object> AddUserItemData(this Dictionary<string,
/// <returns>Escaped string.</returns>
private static string Escape(this string? input)
=> input?.Replace("\"", "\\\"", StringComparison.Ordinal) ?? string.Empty;
}
}

0 comments on commit 4543c0c

Please sign in to comment.