# HG changeset patch # User StephaneLenclud # Date 1431703731 -7200 # Node ID 01a00603ec28d2dabf5350d25e5a6b1feb1c980e # Parent d73e99c5333caf6e4ae892de701f81b1215d4548 First verified MediaPortal export. Adding orbital position filter. diff -r d73e99c5333c -r 01a00603ec28 Channel.cs --- a/Channel.cs Fri May 15 15:16:18 2015 +0200 +++ b/Channel.cs Fri May 15 17:28:51 2015 +0200 @@ -63,6 +63,17 @@ // public string TXT { get; set; } + ////// + public void Copy(Channel aChannel) + { + PropertyInfo[] properties = typeof(Channel).GetProperties(); + foreach (PropertyInfo property in properties) + { + object value = property.GetValue(aChannel); + property.SetValue(this,value); + } + } + ////// public override string ToString() { diff -r d73e99c5333c -r 01a00603ec28 KingOfSat.cs --- a/KingOfSat.cs Fri May 15 15:16:18 2015 +0200 +++ b/KingOfSat.cs Fri May 15 17:28:51 2015 +0200 @@ -21,7 +21,7 @@ // // Return: // List of channels parsed. - public static List Parse(string aUrl) + public static List Parse(string aUrl, string aOrbitalPosition) { string kos = new WebClient().DownloadString(aUrl); //Debug.Write(kos); @@ -39,7 +39,12 @@ Channel common = new Channel(); //Parse channel details - common.OrbitalPosition = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td > a > font").Get(0).InnerText); + common.OrbitalPosition = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td > a > font").Get(0).InnerText).Trim(); + if (common.OrbitalPosition != aOrbitalPosition) + { + //Wrong sat, skip + continue; + } common.Satellite = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(2) > a").Get(0).InnerText); common.Frequency = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(3)").Get(0).InnerText); common.Polarisation = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(4)").Get(0).InnerText); @@ -82,7 +87,7 @@ { Channel channel = new Channel(); //Initialize this channel with common properties on this frequency - channel = common; + channel.Copy(common); //Try and parse channel name CQ cqChannelName = row.Cq().Find("td:nth-child(3) > a"); diff -r d73e99c5333c -r 01a00603ec28 MainForm.cs --- a/MainForm.cs Fri May 15 15:16:18 2015 +0200 +++ b/MainForm.cs Fri May 15 17:28:51 2015 +0200 @@ -24,7 +24,7 @@ private void buttonGenerate_Click(object sender, EventArgs e) { - List channels=KingOfSat.Parse("http://en.kingofsat.net/pack-skygermany.php"); + List channels=KingOfSat.Parse("http://en.kingofsat.net/pack-skygermany.php","19.2°E"); MediaPortal.Export(channels,"channels.xml"); } } diff -r d73e99c5333c -r 01a00603ec28 MediaPortal.cs --- a/MediaPortal.cs Fri May 15 15:16:18 2015 +0200 +++ b/MediaPortal.cs Fri May 15 17:28:51 2015 +0200 @@ -163,10 +163,10 @@ AddAttribute(nodechannel, "IdChannel", channelId); AddAttribute(nodechannel, "IsRadio", "False"); AddAttribute(nodechannel, "IsTv", "True"); - //AddAttribute(nodechannel, "LastGrabTime", channel.LastGrabTime); + AddAttribute(nodechannel, "LastGrabTime", "2000-1-1 0:0:0"); //AddAttribute(nodechannel, "SortOrder", channel.SortOrder); - //AddAttribute(nodechannel, "TimesWatched", channel.TimesWatched); - //AddAttribute(nodechannel, "TotalTimeWatched", channel.TotalTimeWatched); + //sAddAttribute(nodechannel, "TimesWatched", "0"); + AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0"); AddAttribute(nodechannel, "VisibleInGuide", "True"); AddAttribute(nodechannel, "DisplayName", channel.Name); AddAttribute(nodechannel, "ChannelNumber", channelId);