use new channel identifiers in M3U and XMLTV to disambiguate in Plex (#1920)

This commit is contained in:
Jason Dove
2024-10-16 09:37:33 -05:00
committed by GitHub
parent 5d0f40978d
commit c063720169
12 changed files with 104 additions and 17 deletions
+25
View File
@@ -0,0 +1,25 @@
using System.Globalization;
namespace ErsatzTV.Core.Iptv;
public static class ChannelIdentifier
{
public static string LegacyFromNumber(string channelNumber)
{
return $"{channelNumber}.etv";
}
public static string FromNumber(string channelNumber)
{
// get rid of any decimal (only two are allowed)
int number = (int)(decimal.Parse(channelNumber, CultureInfo.InvariantCulture) * 100);
int id = 0;
while (number != 0)
{
id += number % 10 + 48;
number /= 10;
}
return $"C{channelNumber}.{id}.ersatztv.org";
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ public class ChannelPlaylist
sb.AppendLine(
CultureInfo.InvariantCulture,
$"#EXTINF:0 tvg-id=\"{channel.Number}.etv\" channel-id=\"{shortUniqueId}\" channel-number=\"{channel.Number}\" CUID=\"{shortUniqueId}\" tvg-chno=\"{channel.Number}\" tvg-name=\"{channel.Name}\" tvg-logo=\"{logo}\" group-title=\"{channel.Group}\" tvc-stream-vcodec=\"{vcodec}\" tvc-stream-acodec=\"{acodec}\", {channel.Name}");
$"#EXTINF:0 tvg-id=\"{ChannelIdentifier.FromNumber(channel.Number)}\" channel-id=\"{shortUniqueId}\" channel-number=\"{channel.Number}\" CUID=\"{shortUniqueId}\" tvg-chno=\"{channel.Number}\" tvg-name=\"{channel.Name}\" tvg-logo=\"{logo}\" group-title=\"{channel.Group}\" tvc-stream-vcodec=\"{vcodec}\" tvc-stream-acodec=\"{acodec}\", {channel.Name}");
sb.AppendLine(
CultureInfo.InvariantCulture,
$"{_scheme}://{_host}{_baseUrl}/iptv/channel/{channel.Number}.{format}");