use new channel identifiers in M3U and XMLTV to disambiguate in Plex (#1920)
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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}");
|
||||
|
||||
Reference in New Issue
Block a user