Browse Source

Fixing URL Encoding for logo generation (#1818)

pull/1821/head
Sylvain 2 years ago committed by GitHub
parent
commit
01090f62e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      ErsatzTV.Application/Channels/ChannelViewModel.cs
  2. 4
      ErsatzTV.Core/Domain/Channel.cs
  3. 2
      ErsatzTV.Core/Iptv/ChannelPlaylist.cs
  4. 11
      ErsatzTV/Pages/Channels.razor

8
ErsatzTV.Application/Channels/ChannelViewModel.cs

@ -1,4 +1,5 @@
using ErsatzTV.Core.Domain; using ErsatzTV.Core.Domain;
using System.Net;
namespace ErsatzTV.Application.Channels; namespace ErsatzTV.Application.Channels;
@ -20,4 +21,7 @@ public record ChannelViewModel(
string PreferredSubtitleLanguageCode, string PreferredSubtitleLanguageCode,
ChannelSubtitleMode SubtitleMode, ChannelSubtitleMode SubtitleMode,
ChannelMusicVideoCreditsMode MusicVideoCreditsMode, ChannelMusicVideoCreditsMode MusicVideoCreditsMode,
string MusicVideoCreditsTemplate); string MusicVideoCreditsTemplate)
{
public string WebEncodedName => WebUtility.UrlEncode(Name);
}

4
ErsatzTV.Core/Domain/Channel.cs

@ -1,4 +1,5 @@
using ErsatzTV.Core.Domain.Filler; using ErsatzTV.Core.Domain.Filler;
using System.Net;
namespace ErsatzTV.Core.Domain; namespace ErsatzTV.Core.Domain;
@ -29,4 +30,5 @@ public class Channel
public ChannelMusicVideoCreditsMode MusicVideoCreditsMode { get; set; } public ChannelMusicVideoCreditsMode MusicVideoCreditsMode { get; set; }
public string MusicVideoCreditsTemplate { get; set; } public string MusicVideoCreditsTemplate { get; set; }
public ChannelProgressMode ProgressMode { get; set; } public ChannelProgressMode ProgressMode { get; set; }
public string WebEncodedName => WebUtility.UrlEncode(Name);
} }

2
ErsatzTV.Core/Iptv/ChannelPlaylist.cs

@ -65,7 +65,7 @@ public class ChannelPlaylist
.HeadOrNone() .HeadOrNone()
.Match( .Match(
artwork => $"{_scheme}://{_host}{_baseUrl}/iptv/logos/{artwork.Path}.jpg{accessTokenUri}", artwork => $"{_scheme}://{_host}{_baseUrl}/iptv/logos/{artwork.Path}.jpg{accessTokenUri}",
() => $"{_scheme}://{_host}{_baseUrl}/iptv/logos/gen?text={WebUtility.UrlEncode(channel.Name)}{accessTokenUriAmp}"); () => $"{_scheme}://{_host}{_baseUrl}/iptv/logos/gen?text={channel.WebEncodedName}{accessTokenUriAmp}");
string shortUniqueId = Convert.ToBase64String(channel.UniqueId.ToByteArray()) string shortUniqueId = Convert.ToBase64String(channel.UniqueId.ToByteArray())
.TrimEnd('=') .TrimEnd('=')

11
ErsatzTV/Pages/Channels.razor

@ -47,10 +47,10 @@
{ {
<MudElement HtmlTag="img" src="@($"iptv/logos/{context.Logo}")" Style="max-height: 50px"/> <MudElement HtmlTag="img" src="@($"iptv/logos/{context.Logo}")" Style="max-height: 50px"/>
} }
else else
{ {
<MudElement HtmlTag="img" src="@($"iptv/logos/gen?text={context.Name}")" Style="max-height: 50px" /> <MudElement HtmlTag="img" src="@($"iptv/logos/gen?text={context.WebEncodedName}")" Style="max-height: 50px" />
} }
</MudTd> </MudTd>
<MudTd DataLabel="Name">@context.Name</MudTd> <MudTd DataLabel="Name">@context.Name</MudTd>
<MudTd DataLabel="Language">@context.PreferredAudioLanguageCode</MudTd> <MudTd DataLabel="Language">@context.PreferredAudioLanguageCode</MudTd>
@ -252,5 +252,4 @@
StreamingMode.TransportStreamHybrid => "MPEG-TS", StreamingMode.TransportStreamHybrid => "MPEG-TS",
_ => "MPEG-TS (Legacy)" _ => "MPEG-TS (Legacy)"
}; };
}
}

Loading…
Cancel
Save