1.1 --- a/KingOfSat.cs Sun May 17 19:36:48 2015 +0200
1.2 +++ b/KingOfSat.cs Sun May 17 20:35:37 2015 +0200
1.3 @@ -20,7 +20,7 @@
1.4 //
1.5 // Return:
1.6 // List of channels parsed.
1.7 - public static List<Channel> Parse(List<Channel> aChannels, string aUrl, string aOrbitalPosition)
1.8 + public static List<Channel> Parse(List<Channel> aChannels, string aUrl, string aOrbitalPosition, bool aUseChannelIdForName=false, string aCategoryOverride="")
1.9 {
1.10 //To avoid duplicated name
1.11 Dictionary<string, int> names = new Dictionary<string, int>();
1.12 @@ -104,15 +104,28 @@
1.13 }
1.14 }
1.15
1.16 - string channelNameInnerText = cqChannelName.Get(0).InnerText;
1.17 + string channelName = "";
1.18 + if (cqChannelName.Get(0).HasAttribute("title") && aUseChannelIdForName)
1.19 + {
1.20 + //We want to use the channel ID
1.21 + channelName = cqChannelName.Get(0).GetAttribute("title");
1.22 + }
1.23 + else
1.24 + {
1.25 + channelName = cqChannelName.Get(0).InnerText;
1.26 + }
1.27 +
1.28 //We spend a lot of time trying to get this right until we found our answer in the following thread.
1.29 //http://stackoverflow.com/questions/14057434/how-can-i-transform-string-to-utf-8-in-c
1.30 //Decode HTML
1.31 - channel.Name = WebUtility.HtmlDecode(channelNameInnerText);
1.32 + channel.Name = WebUtility.HtmlDecode(channelName);
1.33 //Convert from default encoding to UTF8
1.34 byte[] bytes = Encoding.Default.GetBytes(channel.Name);
1.35 channel.Name = Encoding.UTF8.GetString(bytes);
1.36 - if (channel.Name == "Name")
1.37 +
1.38 +
1.39 +
1.40 + if (channel.Name == "Name" || channel.Name == "Sorted by name")
1.41 {
1.42 //Skipping header rows
1.43 continue;
1.44 @@ -147,6 +160,13 @@
1.45 {
1.46 channel.Category = "Other";
1.47 }
1.48 +
1.49 + //Override category if needed
1.50 + if (aCategoryOverride != "")
1.51 + {
1.52 + channel.Category = aCategoryOverride;
1.53 + }
1.54 +
1.55 //Skip the packages
1.56 //Skip the encryptions
1.57 channel.SID = WebUtility.HtmlDecode(row.Cq().Find("td:nth-child(8)").Get(0).InnerText).Trim();
1.58 @@ -182,6 +202,20 @@
1.59 break; //only allow one match at most
1.60 }
1.61 }
1.62 +
1.63 + string[] removePrefix = { "Id: " };
1.64 +
1.65 + foreach (string item in removePrefix)
1.66 + {
1.67 + if (aName.StartsWith(item))
1.68 + {
1.69 + aName = aName.Substring(item.Length, aName.Length - item.Length);
1.70 + break; //only allow one match at most
1.71 + }
1.72 + }
1.73 +
1.74 +
1.75 +
1.76 aName = aName.Trim();
1.77 return aName;
1.78 }
1.79 @@ -268,6 +302,16 @@
1.80 channel.Category = "General";
1.81 }
1.82
1.83 + if (channel.Category == "Movies")
1.84 + {
1.85 + channel.Category = "Movies & Series";
1.86 + }
1.87 +
1.88 + if (channel.Category == "Series")
1.89 + {
1.90 + channel.Category = "Movies & Series";
1.91 + }
1.92 +
1.93
1.94 //No corresponding HD channel, keep it then
1.95 channels.Add(channel);
2.1 --- a/MainForm.cs Sun May 17 19:36:48 2015 +0200
2.2 +++ b/MainForm.cs Sun May 17 20:35:37 2015 +0200
2.3 @@ -25,11 +25,11 @@
2.4 private void buttonGenerate_Click(object sender, EventArgs e)
2.5 {
2.6 List<Channel> channels = new List<Channel>();
2.7 - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-skygermany.php", "19.2°E"));
2.8 - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-hdplus.php", "19.2°E"));
2.9 - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-arddigital.php", "19.2°E"));
2.10 - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-zdfvision.php", "19.2°E"));
2.11 - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-tntsat.php", "19.2°E"));
2.12 + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-skygermany.php", "19.2°E", true));
2.13 + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-hdplus.php", "19.2°E", true));
2.14 + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-arddigital.php", "19.2°E", true));
2.15 + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-zdfvision.php", "19.2°E", true));
2.16 + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-tntsat.php", "19.2°E", true, "TNTSAT"));
2.17
2.18 //Discard non HD channels we don't need
2.19 channels = KingOfSat.CleanChannelList(channels);
3.1 --- a/MediaPortal.cs Sun May 17 19:36:48 2015 +0200
3.2 +++ b/MediaPortal.cs Sun May 17 20:35:37 2015 +0200
3.3 @@ -189,7 +189,7 @@
3.4 //AddAttribute(nodechannel, "SortOrder", channel.SortOrder);
3.5 //AddAttribute(nodechannel, "TimesWatched", "0");
3.6 AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0");
3.7 - AddAttribute(nodechannel, "VisibleInGuide", "True");
3.8 + AddAttribute(nodechannel, "VisibleInGuide", !channel.Name.StartsWith("."));
3.9 AddAttribute(nodechannel, "DisplayName", channel.Name);
3.10 AddAttribute(nodechannel, "ChannelNumber", channelId);
3.11