From: <moi...@us...> - 2007-07-25 13:37:34
|
Revision: 761 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=761&view=rev Author: moiristo Date: 2007-07-25 06:37:32 -0700 (Wed, 25 Jul 2007) Log Message: ----------- version 0.9 Modified Paths: -------------- trunk/plugins/UitzendingGemist/Readme.txt trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.Designer.cs trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.cs trunk/plugins/UitzendingGemist/UitGemist/NLGemist.cs trunk/plugins/UitzendingGemist/UitGemist/NLSecondScreen.cs trunk/plugins/UitzendingGemist/UitGemist/RTLGemist.cs trunk/plugins/UitzendingGemist/UitGemist/ShowWaitCursor.cs trunk/plugins/UitzendingGemist/UitGemist/TienGemist.cs trunk/plugins/UitzendingGemist/UitGemist/TienSecondScreen.cs trunk/plugins/UitzendingGemist/UitGemist/UitGemist.csproj trunk/plugins/UitzendingGemist/UitGemist/UitGemistMain.cs Added Paths: ----------- trunk/plugins/UitzendingGemist/UitGemist/MultipartForm.cs trunk/plugins/UitzendingGemist/UitGemist/TienLogin.cs trunk/plugins/UitzendingGemist/images/hover_nlgemist.png trunk/plugins/UitzendingGemist/images/hover_rtlgemist.png trunk/plugins/UitzendingGemist/images/hover_tiengemist.png trunk/plugins/UitzendingGemist/images/nlgemist.png trunk/plugins/UitzendingGemist/images/tiengemist.png Modified: trunk/plugins/UitzendingGemist/Readme.txt =================================================================== --- trunk/plugins/UitzendingGemist/Readme.txt 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/Readme.txt 2007-07-25 13:37:32 UTC (rev 761) @@ -3,25 +3,28 @@ This plugin for MediaPortal makes it possible to browse and watch the -internet streams provided by uitzendinggemist.nl and www.rtl.nl. +internet streams provided by uitzendinggemist.nl,www.rtl.nl and tien.tv. This plugin is a frontend to the website and allows the user watch these streams from within Mediaportal. - installation: +- Use Dukus's MPInstaller utility (available in the plugins/utilities download section) to install the plugin -- Unpack -- Use Dukus's MPInstaller utility (available in the plugins/utilities download section) to install the plugin. Be sure to use the 0.2.2_SVN MPI when you are using the latest MP snapshot. +usage: +- First go to the configuration pane and choose default speed +- To be able to watch Tien emissions: + - Get an account at http://www.tien.tv (it's free!) + - Enter the account data in the 'Tien Account' tab -bugs needed to be fixed -- After an emission finishes, MP isn't notified and will not go back to the menu. -(you have to stop the playback manually) +thanks: +A big thanks to ZipperZip for letting me use his original Uitzending_Gemist Plugin code. -thanks: +0.9 +- Added support for Tien Gemist! +- Some minor changes +- No PM3 skin for TienGemist yet -A big thanks to ZipperZip for letting me use his Uitzending_Gemist Plugin code. - 0.8 - Fixed the TopTen screen of RTLGemist - Recompiled against the latest SVN Modified: trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.Designer.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.Designer.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.Designer.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -33,7 +33,17 @@ this.groupBox1 = new System.Windows.Forms.GroupBox(); this.okBtn = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.Speed = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.passBox = new System.Windows.Forms.MaskedTextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.userBox = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.Speed.SuspendLayout(); + this.tabPage2.SuspendLayout(); this.SuspendLayout(); // // sbBtn @@ -62,7 +72,7 @@ // this.groupBox1.Controls.Add(this.bbBtn); this.groupBox1.Controls.Add(this.sbBtn); - this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Location = new System.Drawing.Point(6, 6); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(169, 70); this.groupBox1.TabIndex = 2; @@ -71,7 +81,7 @@ // // okBtn // - this.okBtn.Location = new System.Drawing.Point(12, 88); + this.okBtn.Location = new System.Drawing.Point(12, 129); this.okBtn.Name = "okBtn"; this.okBtn.Size = new System.Drawing.Size(75, 23); this.okBtn.TabIndex = 3; @@ -81,27 +91,102 @@ // // button1 // - this.button1.Location = new System.Drawing.Point(93, 88); + this.button1.Location = new System.Drawing.Point(93, 129); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; this.button1.Text = "Cancel"; this.button1.UseVisualStyleBackColor = true; - + this.button1.Click += new System.EventHandler(this.button1_Click); // + // tabControl1 + // + this.tabControl1.AccessibleName = ""; + this.tabControl1.Controls.Add(this.Speed); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(262, 111); + this.tabControl1.TabIndex = 5; + this.tabControl1.Tag = ""; + // + // Speed + // + this.Speed.Controls.Add(this.groupBox1); + this.Speed.Location = new System.Drawing.Point(4, 22); + this.Speed.Name = "Speed"; + this.Speed.Padding = new System.Windows.Forms.Padding(3); + this.Speed.Size = new System.Drawing.Size(254, 85); + this.Speed.TabIndex = 0; + this.Speed.Text = "Speed"; + this.Speed.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.passBox); + this.tabPage2.Controls.Add(this.label2); + this.tabPage2.Controls.Add(this.label1); + this.tabPage2.Controls.Add(this.userBox); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(254, 85); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Tien Account"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // passBox + // + this.passBox.Location = new System.Drawing.Point(77, 45); + this.passBox.Name = "passBox"; + this.passBox.PasswordChar = '*'; + this.passBox.Size = new System.Drawing.Size(164, 20); + this.passBox.TabIndex = 3; + this.passBox.UseSystemPasswordChar = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 48); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(59, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Password: "; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(61, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Username: "; + // + // userBox + // + this.userBox.Location = new System.Drawing.Point(77, 16); + this.userBox.Name = "userBox"; + this.userBox.Size = new System.Drawing.Size(164, 20); + this.userBox.TabIndex = 0; + // // ConfigurationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(246, 120); + this.ClientSize = new System.Drawing.Size(292, 156); + this.Controls.Add(this.tabControl1); this.Controls.Add(this.button1); this.Controls.Add(this.okBtn); - this.Controls.Add(this.groupBox1); this.Name = "ConfigurationForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "UitzendingGemist Configuration"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.Speed.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); this.ResumeLayout(false); } @@ -113,5 +198,12 @@ private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button okBtn; private System.Windows.Forms.Button button1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage Speed; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox userBox; + private System.Windows.Forms.MaskedTextBox passBox; + private System.Windows.Forms.Label label2; } } \ No newline at end of file Modified: trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/ConfigurationForm.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -22,6 +22,10 @@ this.sbBtn.Checked = !broadband; this.bbBtn.Checked = broadband; + + string[] account = ShowWaitCursor.getTienAccount(); + userBox.Text = account[0]; + passBox.Text = account[1]; } private void okBtn_Click(object sender, EventArgs e) @@ -36,8 +40,16 @@ if(broadband) writer.SetValue("settings", "broadband", "yes"); else writer.SetValue("settings", "broadband", "no"); + + writer.SetValue("settings", "tienUser", userBox.Text); + writer.SetValue("settings", "tienPassword", passBox.Text); } this.Dispose(true); } + + private void button1_Click(object sender, EventArgs e) + { + this.Dispose(true); + } } } \ No newline at end of file Added: trunk/plugins/UitzendingGemist/UitGemist/MultipartForm.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/MultipartForm.cs (rev 0) +++ trunk/plugins/UitzendingGemist/UitGemist/MultipartForm.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -0,0 +1,337 @@ +using System; +using System.Net; +using System.Text; +using System.IO; +using System.Collections; +using MediaPortal.GUI.Library; + +namespace MediaPortal.GUI.UitGemist +{ + /// <summary> + /// Allow the transfer of data files using the W3C's specification + /// for HTTP multipart form data. Microsoft's version has a bug + /// where it does not format the ending boundary correctly. + /// Written by: gre...@no... + /// </summary> + public class MultipartForm + { + /// <summary> + /// Holds any form fields and values that you + /// wish to transfer with your data. + /// </summary> + private ArrayList coFormFields; + /// <summary> + /// Used mainly to avoid passing parameters to other routines. + /// Could have been local to sendFile(). + /// </summary> + protected HttpWebRequest coRequest; + /// <summary> + /// Used if we are testing and want to output the raw + /// request, minus http headers, out to a file. + /// </summary> + System.IO.Stream coFileStream; + /// <summary> + /// Difined to build the form field data that is being + /// passed along with the request. + /// </summary> + static string CONTENT_DISP = "Content-Disposition: form-data; name="; + /// <summary> + /// Allows you to specify the specific version of HTTP to use for uploads. + /// The dot NET stuff currently does not allow you to remove the continue-100 header + /// from 1.1 and 1.0 currently has a bug in it where it adds the continue-100. MS + /// has sent a patch to remove the continue-100 in HTTP 1.0. + /// </summary> + public Version TransferHttpVersion + {get{return coHttpVersion;}set{coHttpVersion=value;}} + Version coHttpVersion; + + /// <summary> + /// Used to change the content type of the file being sent. + /// Currently defaults to: text/xml. Other options are + /// text/plain or binary + /// </summary> + public string FileContentType + {get{return coFileContentType;}set{coFileContentType=value;}} + string coFileContentType; + + /// <summary> + /// Initialize our class for use to send data files. + /// </summary> + /// <param name="url">The web address of the recipient of the data transfer.</param> + public MultipartForm(string url) + { + URL = url; + coFormFields = new ArrayList(); + ResponseText = new StringBuilder(); + BufferSize = 1024 * 10; + BeginBoundary = "---------------------------4089736519495"; + TransferHttpVersion = HttpVersion.Version11; + } + //---------- BEGIN PROPERTIES SECTION ---------- + string _BeginBoundary; + /// <summary> + /// The string that defines the begining boundary of + /// our multipart transfer as defined in the w3c specs. + /// This method also sets the Content and Ending + /// boundaries as defined by the w3c specs. + /// </summary> + public string BeginBoundary + { + get{return _BeginBoundary;} + set + { + _BeginBoundary =value; + ContentBoundary = "--" + BeginBoundary; + EndingBoundary = ContentBoundary + "--"; + } + } + /// <summary> + /// The string that defines the content boundary of + /// our multipart transfer as defined in the w3c specs. + /// </summary> + protected string ContentBoundary + {get{return _ContentBoundary;}set{_ContentBoundary=value;}} + string _ContentBoundary; + /// <summary> + /// The string that defines the ending boundary of + /// our multipart transfer as defined in the w3c specs. + /// </summary> + protected string EndingBoundary + {get{return _EndingBoundary;}set{_EndingBoundary=value;}} + string _EndingBoundary; + /// <summary> + /// The cookies returned to us after the transfer is completed. + /// </summary> + public string ResponseCookies + { get { return _ResponseCookies; } set { _ResponseCookies = value; } } + string _ResponseCookies; + /// <summary> + /// The data returned to us after the transfer is completed. + /// </summary> + public StringBuilder ResponseText + {get{return _ResponseText;}set{_ResponseText=value;}} + StringBuilder _ResponseText; + /// <summary> + /// The web address of the recipient of the transfer. + /// </summary> + public string URL + {get{return _URL;}set{_URL = value;}} + string _URL; + /// <summary> + /// Allows us to determine the size of the buffer used + /// to send a piece of the file at a time out the IO + /// stream. Defaults to 1024 * 10. + /// </summary> + public int BufferSize + {get{return _BufferSize;}set{_BufferSize = value;}} + int _BufferSize; + //---------- END PROPERTIES SECTION ---------- + /// <summary> + /// Used to signal we want the output to go to a + /// text file verses being transfered to a URL. + /// </summary> + /// <param name="path"></param> + public void setFilename(string path) + { + coFileStream = new System.IO.FileStream(path,FileMode.Create,FileAccess.Write); + } + /// <summary> + /// Allows you to add some additional field data to be + /// sent along with the transfer. This is usually used + /// for things like userid and password to validate the + /// transfer. + /// </summary> + /// <param name="key">The form field name</param> + /// <param name="str">The form field value</param> + public void setField(string key, string str) + { + coFormFields.Add(new string[]{key,str}); + } + /// <summary> + /// Determines if we have a file stream set, and returns either + /// the HttpWebRequest stream of the file. + /// </summary> + /// <returns></returns> + public virtual System.IO.Stream getStream() + { + System.IO.Stream io; + if( null == coFileStream ) + io = coRequest.GetRequestStream(); + else + io = coFileStream; + return io; + } + /// <summary> + /// Here we actually make the request to the web server and + /// retrieve it's response into a text buffer. + /// </summary> + public virtual void getResponse() + { + if( null == coFileStream ) + { + System.IO.Stream io; + HttpWebResponse oResponse; + + oResponse = (HttpWebResponse)coRequest.GetResponse(); + if( null != oResponse ) + { + _ResponseCookies = oResponse.GetResponseHeader("Set-Cookie"); + io = oResponse.GetResponseStream(); + StreamReader sr = new StreamReader(io); + string str; + ResponseText.Length = 0; + while( (str = sr.ReadLine()) != null ) + ResponseText.Append(str); + oResponse.Close(); + } + else + throw new Exception("MultipartForm: Error retrieving server response"); + } + } + /// <summary> + /// Transmits a file to the web server stated in the + /// URL property. You may call this several times and it + /// will use the values previously set for fields and URL. + /// </summary> + /// <param name="aFilename">The full path of file being transfered.</param> + public void sendFile(string aFilename) + { + // The live of this object is only good during + // this function. Used mainly to avoid passing + // around parameters to other functions. + coRequest = (HttpWebRequest) WebRequest.Create(URL); + // Set use HTTP 1.0 or 1.1. + coRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; nl; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5"; + coRequest.ProtocolVersion = TransferHttpVersion; + coRequest.Method = "POST"; + coRequest.ContentType = "multipart/form-data; boundary=" + BeginBoundary; + coRequest.KeepAlive = true; + string strFields = getFormfields(); + string strFileHdr = getFileheader(aFilename); + string strFileTlr = getFiletrailer(); + FileInfo info = new FileInfo(aFilename); + coRequest.ContentLength = strFields.Length + + strFileHdr.Length + + strFileTlr.Length + + info.Length; + System.IO.Stream io; + io = getStream(); + writeString(io,strFields); + writeString(io,strFileHdr); + this.writeFile(io, aFilename); + writeString(io,strFileTlr); + getResponse(); + io.Close(); + // End the life time of this request object. + coRequest = null; + } + + public void sendForm() + { + // The live of this object is only good during + // this function. Used mainly to avoid passing + // around parameters to other functions. + coRequest = (HttpWebRequest)WebRequest.Create(URL); + // Set use HTTP 1.0 or 1.1. + coRequest.ProtocolVersion = TransferHttpVersion; + coRequest.AllowAutoRedirect = false; + coRequest.MaximumAutomaticRedirections = 30; + coRequest.Method = "POST"; + coRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; nl; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5"; + coRequest.ContentType = "multipart/form-data; boundary=" + BeginBoundary; + coRequest.KeepAlive = true; + string strFields = getFormfields(); + string strTlr = getTrailer(); + coRequest.ContentLength = strFields.Length + strTlr.Length; + System.IO.Stream io; + io = getStream(); + writeString(io, strFields); + writeString(io, strTlr); + getResponse(); + io.Close(); + // End the life time of this request object. + coRequest = null; + } + /// <summary> + /// Mainly used to turn the string into a byte buffer and then + /// write it to our IO stream. + /// </summary> + /// <param name="io">The io stream for output.</param> + /// <param name="str">The data to write.</param> + public void writeString(System.IO.Stream io, string str) + { + byte[] PostData = System.Text.Encoding.ASCII.GetBytes(str); + io.Write(PostData,0,PostData.Length); + } + /// <summary> + /// Builds the proper format of the multipart data that + /// contains the form fields and their respective values. + /// </summary> + /// <returns>The data to send in the multipart upload.</returns> + public string getFormfields() + { + string str=""; + IEnumerator myEnumerator = coFormFields.GetEnumerator(); + while ( myEnumerator.MoveNext() ) + { + string[] field = (string[]) myEnumerator.Current; + str += ContentBoundary + "\r\n" + + CONTENT_DISP + '"' + field[0] + "\"\r\n\r\n" + + field[1] + "\r\n"; + } + return str; + } + /// <summary> + /// Returns the proper content information for the + /// file we are sending. + /// </summary> + /// <remarks> + /// Hits Patel reported a bug when used with ActiveFile. + /// Added semicolon after sendfile to resolve that issue. + /// Tested for compatibility with IIS 5.0 and Java. + /// </remarks> + /// <param name="aFilename"></param> + /// <returns></returns> + public string getFileheader(string aFilename) + { + return ContentBoundary + "\r\n" + + CONTENT_DISP + + "\"sendfile\"; filename=\"" + + Path.GetFileName(aFilename) + "\"\r\n" + + "Content-type: " + FileContentType + "\r\n\r\n"; + } + /// <summary> + /// Creates the proper ending boundary for the multipart upload. + /// </summary> + /// <returns>The ending boundary.</returns> + public string getFiletrailer() + { + return "\r\n" + EndingBoundary; + } + + public string getTrailer() + { + return EndingBoundary + "\r\n"; + } + + /// <summary> + /// Reads in the file a chunck at a time then sends it to the + /// output stream. + /// </summary> + /// <param name="io">The io stream to write the file to.</param> + /// <param name="aFilename">The name of the file to transfer.</param> + public void writeFile(System.IO.Stream io, string aFilename) + { + FileStream readIn = new FileStream(aFilename, FileMode.Open, FileAccess.Read); + readIn.Seek(0, SeekOrigin.Begin); // move to the start of the file + byte[] fileData = new byte[BufferSize]; + int bytes; + while( (bytes = readIn.Read(fileData,0, BufferSize)) > 0 ) + { + // read the file data and send a chunk at a time + io.Write(fileData,0,bytes); + } + readIn.Close(); + } + } +} Modified: trunk/plugins/UitzendingGemist/UitGemist/NLGemist.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/NLGemist.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/NLGemist.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -254,9 +254,8 @@ UrlsSecondScreen.Clear(); ViewFavorieten = false; - string result = wc.GetUrl(url, true); + string result = wc.GetUrl(url); - int i = 0; MatchCollection mc = Regex.Matches(result, @"title.\shref=.(?<url>.*?).>(?<name>.*?)<"); foreach (Match m in mc) @@ -365,12 +364,13 @@ Match m = Regex.Match(MainUrlBody, "id=." + search + ".*?</select>", RegexOptions.Singleline); string temp = m.Value; - MatchCollection mc = Regex.Matches(temp, @"value=.(?<url>\d*).*?.>(?<name>.*?)<"); + MatchCollection mc = Regex.Matches(temp, @"value=.(?<url>\d*).*?.>(?<name>.*?)<", RegexOptions.Singleline); foreach (Match m1 in mc) { NavUrls.Add("http://www.uitzendinggemist.nl/index.php/selectie?searchitem=" + search + "&" + search + "=" + m1.Groups["url"].Value); NavNames.Add(m1.Groups["name"].Value); } + NavNames.RemoveAt(0); NavUrls.RemoveAt(0); } @@ -484,7 +484,7 @@ string result = m.Value; int i = 0; - MatchCollection mc = Regex.Matches(result, @"img\ssrc=.(?<image>.*?.png).*?href=.(?<url2>/index.php.*?).\s.*?>(?<name>.*?)<"); + MatchCollection mc = Regex.Matches(result, @"<a\shref=.(?<url2>.*?).\sclass=.title.*?img\ssrc=.(?<image>.*?.png).*?class=.title.>(?<name>.*?)</a>", RegexOptions.Singleline); foreach (Match m1 in mc) { ImageUrls.Add(@"http://www.uitzendinggemist.nl"+m1.Groups["image"].Value); @@ -496,7 +496,7 @@ i++; } i = 0; - mc = Regex.Matches(result, @"(http://player.*?).\starget"); + mc = Regex.Matches(result, @"(http://player.*?).\starget", RegexOptions.Singleline); foreach(Match m1 in mc) { Urls.Add(m1.Groups[1].Value); @@ -504,7 +504,7 @@ i++; } i= 0; - mc = Regex.Matches(result, @"margin:5px..>(.*?)<"); + mc = Regex.Matches(result, @"margin:5px..>(.*?)<", RegexOptions.Singleline); foreach (Match m1 in mc) { Plot.Add(m1.Groups[1].Value); Modified: trunk/plugins/UitzendingGemist/UitGemist/NLSecondScreen.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/NLSecondScreen.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/NLSecondScreen.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -112,7 +112,7 @@ Waardering.Clear(); StreamUrl.Clear(); - string result = NLGemist.wc.GetUrl(url, true); + string result = NLGemist.wc.GetUrl(url); result = NLGemist.ConvertString(result); //get image @@ -143,7 +143,7 @@ if (moreEmissions) { string series2url = url.Replace(@"/index.php/serie", @"/index.php/serie2"); - GetAfleveringen(NLGemist.wc.GetUrl(series2url, true), out moreEmissions); + GetAfleveringen(NLGemist.wc.GetUrl(series2url), out moreEmissions); } } Modified: trunk/plugins/UitzendingGemist/UitGemist/RTLGemist.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/RTLGemist.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/RTLGemist.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -455,7 +455,7 @@ //sw.Close(); int i = 0; - MatchCollection mc = Regex.Matches(result, @"target=._parent.*?href=.(?<url>.*?.xml).*?>(?<name>.*?)</a>"); + MatchCollection mc = Regex.Matches(result, @"<a.*?href=.(?<url>.*?.xml).*?>(?<name>.*?)</a>"); if (mc.Count == 0) Log.Info("UitGemist: No emissions found"); foreach (Match m1 in mc) { Modified: trunk/plugins/UitzendingGemist/UitGemist/ShowWaitCursor.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/ShowWaitCursor.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/ShowWaitCursor.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using MediaPortal.Dialogs; using MediaPortal.GUI.Library; @@ -15,10 +16,8 @@ private string result = String.Empty; private string workUrl = String.Empty; private bool _workerCompleted = true; - private bool Cookies = false; - private string agent = "Mozilla/4.0 (compatible; MSIE 6.0; WindowsNT 5.0; .NET CLR 1 .1.4322)"; + private string agent = "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"; private string postType = "application/x-www-form-urlencoded"; - private string secondUrl = String.Empty; private HttpWebRequest firstRequest = null; private HttpWebResponse firstResponse = null; private Stream recstream = null; @@ -67,10 +66,9 @@ return result; } - public string GetUrl(string url, bool useCookies) + public string GetTienUrl(string url, bool showWait) { - Cookies = useCookies; - secondUrl = url; + workUrl = url; if (_workerCompleted) { @@ -78,18 +76,26 @@ BackgroundWorker worker = new BackgroundWorker(); - worker.DoWork += new DoWorkEventHandler(DownloadWorker); + worker.DoWork += new DoWorkEventHandler(TienDownloadWorker); worker.RunWorkerAsync(url); using (WaitCursor cursor = new WaitCursor()) { while (_workerCompleted == false) - GUIWindowManager.Process(); + { + if(showWait) GUIWindowManager.Process(); + } } } return result; } + public string GetTienUrl(string url) + { + return GetTienUrl(url, true); + } + + private void XMLDownloadWorker(object sender, DoWorkEventArgs e) { System.Uri url = new System.Uri(workUrl); @@ -100,7 +106,7 @@ { WebClient client = new WebClient(); client.Encoding = Encoding.GetEncoding("iso-8859-1"); - client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); + client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"); Stream data = client.OpenRead(url); StreamReader reader = new StreamReader(data,client.Encoding); result = reader.ReadToEnd(); @@ -118,39 +124,85 @@ } } - public void DownloadWorker(object sender, DoWorkEventArgs e) + public void TienDownloadWorker(object sender, DoWorkEventArgs e) { - if (Cookies==false) + // Make the request + HttpWebRequest firstRequest = (HttpWebRequest)WebRequest.Create(workUrl); + firstRequest.UserAgent = agent; + firstRequest.ContentType = postType; + firstRequest.CookieContainer = new CookieContainer(); + + string[] account = getTienAccount(); + + Cookie c = new Cookie(); + c.Domain = "www.tien.tv"; + c.Name = "u"; + c.Value = account[0]; + firstRequest.CookieContainer.Add(c); + + Cookie c2 = new Cookie(); + c2.Domain = "www.tien.tv"; + c2.Name = "p"; + c2.Value = account[1]; + firstRequest.CookieContainer.Add(c2); + + Cookie c3 = new Cookie(); + c3.Domain = "www.tien.tv"; + c3.Name = "loggedinsession"; + c3.Value = "true"; + firstRequest.CookieContainer.Add(c3); + + // Add login cookies, if any + if (TienLogin.loginCookies != null) { - firstRequest = (HttpWebRequest)WebRequest.Create(workUrl); - firstRequest.UserAgent = agent; - firstRequest.ContentType = postType; - firstRequest.CookieContainer = new CookieContainer(); - firstResponse = (HttpWebResponse) - firstRequest.GetResponse(); - recstream = firstResponse.GetResponseStream(); + string[] cookie = TienLogin.loginCookies.Split(new char[] { '=', ';' }); + Cookie c4 = new Cookie(); + c4.Domain = "www.tien.tv"; + c4.Name = cookie[0]; + c4.Value = cookie[1]; + c4.Path = cookie[cookie.Length - 1]; + firstRequest.CookieContainer.Add(c4); } - if (Cookies == true) - { - HttpWebRequest secondRequest = (HttpWebRequest)WebRequest.Create(secondUrl); - secondRequest.UserAgent = agent; - secondRequest.ContentType = postType; - secondRequest.CookieContainer = new CookieContainer(); - //Cookie c = new Cookie(); - //c.Domain = "player.omroep.nl"; - //c.Name = "player_instellingen"; - //c.Value = "formaat:wmv&kwaliteit:bb"; + HttpWebResponse firstResponse = (HttpWebResponse)firstRequest.GetResponse(); + recstream = firstResponse.GetResponseStream(); + + readResult(); + firstResponse.Close(); + _workerCompleted = true; + } - //secondRequest.CookieContainer.Add(c); + public void DownloadWorker(object sender, DoWorkEventArgs e) + { - CookieCollection cookies = firstResponse.Cookies; - secondRequest.CookieContainer.Add(cookies); + firstRequest = (HttpWebRequest)WebRequest.Create(workUrl); + firstRequest.UserAgent = agent; + firstRequest.ContentType = postType; + firstRequest.CookieContainer = new CookieContainer(); - HttpWebResponse secondResponse = (HttpWebResponse)secondRequest.GetResponse(); - recstream = secondResponse.GetResponseStream(); - //secondResponse.Close(); - } + Cookie c = new Cookie(); + c.Domain = "www.uitzendinggemist.nl"; + c.Name = "CheckUGCookie"; + c.Path = "/index.php/"; + c.Value = "true"; + firstRequest.CookieContainer.Add(c); + + Cookie c2 = new Cookie(); + c2.Domain = "www.uitzendinggemist.nl"; + c2.Name = "UGSES"; + c2.Value = "i6e59muv44i4h6m9lfa1h1lip6"; + firstRequest.CookieContainer.Add(c2); + + firstResponse = (HttpWebResponse) + firstRequest.GetResponse(); + recstream = firstResponse.GetResponseStream(); + + readResult(); + _workerCompleted = true; + } + + public void readResult() + { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; @@ -169,11 +221,9 @@ } while (count > 0); + recstream.Close(); + result = sb.ToString(); - Cookies = false; - //recstream.Close(); - - _workerCompleted = true; } public string DownloadImage(string url) @@ -182,13 +232,15 @@ { WebClient wc = new WebClient(); string filename = url.Substring(url.LastIndexOf("/") + 1); + wc.DownloadFile(url, @"thumbs\MPTemp-" + filename); while (System.IO.File.Exists(@"thumbs\MPTemp-" + filename) != true) GUIWindowManager.Process(); return @"thumbs\MPTemp-" + filename; } - catch (Exception) + catch (Exception e) { + Log.Info(e.Message); return string.Empty; } } @@ -201,6 +253,18 @@ return reader.GetValueAsBool("settings", "broadband", true); } } + + public static string[] getTienAccount() + { + string dir = Directory.GetCurrentDirectory(); + using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(dir + @"\UitGemist.xml", false)) + { + string[] s = new string[2]; + s[0] = reader.GetValueAsString("settings", "tienUser", ""); + s[1] = reader.GetValueAsString("settings", "tienPassword", ""); + return s; + } + } } } Modified: trunk/plugins/UitzendingGemist/UitGemist/TienGemist.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/TienGemist.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/TienGemist.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -16,10 +16,11 @@ { struct Program { - public string name; - public string ep; - public string date; - public string link; + public string name; + public string ep; + public string date; + public string link; + public string desc; } public class TienGemist : GUIWindow @@ -107,7 +108,9 @@ } if (control == facadeview) { - TienSecondScreen.Url = ((Program) favs[facadeview.SelectedListItemIndex]).link; + Program pSelected = (Program) progs[facadeview.SelectedListItemIndex]; + TienSecondScreen.ProgTitle = pSelected.name; + TienSecondScreen.Url = pSelected.link; GUIWindowManager.ActivateWindow(6804); } base.OnClicked(controlId, control, actionType); @@ -176,22 +179,30 @@ private void GetUitzendingen() { progs.Clear(); + ViewFavorieten = false; + ViewTopFifty = false; - string result = wc.GetXML(rootPage); + string result = TienGemist.wc.GetTienUrl(rootPage); + + Match m = Regex.Match(result, @"<select\sclass=.gx_overrules_selectionWidth.\sname=.selector_2.*?>(?<data>.*?)</select>", RegexOptions.Singleline); + result = "<root>" + m.Groups["data"].Value + "</root>"; + result = Regex.Replace(result, "<!--.*?-->", "", RegexOptions.Singleline); + result = result.Replace("SELECTED", ""); + result = result.Replace("&", "&"); + try { XPathDocument document = new XPathDocument(new System.IO.StringReader(result)); XPathNavigator navigator = document.CreateNavigator(); - XPathExpression programs = XPathExpression.Compile("//select[name='selector_2']//option"); //returns nodeset with rows per program + XPathExpression programs = XPathExpression.Compile("//option[position() != 1]"); //returns nodeset with rows per program - XPathNodeIterator nodes = navigator.Select(programs); while (nodes.MoveNext()) { XPathNavigator node = nodes.Current; Program p = new Program(); - p.name = node.SelectSingleNode(".").Value; + p.name = node.SelectSingleNode(".").Value.Trim(); p.link = node.SelectSingleNode("./@value").Value; progs.Add(p); } @@ -211,25 +222,44 @@ progs.Clear(); ViewFavorieten = false; - string result = wc.GetXML(url); + string result = wc.GetTienUrl(url); + Match m = Regex.Match(result,@"<div\sclass=.Element_4xflow.>(?<data>.*?)</div>",RegexOptions.Singleline); + result = "<root>" + m.Groups["data"].Value + "</root>"; + result = result.Replace("&", "&"); + + //FileStream fs = new FileStream("d:\\huh.txt", FileMode.Create, FileAccess.Write); + //StreamWriter sw = new StreamWriter(fs); + //try + //{ + // sw.Write(result); + //} + //finally + //{ + // if (sw != null) { sw.Close(); } + //} + try { XPathDocument document = new XPathDocument(new System.IO.StringReader(result)); XPathNavigator navigator = document.CreateNavigator(); - XPathExpression programs = XPathExpression.Compile("//table[class='Program']//tr"); //returns nodeset with rows per program - - + XPathExpression programs = XPathExpression.Compile("//table//tr"); //returns nodeset with rows per program + XPathNodeIterator nodes = navigator.Select(programs); while (nodes.MoveNext()) { - XPathNavigator node = nodes.Current; - Program p = new Program(); - p.name = node.SelectSingleNode("./td[1]/h1").Value; - p.ep = node.SelectSingleNode("./td[1]/h2").Value; - p.date = node.SelectSingleNode("./td[2]/h2").Value; - p.link = node.SelectSingleNode("./td[2]/a/@href").Value; - progs.Add(p); + try + { + XPathNavigator node = nodes.Current; + Program p = new Program(); + p.name = node.SelectSingleNode("./td[1]/h1").Value; + p.ep = node.SelectSingleNode("./td[1]/h2").Value; + p.date = node.SelectSingleNode("./td[2]/h2").Value; + p.link = node.SelectSingleNode("./td[2]/a/@href").Value; + progs.Add(p); + } + catch (NullReferenceException) { /* Last line only contains 1 td, so just ignore */ } } + Log.Info("UitGemist: Finished loading programs"); } catch (XmlException e) { @@ -243,14 +273,63 @@ public static string GetPlayUrl(string url) { - string page = wc.GetUrl(url); - Regex r = new Regex(@"var url =.(?<url>.*?);", RegexOptions.Multiline); + string[] login = ShowWaitCursor.getTienAccount(); + if (login[0].Trim().Equals("") || login[1].Trim().Equals("")) + { + GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + if (pDlgOK != null) + { + pDlgOK.SetHeading("Geen login gevonden"); + pDlgOK.SetLine(1, "U dient eerst uw inloggegevens in te"); + pDlgOK.SetLine(2, "voeren het het configuratiescherm"); + pDlgOK.DoModal(GUIWindowManager.ActiveWindowEx); + } + return null; + } + Log.Info("Trying to play: " + url); + + string page = wc.GetTienUrl(rootUrl + url); + Regex r = new Regex(@"var\surl\s=\s.(?<url>.*?).;", RegexOptions.Singleline); + Match m = r.Match(page); - Log.Debug("" + m.Success); - url = m.Groups[1].Value; - Log.Debug("url length:" + url.Length); - Log.Debug(url); + + int i = 0; + while (i<2 && !m.Success) + { + //Try to login + TienLogin.login(); + page = wc.GetTienUrl(rootUrl + url); + + //FileStream fs = new FileStream("d:\\huh.txt", FileMode.Create, FileAccess.Write); + //StreamWriter sw = new StreamWriter(fs); + //try + //{ + // sw.Write(page); + //} + //finally + //{ + // if (sw != null) { sw.Close(); } + //} + + m = r.Match(page); + i++; + } + + if (!m.Success) + { + GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + if (pDlgOK != null) + { + pDlgOK.SetHeading("Inloggen mislukt"); + pDlgOK.SetLine(1, "Controleer uw inloggegevens"); + pDlgOK.DoModal(GUIWindowManager.ActiveWindowEx); + } + return null; + } + + url = m.Groups["url"].Value; + //Log.Info("Found URL: " + url); url = ConvertString(url); return url; @@ -259,18 +338,20 @@ /// Fills the facadeview with item /// </summary> /// <param name="names">labels for the items</param> - private void ShowList(ArrayList progs) + private void ShowList(ArrayList progz) { - ViewTopFifty = false; facadeview.View = GUIFacadeControl.ViewMode.List; facadeview.Clear(); - foreach (Object o in progs) + + foreach (Object o in progz) { Program p = (Program)o; GUIListItem item = new GUIListItem(); item.Label = p.name; - if(p.ep != null) item.Label2 = p.ep; - if(p.date != null) item.Label3 = p.date; + + String date = p.date; + if (date != null) item.Label2 = date.Substring(0,date.LastIndexOf(" ")); + //if(p.ep != null) item.Label3 = p.ep; item.IsFolder = true; Util.Utils.SetDefaultIcons(item); facadeview.Add(item); @@ -369,6 +450,7 @@ /// </summary> private void ShowTopFifty() { + ViewTopFifty = true; GetUitzending(rootPage); } @@ -389,7 +471,5 @@ } - - - + } \ No newline at end of file Added: trunk/plugins/UitzendingGemist/UitGemist/TienLogin.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/TienLogin.cs (rev 0) +++ trunk/plugins/UitzendingGemist/UitGemist/TienLogin.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -0,0 +1,90 @@ +using System.Net; +using System.Text; +using System.IO; +using System; +using MediaPortal.Dialogs; +using MediaPortal.GUI.Library; + +namespace MediaPortal.GUI.UitGemist +{ + public class TienLogin + { + public static string loginCookies; + + public static bool login() + { + /** + * <form name="f177717f" + * action="http://www.tien.tv/web/form" + * method="post" encType="multipart/form-data"> + * + * <input type="hidden" name="ff" value="432453" /> + *<input type="hidden" name="abort" value="" /> + *<input type="hidden" name="formpartcode" value="abort"/> + *<input type="hidden" name="formelement" value="432453" /> + *<input type="hidden" name="element" value="177717" /> + *<input type="hidden" name="form" value="432414" /> + *<input type="hidden" name="pageid" value="54581" /> + *<input type="hidden" name="originalurl" value="http://www.tien.tv/web/show?id=54585&langid=43&aflid=8747&cfe=432453&ff=432453&progid=1923&show=true" /> + *<input type="hidden" name="errorurl" value="http://www.tien.tv/web/show?id=54585&langid=43&aflid=8747&cfe=432453&ff=432453&formerror=432453&progid=1923&show=true" /> + *<INPUT type="hidden" value="f432473" name="formpartcode"/> + *<INPUT type="hidden" value="$USERNAME$" name="f432473" /> + *<INPUT type="hidden" value="f432474" name="formpartcode"/> + *<INPUT type="hidden" value="$PASSWORD$" name="f432474" /> + *<INPUT type="hidden" value="f432479" name="formpartcode"/> + */ + string[] login = ShowWaitCursor.getTienAccount(); + + MultipartForm mp = new MultipartForm("http://www.tien.tv/web/form"); + mp.setField("ff", "432453"); + mp.setField("abort", ""); + mp.setField("formpartcode", "abort"); + mp.setField("formelement", "432453"); + mp.setField("element", "177717"); + mp.setField("form", "432414"); + mp.setField("pageid", "54581"); + mp.setField("originalurl", "http://www.tien.tv/web/show?id=54585&langid=43&aflid=8747&cfe=432453&ff=432453&progid=1923&show=true"); + mp.setField("errorurl", "http://www.google.nl"); + mp.setField("formpartcode", "f432473"); + mp.setField("f432473", login[0]); + mp.setField("formpartcode", "f432474"); + mp.setField("f432474", login[1]); + mp.setField("formpartcode", "f432479"); + mp.sendForm(); + loginCookies = mp.ResponseCookies; + + return true; + } + + public static bool logout() + { + //Not implemented yet; + return true; + } + + public static byte[] getFile(string filePath) + { + FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fs); + + byte[] fileRD = br.ReadBytes((int)fs.Length); + + br.Close(); + fs.Close(); + + return fileRD; + } + + public static byte[] StrToByteArray(string str) + { + System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); + return encoding.GetBytes(str); + } + + public static string ByteArrayToStr(byte[] dBytes) + { + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + return enc.GetString(dBytes); + } + } +} Modified: trunk/plugins/UitzendingGemist/UitGemist/TienSecondScreen.cs =================================================================== --- trunk/plugins/UitzendingGemist/UitGemist/TienSecondScreen.cs 2007-07-24 23:02:23 UTC (rev 760) +++ trunk/plugins/UitzendingGemist/UitGemist/TienSecondScreen.cs 2007-07-25 13:37:32 UTC (rev 761) @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Collections; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; @@ -7,6 +7,9 @@ using MediaPortal.Player; using MediaPortal.Dialogs; using MediaPortal.Playlists; +using System.Xml; +using System.Xml.XPath; +using System.IO; namespace MediaPortal.GUI.UitGemist { @@ -17,25 +20,14 @@ protected GUIListControl listview = null; [SkinControlAttribute(3)] protected GUIImage image = null; - //[SkinControlAttribute(3)] - //protected GUIImage imgPrgramma = null; - //[SkinControlAttribute(4)] - //protected GUILabelControl lblGenre = null; - //[SkinControlAttribute(5)] - //protected GUILabelControl lblOmroep = null; - //[SkinControlAttribute(6)] - //protected GUISelectButtonControl btnRubriek = null; - //#endregion public static string Url = string.Empty; - public static bool ViewVideo = false; - private string imageurl = string.Empty; - private StringCollection Datum = new StringCollection(); - private StringCollection Omschrijving = new StringCollection(); - private StringCollection Views = new StringCollection(); - private StringCollection Waardering = new StringCollection(); - private StringCollection StreamUrl = new StringCollection(); + public static string ProgTitle = string.Empty; + private string imageurl = string.Empty; + private int lastSelectedIndex = -1; + private ArrayList eps = new ArrayList(); + public override int GetID { get @@ -55,20 +47,24 @@ protected override void OnPageLoad() { - if (ViewVideo) - { - NLGemist.wc.GetUrl("http://www.uitzendinggemist.nl"); - GetInfo(Url); - ViewVideo = false; - } - else - { - GetInfo(Url); - } + lastSelectedIndex = -1; + GUIPropertyManager.SetProperty("#title", ProgTitle); + GUIPropertyManager.SetProperty("#plot", ""); + GetInfo(Url); Showlist(); base.OnPageLoad(); } + public override void OnAction(Action action) + { + if (action.wID == Action.ActionType.ACTION_STOP) + { + g_Player.Stop(); + } + + else base.OnAction(action); + } + protected override void OnPageDestroy(int new_windowId) { image.FileName = GUIGraphicsContext.Skin + @"\media\background.png"; @@ -80,11 +76,11 @@ if (control == listview) { string mmsurl = string.Empty; - mmsurl = NLGemist.GetPlayUrl(StreamUrl[listview.SelectedListItemIndex]); + mmsurl = TienGemist.GetPlayUrl(((Program)eps[listview.SelectedListItemIndex]).link); + if (mmsurl == null) return; GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); g_Player.FullScreen = true; - ViewVideo = true; g_Player.Play(mmsurl); } base.OnClicked(controlId, control, actionType); @@ -94,10 +90,23 @@ { if (message.Message == GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS || message.Message == GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED) { - if (listview.SelectedListItemIndex != -1) + int itemIndex = listview.SelectedListItemIndex; + if (itemIndex != lastSelectedIndex && itemIndex < listview.Count && itemIndex > -1) { - GUIPropertyManager.SetProperty("#rating", Waardering[listview.SelectedListItemIndex]); - GUIPropertyManager.SetProperty("#plotoutline", Omschrijving[listview.SelectedListItemIndex]); + // Get episode plot + + Program pSelected = (Program)eps[itemIndex]; + if (pSelected.desc == null) + { + string ep = TienGemist.wc.GetTienUrl(TienGemist.rootUrl + pSelected.link, false); + Match m = Regex.Match(ep, @"<p\sclass=.progomschrijving.>(?<plot>.*?)</p>", RegexOptions.Singleline); + + string desc = m.Groups["plot"].Value.Replace("<br>", "\n"); + if (desc != null) pSelected.desc = desc; + else pSelected.desc = ""; + } + GUIPropertyManager.SetProperty("#plot", pSelected.desc); + lastSelectedIndex = itemIndex; } } return base.OnMessage(message); @@ -105,107 +114,60 @@ private void GetInfo(string url) { - Datum.Clear(); - Views.Clear(); - Omschrijving.Clear(); - Waardering.Clear(); - StreamUrl.Clear(); + eps.Clear(); - string result = NLGemist.wc.GetUrl(url, true); - result = NLGemist.ConvertString(result); + string result = TienGemist.wc.GetTienUrl(TienGemist.rootUrl + url); - //get image - Match m = Regex.Match(result, @"<img\ssrc=.(http://gids.omroep.nl.*?.png)"); - imageurl = m.Groups[1].Value; - image.FileName = NLGemist.wc.DownloadImage(imageurl); + // Get the plot first + Match m = Regex.Match(result, @"<p\sclass=.progomschrijving.>(?<plot>.*?)</p>", RegexOptions.Singleline); + GUIPropertyManager.SetProperty("#plot", m.Groups["plot"].Value.Replace("<br>","\n")); - //get Programma-Naam - m = Regex.Match(result, @"<title>(.*?)</title>"); - GUIPropertyManager.SetProperty("#title", m.Groups[1].Value); + m = Regex.Match(result, @"<select\sclass=.gx_overrules_selectionWidth.\sname=.selector_3.*?>(?<data>.*?)</select>", RegexOptions.Singleline); + result = "<root>" + m.Groups["data"].Value + "</root>"; + result = Regex.Replace(result, "<!--.*?-->", "", RegexOptions.Singleline); + result = result.Replace("SELECTED", ""); + result = result.Replace("&", "&"); - //get Programma-omschrijving - m = Regex.Match(result, @"<p\sstyle=.margin-top.5px..>(.*?)<", RegexOptions.Singleline); - GUIPropertyManager.SetProperty("#plot", m.Groups[1].Value); - - //get Genre - m = Regex.Match(result, @"genre</b>.*?title=.(.*?).>", RegexOptions.Singleline); - GUIPropertyManager.SetProperty("#genre", m.Groups[1].Value); - - // get Omproep - m = Regex.Match(result, @"omroep</b>.*?title=.(.*?).>", RegexOptions.Singleline); - GUIPropertyManager.SetProperty("#credits", m.Groups[1].Value); - - // get Afleveringen - m = Regex.Match(result, @"tbody\sid=.afleveringen.>(.*?)</tbody>", RegexOptions.Singleline); - if (m.Success) + try { - string afleveringen = m.Groups[1].Value; + XPathDocument document = new XPathDocument(new System.IO.StringReader(result)); + XPathNavigator navigator = document.CreateNavigator(); + XPathExpression programs = XPathExpression.Compile("//option[position() != 1]"); //returns nodeset with rows per program - //get datum - MatchCollection mc = Regex.Matches(afleveringen, @"(\d{2}-\d{2}-\d{4})</td>"); - foreach (Match m1 in mc) + XPathNodeIterator nodes = navigator.Select(programs); + while (nodes.MoveNext()) { - Datum.Add(m1.Groups[1].Value); + XPathNavigator node = nodes.Current; + Program p = new Program(); + p.date = node.SelectSingleNode(".").Value.Trim(); + p.link = node.SelectSingleNode("./@value").Value; + eps.Add(p); } - - //get omschrijving - mc = Regex.Matches(afleveringen, @"(.*?).<a\shref=./index"); - foreach (Match m1 in mc) - { - Omschrijving.Add(m1.Groups[1].Value); - } - - //get views - mc = Regex.Matches(afleveringen, @"right.>(\d.*)... [truncated message content] |