# HG changeset patch # User StephaneLenclud # Date 1431887737 -7200 # Node ID bf908f6c7758bcf0cee2a43f4ea6ac831bd21fb7 # Parent 3061de2306d91ff681cccd18d9963d6e2cda81f5 Adding category override option, ID usage for name, hiding channels starting with '.'. Folding Movies and Series in a single category. Adding channel prefix removel. diff -r 3061de2306d9 -r bf908f6c7758 KingOfSat.cs --- a/KingOfSat.cs Sun May 17 19:36:48 2015 +0200 +++ b/KingOfSat.cs Sun May 17 20:35:37 2015 +0200 @@ -20,7 +20,7 @@ // // Return: // List of channels parsed. - public static List Parse(List aChannels, string aUrl, string aOrbitalPosition) + public static List Parse(List aChannels, string aUrl, string aOrbitalPosition, bool aUseChannelIdForName=false, string aCategoryOverride="") { //To avoid duplicated name Dictionary names = new Dictionary(); @@ -104,15 +104,28 @@ } } - string channelNameInnerText = cqChannelName.Get(0).InnerText; + string channelName = ""; + if (cqChannelName.Get(0).HasAttribute("title") && aUseChannelIdForName) + { + //We want to use the channel ID + channelName = cqChannelName.Get(0).GetAttribute("title"); + } + else + { + channelName = cqChannelName.Get(0).InnerText; + } + //We spend a lot of time trying to get this right until we found our answer in the following thread. //http://stackoverflow.com/questions/14057434/how-can-i-transform-string-to-utf-8-in-c //Decode HTML - channel.Name = WebUtility.HtmlDecode(channelNameInnerText); + channel.Name = WebUtility.HtmlDecode(channelName); //Convert from default encoding to UTF8 byte[] bytes = Encoding.Default.GetBytes(channel.Name); channel.Name = Encoding.UTF8.GetString(bytes); - if (channel.Name == "Name") + + + + if (channel.Name == "Name" || channel.Name == "Sorted by name") { //Skipping header rows continue; @@ -147,6 +160,13 @@ { channel.Category = "Other"; } + + //Override category if needed + if (aCategoryOverride != "") + { + channel.Category = aCategoryOverride; + } + //Skip the packages //Skip the encryptions channel.SID = WebUtility.HtmlDecode(row.Cq().Find("td:nth-child(8)").Get(0).InnerText).Trim(); @@ -182,6 +202,20 @@ break; //only allow one match at most } } + + string[] removePrefix = { "Id: " }; + + foreach (string item in removePrefix) + { + if (aName.StartsWith(item)) + { + aName = aName.Substring(item.Length, aName.Length - item.Length); + break; //only allow one match at most + } + } + + + aName = aName.Trim(); return aName; } @@ -268,6 +302,16 @@ channel.Category = "General"; } + if (channel.Category == "Movies") + { + channel.Category = "Movies & Series"; + } + + if (channel.Category == "Series") + { + channel.Category = "Movies & Series"; + } + //No corresponding HD channel, keep it then channels.Add(channel); diff -r 3061de2306d9 -r bf908f6c7758 MainForm.cs --- a/MainForm.cs Sun May 17 19:36:48 2015 +0200 +++ b/MainForm.cs Sun May 17 20:35:37 2015 +0200 @@ -25,11 +25,11 @@ private void buttonGenerate_Click(object sender, EventArgs e) { List channels = new List(); - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-skygermany.php", "19.2°E")); - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-hdplus.php", "19.2°E")); - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-arddigital.php", "19.2°E")); - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-zdfvision.php", "19.2°E")); - channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-tntsat.php", "19.2°E")); + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-skygermany.php", "19.2°E", true)); + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-hdplus.php", "19.2°E", true)); + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-arddigital.php", "19.2°E", true)); + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-zdfvision.php", "19.2°E", true)); + channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-tntsat.php", "19.2°E", true, "TNTSAT")); //Discard non HD channels we don't need channels = KingOfSat.CleanChannelList(channels); diff -r 3061de2306d9 -r bf908f6c7758 MediaPortal.cs --- a/MediaPortal.cs Sun May 17 19:36:48 2015 +0200 +++ b/MediaPortal.cs Sun May 17 20:35:37 2015 +0200 @@ -189,7 +189,7 @@ //AddAttribute(nodechannel, "SortOrder", channel.SortOrder); //AddAttribute(nodechannel, "TimesWatched", "0"); AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0"); - AddAttribute(nodechannel, "VisibleInGuide", "True"); + AddAttribute(nodechannel, "VisibleInGuide", !channel.Name.StartsWith(".")); AddAttribute(nodechannel, "DisplayName", channel.Name); AddAttribute(nodechannel, "ChannelNumber", channelId);