Files
ersatztv/ErsatzTV.Core/Iptv/ChannelIdentifier.cs
T
a91de68a5c Add instance id support (#2828)
* Add instance id support

* actually use env variable for instance ID

* Default to ersatztv.org for instance id

* simplify

* fix ordering

* update changelog

---------

Co-authored-by: Jason Dove <1695733+jasongdove@users.noreply.github.com>
2026-02-18 09:09:44 -06:00

26 lines
776 B
C#

using System.Globalization;
namespace ErsatzTV.Core.Iptv;
public static class ChannelIdentifier
{
public static string LegacyFromNumber(string channelNumber) => $"{channelNumber}.etv";
public static string FromNumber(string channelNumber)
{
// get rid of any decimal (only two are allowed)
var number = (int)(decimal.Parse(channelNumber, CultureInfo.InvariantCulture) * 100);
var id = 0;
while (number != 0)
{
id += number % 10 + 48;
number /= 10;
}
string instanceId = SystemEnvironment.InstanceId;
return !string.IsNullOrWhiteSpace(instanceId)
? $"C{channelNumber}.{id}.{instanceId}.ersatztv.org"
: $"C{channelNumber}.{id}.ersatztv.org";
}
}