Files
ChanSort/source/ChanSort.Loader.VDR/Serializer.cs
hbeham 0cf97fe76c - UHD channels using ServiceType 0x9F are now recognized as TV channels (fixes an issue with Panasonic lists where these channels did not show up and their numbers were assigned multiple times)
- ChannelList.SignalSource and DataRoot.GetChannelList(SignalSource) are now handled so that if all bits of a given Mask are left 0, the list will accept anything.
  i.e. if Tv/Radio/Data is left 0, the list can contain all of them as well as channels that have neither of the 3 bits set.
- added basic unit tests for each loader to ensure test files have the expected numbers of channels in the various sub lists
2019-08-29 16:57:20 +02:00

82 lines
2.1 KiB
C#

using System.IO;
using System.Text;
using ChanSort.Api;
namespace ChanSort.Loader.VDR
{
class Serializer : SerializerBase
{
private readonly ChannelList allChannels = new ChannelList(0, "All");
#region ctor()
public Serializer(string inputFile) : base(inputFile)
{
DepencencyChecker.AssertVc2010RedistPackageX86Installed();
this.Features.ChannelNameEdit = ChannelNameEditMode.None;
this.DataRoot.SortedFavorites = false;
//this.DataRoot.SupportedFavorites = new Favorites();
this.DataRoot.AddChannelList(this.allChannels);
}
#endregion
public override string DisplayName { get { return "VDR channels .conf Loader"; } }
#region Load()
public override void Load()
{
this.ReadChannels();
}
#endregion
#region ReadChannels()
private void ReadChannels()
{
string line;
int pos = 0;
using (StreamReader file = new StreamReader(this.FileName))
{
while ((line = file.ReadLine()) != null)
{
ChannelInfo channel = new Channels(pos, line, this.DataRoot);
this.DataRoot.AddChannel(this.allChannels, channel);
pos++;
}
}
}
#endregion
#region Save()
public override void Save(string tvOutputFile)
{
if (tvOutputFile != this.FileName)
{
File.Copy(this.FileName, tvOutputFile);
this.FileName = tvOutputFile;
}
using (StreamWriter file = new StreamWriter(tvOutputFile))
{
foreach (ChannelInfo channel in this.allChannels.GetChannelsByNewOrder())
{
// when a reference list was applied, the list may contain proxy entries for deleted channels, which must be ignored
if (channel is Channels vdrChannel)
file.WriteLine(vdrChannel.confLine);
}
}
}
#endregion
#region GetFileInformation()
public override string GetFileInformation()
{
StringBuilder sb = new StringBuilder();
sb.Append(base.GetFileInformation());
return sb.ToString();
}
#endregion
}
}