Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for more variables #194

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}