Files
ChanSort/source/ChanSort.Loader.VDR/Serializer.cs
hbeham 43cfca4d0b - when appending unsorted channels during save, they are now set to
"hidden" and "skipped/unselectable"
- reference lists: the satellite orbital position is no longer used
  to match channels. (Samsung J series does not provide that info).
- Samsung J series: favorite lists are no longer individually sortable.
  (The same Pr# is used for all favorite lists).
- Samsung J series: deleting channels now physically removes them from
  the file. (The TV might automatically append them again when it finds
  them in the DVB data stream).
- Samsung J series: editing of channel names is now enabled.
- Samsung J series: favorite E is now also available
2015-06-13 18:37:59 +02:00

80 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(SignalSource.DvbT | SignalSource.DvbC | SignalSource.DvbS | SignalSource.AnalogC | SignalSource.AnalogT | SignalSource.Tv | SignalSource.Radio, "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 (Channels channelInfo in this.allChannels.GetChannelsByNewOrder())
{
file.WriteLine(channelInfo.confLine);
}
}
}
#endregion
#region GetFileInformation()
public override string GetFileInformation()
{
StringBuilder sb = new StringBuilder();
sb.Append(base.GetFileInformation());
return sb.ToString();
}
#endregion
}
}