From 06397500959fb8563460c5af0808a2677b62d704 Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Tue, 27 Jul 2021 20:42:20 +0200 Subject: [PATCH] - Philips ChannelMap\_100: fixed reading/writing favorites --- source/ChanSort.Api/Model/DataRoot.cs | 2 +- .../ChanSort.Loader.Philips/XmlSerializer.cs | 5 +- source/ChanSort.sln | 2 +- .../LaSat_lst.h | 6 +- .../PhilipsXmlStatsCollector.cs | 93 +++++++++++++++++++ .../{Spike.LgWebOs5.csproj => Spikes.csproj} | 7 +- .../{Program.cs => WebOs5StatsCollector.cs} | 13 ++- source/changelog.md | 7 +- 8 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 source/Spike.LgWebOs5/PhilipsXmlStatsCollector.cs rename source/Spike.LgWebOs5/{Spike.LgWebOs5.csproj => Spikes.csproj} (92%) rename source/Spike.LgWebOs5/{Program.cs => WebOs5StatsCollector.cs} (97%) diff --git a/source/ChanSort.Api/Model/DataRoot.cs b/source/ChanSort.Api/Model/DataRoot.cs index 380a0a3..b01dba1 100644 --- a/source/ChanSort.Api/Model/DataRoot.cs +++ b/source/ChanSort.Api/Model/DataRoot.cs @@ -114,7 +114,7 @@ namespace ChanSort.Api this.FavListCount = this.loader.Features.MaxFavoriteLists; var favMode = this.FavoritesMode; - if (this.ChannelLists.Any(l => l.IsMixedSourceFavoritesList)) + if (this.ChannelLists.Any(l => l.IsMixedSourceFavoritesList && l.Channels.Count > 0)) favMode = loader.Features.FavoritesMode = FavoritesMode.MixedSource; foreach (var list in this.ChannelLists) diff --git a/source/ChanSort.Loader.Philips/XmlSerializer.cs b/source/ChanSort.Loader.Philips/XmlSerializer.cs index a413109..d0e86ae 100644 --- a/source/ChanSort.Loader.Philips/XmlSerializer.cs +++ b/source/ChanSort.Loader.Philips/XmlSerializer.cs @@ -80,7 +80,7 @@ namespace ChanSort.Loader.Philips this.DataRoot.AddChannelList(this.dvbcChannels); this.DataRoot.AddChannelList(this.satChannels); this.DataRoot.AddChannelList(this.allSatChannels); - this.DataRoot.AddChannelList(this.favChannels); + //this.DataRoot.AddChannelList(this.favChannels); // format 100.0 does not support mixed source favs and adding it would automatically switch to mixed source fav mode this.dvbtChannels.VisibleColumnFieldNames.Add("Source"); this.dvbcChannels.VisibleColumnFieldNames.Add("Source"); @@ -174,6 +174,9 @@ namespace ChanSort.Loader.Philips // otherwise load the single file that was originally selected by the user LoadFile(this.FileName); } + + if (this.Features.FavoritesMode == FavoritesMode.MixedSource) + this.DataRoot.AddChannelList(this.favChannels); } #endregion diff --git a/source/ChanSort.sln b/source/ChanSort.sln index 5026c7f..134df11 100644 --- a/source/ChanSort.sln +++ b/source/ChanSort.sln @@ -67,7 +67,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.M3u", "Chan EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Philips", "ChanSort.Loader.Philips\ChanSort.Loader.Philips.csproj", "{1F52B5EC-A2F1-4E53-9E1A-4658296C5BB5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spike.LgWebOs5", "Spike.LgWebOs5\Spike.LgWebOs5.csproj", "{32EFB306-DEF8-4488-B1AE-46D5B183C373}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spikes", "Spike.LgWebOs5\Spikes.csproj", "{32EFB306-DEF8-4488-B1AE-46D5B183C373}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Grundig", "ChanSort.Loader.Grundig\ChanSort.Loader.Grundig.csproj", "{4D5AF0A3-1B96-42C8-910D-0C4852EA22F4}" EndProject diff --git a/source/Information/FileStructures_for_HHD_Hex_Editor_Neo/LaSat_lst.h b/source/Information/FileStructures_for_HHD_Hex_Editor_Neo/LaSat_lst.h index deafca4..20a9cd1 100644 --- a/source/Information/FileStructures_for_HHD_Hex_Editor_Neo/LaSat_lst.h +++ b/source/Information/FileStructures_for_HHD_Hex_Editor_Neo/LaSat_lst.h @@ -22,7 +22,9 @@ public struct LaSat uint8 header[28]; struct { - uint16 u1[3]; + uint16 u1; + uint16 zero1; + uint16 zero2; uint16 sid; uint16 u2; uint16 pcrPid; @@ -53,5 +55,5 @@ public struct LaSat } satellites[30]; } structured; } dataBlock; - uint8 suffix_0A_0D[2]; + uint8 suffix_0A_0D[2]; // this may or may not be present, also additional data may follow, which should be kept as-is }; \ No newline at end of file diff --git a/source/Spike.LgWebOs5/PhilipsXmlStatsCollector.cs b/source/Spike.LgWebOs5/PhilipsXmlStatsCollector.cs new file mode 100644 index 0000000..bbad80f --- /dev/null +++ b/source/Spike.LgWebOs5/PhilipsXmlStatsCollector.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ChanSort.Api; +using ChanSort.Loader.Philips; + +namespace Spike.PhilipsXml +{ + class PhilipsXmlStatsCollector + { + static void Main() + { + using var w = new StreamWriter(@"d:\sources\chansort\testfiles_philips\stats.txt"); + var dirs = new[] {"100.0", "105.0", "110.0"}; + foreach (var dir in dirs) + ProcessDir(Path.Combine(@"d:\sources\chansort\testfiles_philips", dir), w); + } + + private static void ProcessDir(string dir, StreamWriter w) + { + foreach (var bak in Directory.GetFiles(dir, "*.bak")) + File.Copy(bak, bak.Replace(".bak", ""), true); + + foreach (var subdir in Directory.GetDirectories(dir)) + ProcessDir(subdir, w); + + var file = Path.Combine(dir, "chanLst.bin"); + if (File.Exists(file)) + ProcessFile(file, w); + } + + private static void ProcessFile(string file, StreamWriter w) + { + var sb = new StringBuilder(); + sb.Append(file); + try + { + var p = new PhilipsPlugin(); + var ser = p.CreateSerializer(file); + ser.Load(); + int totalChans = 0; + var conseq = true; + var inOrder = true; + var hasFav = false; + var srcSum = new int[5]; + var typeSum = new int[4]; + foreach (var list in ser.DataRoot.ChannelLists) + { + if (list.IsMixedSourceFavoritesList) + continue; + totalChans += list.Channels.Count; + var lastNr = 0; + var chanCountBySrc = new int[5,4]; + foreach (var c in list.Channels) + { + inOrder &= c.OldProgramNr >= lastNr; + if (!inOrder) + { + } + conseq &= c.OldProgramNr == lastNr + 1; + if (!conseq) + { + } + lastNr = c.OldProgramNr; + hasFav |= c.GetOldPosition(1) != -1; + var s = c.SignalSource; + var i0 = (s & SignalSource.Antenna) != 0 ? 1 : (s & SignalSource.Cable) != 0 ? 2 : (s & SignalSource.Sat) != 0 ? 3 : (s & SignalSource.IP) != 0 ? 4 : 0; + var i1 = (s & SignalSource.Tv) != 0 ? 1 : (s & SignalSource.Radio) != 0 ? 2 : (s & SignalSource.Data) != 0 ? 3 : 0; + ++chanCountBySrc[i0, i1]; + ++srcSum[i0]; + ++typeSum[i1]; + } + } + + sb.Append($"\t{totalChans}"); + foreach(var n in srcSum) + sb.Append("\t").Append(n); + foreach (var n in typeSum) + sb.Append("\t").Append(n); + sb.Append($"\t{inOrder}\t{conseq}\t{hasFav}"); + } + catch (Exception ex) + { + sb.Append("\t").Append(ex.Message); + } + w.WriteLine(sb.ToString()); + } + } +} diff --git a/source/Spike.LgWebOs5/Spike.LgWebOs5.csproj b/source/Spike.LgWebOs5/Spikes.csproj similarity index 92% rename from source/Spike.LgWebOs5/Spike.LgWebOs5.csproj rename to source/Spike.LgWebOs5/Spikes.csproj index 7ea8310..d1ec151 100644 --- a/source/Spike.LgWebOs5/Spike.LgWebOs5.csproj +++ b/source/Spike.LgWebOs5/Spikes.csproj @@ -74,7 +74,8 @@ - + + @@ -86,6 +87,10 @@ {dccffa08-472b-4d17-bb90-8f513fc01392} ChanSort.Api + + {1f52b5ec-a2f1-4e53-9e1a-4658296c5bb5} + ChanSort.Loader.Philips + \ No newline at end of file diff --git a/source/Spike.LgWebOs5/Program.cs b/source/Spike.LgWebOs5/WebOs5StatsCollector.cs similarity index 97% rename from source/Spike.LgWebOs5/Program.cs rename to source/Spike.LgWebOs5/WebOs5StatsCollector.cs index bb629a2..7a2ab5c 100644 --- a/source/Spike.LgWebOs5/Program.cs +++ b/source/Spike.LgWebOs5/WebOs5StatsCollector.cs @@ -9,11 +9,17 @@ using Newtonsoft.Json; namespace Spike.LgWebOs5 { - class Program + class WebOs5StatsCollector { private static string basedir; static void Main(string[] args) + { + CollectLgWebOs5Stats(args); + } + + #region CollectLgWebOs5Stats() + static void CollectLgWebOs5Stats(string[] args) { basedir = args.Length > 0 ? args[0] : @"d:\sources\chansort\testfiles_lg"; @@ -44,7 +50,9 @@ namespace Spike.LgWebOs5 ProcessWebOs5Files(basedir, csv); } + #endregion + #region ProcessWebOs5Files private static void ProcessWebOs5Files(string dir, StreamWriter csv) { var files = Directory.GetFiles(dir, "GlobalClone*.tll"); @@ -61,6 +69,7 @@ namespace Spike.LgWebOs5 foreach (var subdir in Directory.GetDirectories(dir)) ProcessWebOs5Files(subdir, csv); } + #endregion #region ProcessFile() private static string ProcessFile(string file) @@ -192,6 +201,7 @@ namespace Spike.LgWebOs5 } #endregion + #region Dup() private static string Dup(string str, int count) { var sb = new StringBuilder(str.Length * count); @@ -199,6 +209,7 @@ namespace Spike.LgWebOs5 sb.Append(str); return sb.ToString(); } + #endregion } #region class ChanListStats diff --git a/source/changelog.md b/source/changelog.md index a53affc..ad6f58c 100644 --- a/source/changelog.md +++ b/source/changelog.md @@ -1,10 +1,11 @@ ChanSort Change Log =================== -TBD -- improved Linux/Wine performance -- minor fixes ("File / File information" didn't ignore deleted channels when counting duplicates) +2021-07-27 +- Philips ChannelMap\_100: fixed reading/writing favorites - updated Swiss reference lists with new ONID-TSID-SID for SRF info HD and RSI LA HD +- improved Linux/Wine performance +- "File / File information" now ignores deleted channels when counting duplicates 2021-07-26 - user interface can now be toggled between