From 86089ec03a4af121281154a6159cc70787571dbe Mon Sep 17 00:00:00 2001 From: Felix Ruhnow Date: Sun, 10 Feb 2019 22:23:47 +0100 Subject: Adding support for "tvg-chno"-Tag in M3U Channel Lists --- Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 9a01c42d3..e10c44501 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -204,6 +204,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } + if (!IsValidChannelNumber(numberString)) + { + if (attributes.TryGetValue("tvg-chno", out string value)) + { + numberString = value; + } + } + if (!string.IsNullOrWhiteSpace(numberString)) { numberString = numberString.Trim(); -- cgit v1.2.3 From edf5ee0cc43beaff4437ace4ae6b0202e414ec03 Mon Sep 17 00:00:00 2001 From: Felix Ruhnow Date: Mon, 11 Feb 2019 10:11:07 +0100 Subject: combining some of the if's and adressing #820 --- .../LiveTv/TunerHosts/M3uParser.cs | 78 ++++++++++------------ 1 file changed, 37 insertions(+), 41 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index e10c44501..d2a835b85 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -157,72 +157,68 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; string numberString = null; + string attributeValue; + double doubleValue; - // Check for channel number with the format from SatIp - // #EXTINF:0,84. VOX Schweiz - // #EXTINF:0,84.0 - VOX Schweiz - if (!string.IsNullOrWhiteSpace(nameInExtInf)) + if (attributes.TryGetValue("tvg-chno", out attributeValue)) { - var numberIndex = nameInExtInf.IndexOf(' '); - if (numberIndex > 0) + if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue)) { - var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); - - if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) - { - numberString = numberPart; - } + numberString = attributeValue; } } - if (!string.IsNullOrWhiteSpace(numberString)) - { - numberString = numberString.Trim(); - } - if (!IsValidChannelNumber(numberString)) { - if (attributes.TryGetValue("tvg-id", out string value)) + if (attributes.TryGetValue("tvg-id", out attributeValue)) { - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue)) + if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue)) { - numberString = value; + numberString = attributeValue; + } + else if (attributes.TryGetValue("channel-id", out attributeValue)) + { + if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue)) + { + numberString = attributeValue; + } } } - } - if (!string.IsNullOrWhiteSpace(numberString)) - { - numberString = numberString.Trim(); - } - - if (!IsValidChannelNumber(numberString)) - { - if (attributes.TryGetValue("channel-id", out string value)) + if (String.IsNullOrWhiteSpace(numberString)) { - numberString = value; + // Using this as a fallback now as this leads to Problems with channels like "5 USA" + // where 5 isnt ment to be the channel number + // Check for channel number with the format from SatIp + // #EXTINF:0,84. VOX Schweiz + // #EXTINF:0,84.0 - VOX Schweiz + if (!string.IsNullOrWhiteSpace(nameInExtInf)) + { + var numberIndex = nameInExtInf.IndexOf(' '); + if (numberIndex > 0) + { + var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); + + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) + { + numberString = numberPart; + } + } + } } + } if (!IsValidChannelNumber(numberString)) { - if (attributes.TryGetValue("tvg-chno", out string value)) - { - numberString = value; - } + numberString = null; } if (!string.IsNullOrWhiteSpace(numberString)) { numberString = numberString.Trim(); } - - if (!IsValidChannelNumber(numberString)) - { - numberString = null; - } - - if (string.IsNullOrWhiteSpace(numberString)) + else { if (string.IsNullOrWhiteSpace(mediaUrl)) { -- cgit v1.2.3