First MP export draft.
2 using System.Collections.Generic;
3 using System.Diagnostics;
6 using System.Threading.Tasks;
14 public static string Polarisation(Channel aChannel)
16 switch (aChannel.Polarisation)
22 case "L": //Check that on KingOfSat
24 case "R": //Check that on KingOfSat
29 Debug.Write("WARNING: Unknown Polarisation " + aChannel.Polarisation + " for " + aChannel.Name + "\n");
44 public static string Modulation(Channel aChannel)
46 //Those can be worked out from TvLibrary FormDVBSTuningDetail.Designer.cs
48 switch (aChannel.Modulation)
56 Debug.Write("WARNING: Unknown modulation " + aChannel.Modulation + " for " + aChannel.Name + "\n");
102 public static string FEC(Channel aChannel)
104 //Those can be worked out from TvLibrary FormDVBSTuningDetail.Designer.cs
106 switch (aChannel.FEC)
139 Debug.Write("WARNING: Unknown FEC " + aChannel.FEC + " for " + aChannel.Name + "\n");
147 public static void Export(List<Channel> aChannels, string aFileName)
149 XmlDocument xmlDoc = new XmlDocument();
150 XmlNode rootElement = xmlDoc.CreateElement("tvserver");
151 AddAttribute(rootElement, "version", "1.0");
152 xmlDoc.AppendChild(rootElement);
153 //Create our channel element
154 XmlNode nodechannels = xmlDoc.CreateElement("channels");
155 rootElement.AppendChild(nodechannels);
158 foreach (Channel channel in aChannels)
161 XmlNode nodechannel = xmlDoc.CreateElement("channel");
162 AddAttribute(nodechannel, "GrabEpg", "True");
163 AddAttribute(nodechannel, "IdChannel", channelId);
164 AddAttribute(nodechannel, "IsRadio", "False");
165 AddAttribute(nodechannel, "IsTv", "True");
166 //AddAttribute(nodechannel, "LastGrabTime", channel.LastGrabTime);
167 //AddAttribute(nodechannel, "SortOrder", channel.SortOrder);
168 //AddAttribute(nodechannel, "TimesWatched", channel.TimesWatched);
169 //AddAttribute(nodechannel, "TotalTimeWatched", channel.TotalTimeWatched);
170 AddAttribute(nodechannel, "VisibleInGuide", "True");
171 AddAttribute(nodechannel, "DisplayName", channel.Name);
172 AddAttribute(nodechannel, "ChannelNumber", channelId);
175 XmlNode nodeTuningDetails = xmlDoc.CreateElement("TuningDetails");
176 XmlNode nodeTune = xmlDoc.CreateElement("tune");
177 AddAttribute(nodeTune, "IdChannel", channelId);
178 AddAttribute(nodeTune, "IdTuning", channelId);
179 AddAttribute(nodeTune, "Bandwidth", "8"); //Weird
180 AddAttribute(nodeTune, "ChannelNumber", "10000");
181 AddAttribute(nodeTune, "ChannelType", "3"); //Bad hard coding, does it means DVB-S
182 AddAttribute(nodeTune, "CountryId", "31"); //Is that Germany?
183 AddAttribute(nodeTune, "Diseqc", "0"); //Disabled
184 AddAttribute(nodeTune, "FreeToAir", "False"); //Can we get that from KingOfSat? Does it matter?
185 AddAttribute(nodeTune, "Frequency", ((Int32)(Convert.ToDouble(channel.Frequency)*1000)).ToString());
186 AddAttribute(nodeTune, "MajorChannel", "-1");
187 AddAttribute(nodeTune, "MinorChannel", "-1");
188 AddAttribute(nodeTune, "Modulation", Modulation(channel));
189 AddAttribute(nodeTune, "Name", channel.Name);
190 AddAttribute(nodeTune, "NetworkId", channel.NetworkID);
191 AddAttribute(nodeTune, "PmtPid", channel.PMT);
192 AddAttribute(nodeTune, "Polarisation", Polarisation(channel));
193 AddAttribute(nodeTune, "Provider", channel.Provider); //Does that matter? Should really be SKY or CSAT
194 AddAttribute(nodeTune, "ServiceId", channel.SID);
195 AddAttribute(nodeTune, "SwitchingFrequency", "11700000"); //Does it matter?
196 AddAttribute(nodeTune, "Symbolrate", channel.SymbolRate);
197 AddAttribute(nodeTune, "TransportId", channel.TransponderID);
198 AddAttribute(nodeTune, "TuningSource", "0"); //Is that needed?
199 AddAttribute(nodeTune, "VideoSource", "0"); //Is that needed?
200 AddAttribute(nodeTune, "AudioSource", "0"); //Is that needed?
201 AddAttribute(nodeTune, "IsVCRSignal", "False");
202 AddAttribute(nodeTune, "SatIndex", "-1");
203 AddAttribute(nodeTune, "InnerFecRate", FEC(channel));
204 AddAttribute(nodeTune, "Band", "0"); //Needed?
205 AddAttribute(nodeTune, "Pilot", "-1");
206 AddAttribute(nodeTune, "RollOff", "-1");
207 AddAttribute(nodeTune, "Url", "");
208 AddAttribute(nodeTune, "Bitrate", "0"); //Should we bother putting it in there?
209 nodeTuningDetails.AppendChild(nodeTune);
211 nodechannel.AppendChild(nodeTuningDetails);
213 nodechannels.AppendChild(nodechannel);
218 xmlDoc.Save(aFileName);
221 private static void AddAttribute(XmlNode node, string tagName, string tagValue)
223 XmlAttribute attr = node.OwnerDocument.CreateAttribute(tagName);
224 attr.InnerText = tagValue;
225 node.Attributes.Append(attr);
228 private static void AddAttribute(XmlNode node, string tagName, int tagValue)
230 AddAttribute(node, tagName, tagValue.ToString());
233 // store DateTime Values as strings. Improves readability
234 private static void AddAttribute(XmlNode node, string tagName, DateTime tagValue)
236 AddAttribute(node, tagName,
237 String.Format("{0}-{1}-{2} {3}:{4}:{5}", tagValue.Year, tagValue.Month, tagValue.Day, tagValue.Hour,
238 tagValue.Minute, tagValue.Second));
241 private static void AddAttribute(XmlNode node, string tagName, bool tagValue)
243 AddAttribute(node, tagName, tagValue.ToString());