First verified MediaPortal export.
authorStephaneLenclud
Fri, 15 May 2015 17:28:51 +0200
changeset 301a00603ec28
parent 2 d73e99c5333c
child 4 8372aa8d6292
First verified MediaPortal export.
Adding orbital position filter.
Channel.cs
KingOfSat.cs
MainForm.cs
MediaPortal.cs
     1.1 --- a/Channel.cs	Fri May 15 15:16:18 2015 +0200
     1.2 +++ b/Channel.cs	Fri May 15 17:28:51 2015 +0200
     1.3 @@ -63,6 +63,17 @@
     1.4  		//
     1.5  		public string TXT { get; set; }
     1.6  
     1.7 +        //////
     1.8 +	    public void Copy(Channel aChannel)
     1.9 +	    {
    1.10 +            PropertyInfo[] properties = typeof(Channel).GetProperties();
    1.11 +            foreach (PropertyInfo property in properties)
    1.12 +            {
    1.13 +                object value = property.GetValue(aChannel);
    1.14 +                property.SetValue(this,value);
    1.15 +            }	        
    1.16 +	    }
    1.17 +
    1.18  		//////
    1.19  		public override string ToString()
    1.20  		{
     2.1 --- a/KingOfSat.cs	Fri May 15 15:16:18 2015 +0200
     2.2 +++ b/KingOfSat.cs	Fri May 15 17:28:51 2015 +0200
     2.3 @@ -21,7 +21,7 @@
     2.4  		//
     2.5  		// Return:
     2.6  		//   List of channels parsed.		
     2.7 -		public static List<Channel> Parse(string aUrl)
     2.8 +		public static List<Channel> Parse(string aUrl, string aOrbitalPosition)
     2.9  		{
    2.10  			string kos = new WebClient().DownloadString(aUrl);
    2.11  			//Debug.Write(kos);
    2.12 @@ -39,7 +39,12 @@
    2.13  				Channel common = new Channel();
    2.14  
    2.15  				//Parse channel details
    2.16 -				common.OrbitalPosition = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td > a > font").Get(0).InnerText);
    2.17 +				common.OrbitalPosition = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td > a > font").Get(0).InnerText).Trim();
    2.18 +			    if (common.OrbitalPosition != aOrbitalPosition)
    2.19 +			    {
    2.20 +                    //Wrong sat, skip
    2.21 +			        continue;
    2.22 +			    }
    2.23  				common.Satellite = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(2) > a").Get(0).InnerText);
    2.24  				common.Frequency = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(3)").Get(0).InnerText);
    2.25  				common.Polarisation = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(4)").Get(0).InnerText);
    2.26 @@ -82,7 +87,7 @@
    2.27  				{
    2.28  					Channel channel = new Channel();
    2.29  					//Initialize this channel with common properties on this frequency
    2.30 -					channel = common;
    2.31 +                    channel.Copy(common);
    2.32  
    2.33  					//Try and parse channel name
    2.34  					CQ cqChannelName = row.Cq().Find("td:nth-child(3) > a");
     3.1 --- a/MainForm.cs	Fri May 15 15:16:18 2015 +0200
     3.2 +++ b/MainForm.cs	Fri May 15 17:28:51 2015 +0200
     3.3 @@ -24,7 +24,7 @@
     3.4  
     3.5          private void buttonGenerate_Click(object sender, EventArgs e)
     3.6          {
     3.7 -	        List<Channel> channels=KingOfSat.Parse("http://en.kingofsat.net/pack-skygermany.php");
     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      }
     4.1 --- a/MediaPortal.cs	Fri May 15 15:16:18 2015 +0200
     4.2 +++ b/MediaPortal.cs	Fri May 15 17:28:51 2015 +0200
     4.3 @@ -163,10 +163,10 @@
     4.4  				AddAttribute(nodechannel, "IdChannel", channelId);
     4.5  				AddAttribute(nodechannel, "IsRadio", "False");
     4.6  				AddAttribute(nodechannel, "IsTv", "True");
     4.7 -				//AddAttribute(nodechannel, "LastGrabTime", channel.LastGrabTime);
     4.8 +                AddAttribute(nodechannel, "LastGrabTime", "2000-1-1 0:0:0");
     4.9  				//AddAttribute(nodechannel, "SortOrder", channel.SortOrder);
    4.10 -				//AddAttribute(nodechannel, "TimesWatched", channel.TimesWatched);
    4.11 -				//AddAttribute(nodechannel, "TotalTimeWatched", channel.TotalTimeWatched);
    4.12 +                //sAddAttribute(nodechannel, "TimesWatched", "0");
    4.13 +                AddAttribute(nodechannel, "TotalTimeWatched", "2000-1-1 0:0:0");
    4.14  				AddAttribute(nodechannel, "VisibleInGuide", "True");
    4.15  				AddAttribute(nodechannel, "DisplayName", channel.Name);
    4.16  				AddAttribute(nodechannel, "ChannelNumber", channelId);