|
|
|
@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.IO; |
|
|
|
using Microsoft.IO; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Scriban; |
|
|
|
using Scriban; |
|
|
|
|
|
|
|
using Scriban.Runtime; |
|
|
|
using WebMarkupMin.Core; |
|
|
|
using WebMarkupMin.Core; |
|
|
|
|
|
|
|
|
|
|
|
namespace ErsatzTV.Application.Channels; |
|
|
|
namespace ErsatzTV.Application.Channels; |
|
|
|
@ -54,6 +55,8 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
RemoveXmlComments = true, |
|
|
|
RemoveXmlComments = true, |
|
|
|
CollapseTagsWithoutContent = true |
|
|
|
CollapseTagsWithoutContent = true |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var templateContext = new XmlTemplateContext(); |
|
|
|
|
|
|
|
|
|
|
|
string movieText = await File.ReadAllTextAsync(movieTemplateFileName, cancellationToken); |
|
|
|
string movieText = await File.ReadAllTextAsync(movieTemplateFileName, cancellationToken); |
|
|
|
var movieTemplate = Template.Parse(movieText, movieTemplateFileName); |
|
|
|
var movieTemplate = Template.Parse(movieText, movieTemplateFileName); |
|
|
|
@ -213,26 +216,31 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
.HeadOrNone() |
|
|
|
.HeadOrNone() |
|
|
|
.Match(a => GetArtworkUrl(a, ArtworkKind.Poster), () => string.Empty); |
|
|
|
.Match(a => GetArtworkUrl(a, ArtworkKind.Poster), () => string.Empty); |
|
|
|
|
|
|
|
|
|
|
|
string result = await movieTemplate.RenderAsync( |
|
|
|
var data = new |
|
|
|
new |
|
|
|
{ |
|
|
|
{ |
|
|
|
ProgrammeStart = start, |
|
|
|
ProgrammeStart = start, |
|
|
|
ProgrammeStop = stop, |
|
|
|
ProgrammeStop = stop, |
|
|
|
ChannelNumber = request.ChannelNumber, |
|
|
|
ChannelNumber = request.ChannelNumber, |
|
|
|
HasCustomTitle = hasCustomTitle, |
|
|
|
HasCustomTitle = hasCustomTitle, |
|
|
|
CustomTitle = displayItem.CustomTitle, |
|
|
|
CustomTitle = displayItem.CustomTitle, |
|
|
|
MovieTitle = title, |
|
|
|
MovieTitle = title, |
|
|
|
MovieHasPlot = !string.IsNullOrWhiteSpace(metadata.Plot), |
|
|
|
MovieHasPlot = !string.IsNullOrWhiteSpace(metadata.Plot), |
|
|
|
MoviePlot = metadata.Plot, |
|
|
|
MoviePlot = metadata.Plot, |
|
|
|
MovieHasYear = metadata.Year.HasValue, |
|
|
|
MovieHasYear = metadata.Year.HasValue, |
|
|
|
MovieYear = metadata.Year, |
|
|
|
MovieYear = metadata.Year, |
|
|
|
MovieGenres = metadata.Genres.Map(g => g.Name).OrderBy(n => n), |
|
|
|
MovieGenres = metadata.Genres.Map(g => g.Name).OrderBy(n => n), |
|
|
|
MovieHasArtwork = !string.IsNullOrWhiteSpace(poster), |
|
|
|
MovieHasArtwork = !string.IsNullOrWhiteSpace(poster), |
|
|
|
MovieArtworkUrl = poster, |
|
|
|
MovieArtworkUrl = poster, |
|
|
|
MovieHasContentRating = !string.IsNullOrWhiteSpace(metadata.ContentRating), |
|
|
|
MovieHasContentRating = !string.IsNullOrWhiteSpace(metadata.ContentRating), |
|
|
|
MovieContentRating = metadata.ContentRating, |
|
|
|
MovieContentRating = metadata.ContentRating, |
|
|
|
MovieGuids = metadata.Guids.Map(g => g.Guid) |
|
|
|
MovieGuids = metadata.Guids.Map(g => g.Guid) |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var scriptObject = new ScriptObject(); |
|
|
|
|
|
|
|
scriptObject.Import(data); |
|
|
|
|
|
|
|
templateContext.PushGlobal(scriptObject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string result = await movieTemplate.RenderAsync(templateContext); |
|
|
|
|
|
|
|
|
|
|
|
MarkupMinificationResult minified = minifier.Minify(result); |
|
|
|
MarkupMinificationResult minified = minifier.Minify(result); |
|
|
|
await xml.WriteRawAsync(minified.MinifiedContent); |
|
|
|
await xml.WriteRawAsync(minified.MinifiedContent); |
|
|
|
@ -257,31 +265,36 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
|
|
|
|
|
|
|
|
string artworkPath = GetPrioritizedArtworkPath(metadata); |
|
|
|
string artworkPath = GetPrioritizedArtworkPath(metadata); |
|
|
|
|
|
|
|
|
|
|
|
string result = await episodeTemplate.RenderAsync( |
|
|
|
var data = new |
|
|
|
new |
|
|
|
{ |
|
|
|
{ |
|
|
|
ProgrammeStart = start, |
|
|
|
ProgrammeStart = start, |
|
|
|
ProgrammeStop = stop, |
|
|
|
ProgrammeStop = stop, |
|
|
|
ChannelNumber = request.ChannelNumber, |
|
|
|
ChannelNumber = request.ChannelNumber, |
|
|
|
HasCustomTitle = hasCustomTitle, |
|
|
|
HasCustomTitle = hasCustomTitle, |
|
|
|
CustomTitle = displayItem.CustomTitle, |
|
|
|
CustomTitle = displayItem.CustomTitle, |
|
|
|
ShowTitle = title, |
|
|
|
ShowTitle = title, |
|
|
|
EpisodeHasTitle = !string.IsNullOrWhiteSpace(subtitle), |
|
|
|
EpisodeHasTitle = !string.IsNullOrWhiteSpace(subtitle), |
|
|
|
EpisodeTitle = subtitle, |
|
|
|
EpisodeTitle = subtitle, |
|
|
|
EpisodeHasPlot = !string.IsNullOrWhiteSpace(metadata.Plot), |
|
|
|
EpisodeHasPlot = !string.IsNullOrWhiteSpace(metadata.Plot), |
|
|
|
EpisodePlot = metadata.Plot, |
|
|
|
EpisodePlot = metadata.Plot, |
|
|
|
ShowHasYear = showMetadata.Year.HasValue, |
|
|
|
ShowHasYear = showMetadata.Year.HasValue, |
|
|
|
ShowYear = showMetadata.Year, |
|
|
|
ShowYear = showMetadata.Year, |
|
|
|
ShowGenres = showMetadata.Genres.Map(g => g.Name).OrderBy(n => n), |
|
|
|
ShowGenres = showMetadata.Genres.Map(g => g.Name).OrderBy(n => n), |
|
|
|
EpisodeHasArtwork = !string.IsNullOrWhiteSpace(artworkPath), |
|
|
|
EpisodeHasArtwork = !string.IsNullOrWhiteSpace(artworkPath), |
|
|
|
EpisodeArtworkUrl = artworkPath, |
|
|
|
EpisodeArtworkUrl = artworkPath, |
|
|
|
SeasonNumber = templateEpisode.Season?.SeasonNumber ?? 0, |
|
|
|
SeasonNumber = templateEpisode.Season?.SeasonNumber ?? 0, |
|
|
|
EpisodeNumber = metadata.EpisodeNumber, |
|
|
|
EpisodeNumber = metadata.EpisodeNumber, |
|
|
|
ShowHasContentRating = !string.IsNullOrWhiteSpace(showMetadata.ContentRating), |
|
|
|
ShowHasContentRating = !string.IsNullOrWhiteSpace(showMetadata.ContentRating), |
|
|
|
ShowContentRating = showMetadata.ContentRating, |
|
|
|
ShowContentRating = showMetadata.ContentRating, |
|
|
|
ShowGuids = showMetadata.Guids.Map(g => g.Guid), |
|
|
|
ShowGuids = showMetadata.Guids.Map(g => g.Guid), |
|
|
|
EpisodeGuids = metadata.Guids.Map(g => g.Guid) |
|
|
|
EpisodeGuids = metadata.Guids.Map(g => g.Guid) |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var scriptObject = new ScriptObject(); |
|
|
|
|
|
|
|
scriptObject.Import(data); |
|
|
|
|
|
|
|
templateContext.PushGlobal(scriptObject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string result = await episodeTemplate.RenderAsync(templateContext); |
|
|
|
|
|
|
|
|
|
|
|
MarkupMinificationResult minified = minifier.Minify(result); |
|
|
|
MarkupMinificationResult minified = minifier.Minify(result); |
|
|
|
await xml.WriteRawAsync(minified.MinifiedContent); |
|
|
|
await xml.WriteRawAsync(minified.MinifiedContent); |
|
|
|
|