|
|
|
@ -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; |
|
|
|
@ -55,6 +56,8 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
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,8 +216,7 @@ 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, |
|
|
|
@ -232,7 +234,13 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
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,8 +265,7 @@ 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, |
|
|
|
@ -281,7 +288,13 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData> |
|
|
|
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); |
|
|
|
|