Adding channel name clean up.
Adding card mapping support but it's not working.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/.editorconfig Fri May 15 22:41:33 2015 +0200
1.3 @@ -0,0 +1,12 @@
1.4 +; Top-most EditorConfig file
1.5 +root = true
1.6 +
1.7 +; Unix-style newlines
1.8 +[*]
1.9 +end_of_line = crlf
1.10 +
1.11 +; 4-column tab indentation
1.12 +[*.cs]
1.13 +indent_style = space
1.14 +indent_size = 4
1.15 +
2.1 --- a/KingOfSat.cs Fri May 15 17:28:51 2015 +0200
2.2 +++ b/KingOfSat.cs Fri May 15 22:41:33 2015 +0200
2.3 @@ -65,7 +65,7 @@
2.4 common.Bitrate = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(10)").Get(0).InnerText);
2.5 if (common.Bitrate.Substring(0, ", ".Length) == ", ")
2.6 {
2.7 - common.Bitrate = common.Bitrate.Substring(", ".Length, common.Bitrate.Length - ", ".Length);
2.8 + common.Bitrate = common.Bitrate.Substring(", ".Length, common.Bitrate.Length - ", ".Length);
2.9 }
2.10 //
2.11 common.NetworkID = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(11)").Get(0).InnerText);
2.12 @@ -109,6 +109,9 @@
2.13 continue;
2.14 }
2.15
2.16 + //Make sure our channel name looks descent
2.17 + channel.Name = CleanChannelName(channel.Name);
2.18 +
2.19 //So we have a channel name get the other properties then
2.20 channel.Country = WebUtility.HtmlDecode(row.Cq().Find("td:nth-child(4)").Get(0).InnerText).Trim();
2.21 channel.Category = WebUtility.HtmlDecode(row.Cq().Find("td:nth-child(5)").Get(0).InnerText).Trim();
2.22 @@ -131,5 +134,23 @@
2.23
2.24 return channels;
2.25 }
2.26 +
2.27 + //
2.28 + public static string CleanChannelName(string aName)
2.29 + {
2.30 + aName.Trim();
2.31 + string[] remove = { "Germany", "Deutschland", "(Germany)", "(Deutschland)" };
2.32 +
2.33 + foreach (string item in remove)
2.34 + {
2.35 + if (aName.EndsWith(item))
2.36 + {
2.37 + aName = aName.Substring(0, aName.LastIndexOf(item));
2.38 + break; //only allow one match at most
2.39 + }
2.40 + }
2.41 + aName.Trim();
2.42 + return aName;
2.43 + }
2.44 }
2.45 }
3.1 --- a/MainForm.cs Fri May 15 17:28:51 2015 +0200
3.2 +++ b/MainForm.cs Fri May 15 22:41:33 2015 +0200
3.3 @@ -24,8 +24,17 @@
3.4
3.5 private void buttonGenerate_Click(object sender, EventArgs e)
3.6 {
3.7 + //List<Channel> channels = new List<Channel>();
3.8 List<Channel> channels=KingOfSat.Parse("http://en.kingofsat.net/pack-skygermany.php","19.2°E");
3.9 - MediaPortal.Export(channels,"channels.xml");
3.10 +
3.11 + //Declare tuner cards so that we don't need to create mapping manually after import
3.12 + List<string> tuners = new List<string>()
3.13 + {
3.14 + "3",
3.15 + "4"
3.16 + };
3.17 +
3.18 + MediaPortal.Export(channels, tuners, "channels.xml",false);
3.19 }
3.20 }
3.21 }
4.1 --- a/MediaPortal.cs Fri May 15 17:28:51 2015 +0200
4.2 +++ b/MediaPortal.cs Fri May 15 22:41:33 2015 +0200
4.3 @@ -144,7 +144,7 @@
4.4
4.5 }
4.6
4.7 - public static void Export(List<Channel> aChannels, string aFileName)
4.8 + public static void Export(List<Channel> aChannels, List<string> aTunerCards, string aFileName, bool aAddMapping)
4.9 {
4.10 XmlDocument xmlDoc = new XmlDocument();
4.11 XmlNode rootElement = xmlDoc.CreateElement("tvserver");
4.12 @@ -155,6 +155,7 @@
4.13 rootElement.AppendChild(nodechannels);
4.14
4.15 int channelId = 0;
4.16 + int channelMapId = 0;
4.17 foreach (Channel channel in aChannels)
4.18 {
4.19 channelId++;
4.20 @@ -163,14 +164,29 @@
4.21 AddAttribute(nodechannel, "IdChannel", channelId);
4.22 AddAttribute(nodechannel, "IsRadio", "False");
4.23 AddAttribute(nodechannel, "IsTv", "True");
4.24 - AddAttribute(nodechannel, "LastGrabTime", "2000-1-1 0:0:0");
4.25 + AddAttribute(nodechannel, "LastGrabTime", "2000-1-1 0:0:0");
4.26 //AddAttribute(nodechannel, "SortOrder", channel.SortOrder);
4.27 - //sAddAttribute(nodechannel, "TimesWatched", "0");
4.28 - AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0");
4.29 + //sAddAttribute(nodechannel, "TimesWatched", "0");
4.30 + AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0");
4.31 AddAttribute(nodechannel, "VisibleInGuide", "True");
4.32 AddAttribute(nodechannel, "DisplayName", channel.Name);
4.33 AddAttribute(nodechannel, "ChannelNumber", channelId);
4.34
4.35 + if (aAddMapping)
4.36 + {
4.37 + //I don't think we can get mapping to work without having corresponding server and card definition elements
4.38 + XmlNode nodeMaps = xmlDoc.CreateElement("mappings");
4.39 + foreach (string tuner in aTunerCards)
4.40 + {
4.41 + channelMapId++;
4.42 + XmlNode nodeMap = xmlDoc.CreateElement("map");
4.43 + AddAttribute(nodeMap, "IdCard", tuner);
4.44 + AddAttribute(nodeMap, "IdChannel", channelId);
4.45 + AddAttribute(nodeMap, "IdChannelMap", channelMapId);
4.46 + nodeMaps.AppendChild(nodeMap);
4.47 + }
4.48 + nodechannel.AppendChild(nodeMaps);
4.49 + }
4.50
4.51 XmlNode nodeTuningDetails = xmlDoc.CreateElement("TuningDetails");
4.52 XmlNode nodeTune = xmlDoc.CreateElement("tune");