3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
9 using System.Text.RegularExpressions;
\r
12 namespace Handbrake.Functions
\r
14 public class AppcastReader
\r
17 /// Get the build information from the required appcasts. Run before accessing the public vars.
\r
19 public void getInfo(string input)
\r
21 // Get the correct Appcast and set input.
\r
22 XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));
\r
23 string result = nodeItem.InnerXml;
\r
25 // Regular Expressions
\r
26 Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");
\r
27 Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
\r
29 build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
\r
30 version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
\r
31 downloadFile = nodeItem["windows"].InnerText;
\r
32 descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
\r
36 /// Read the RSS file.
\r
38 /// <param name="rssReader"></param>
\r
39 private static XmlNode readRss(XmlReader rssReader)
\r
41 XmlNode nodeItem = null;
\r
42 XmlNode nodeChannel = null;
\r
43 XmlNode nodeRss = null;
\r
45 XmlDocument rssDoc = new XmlDocument();
\r
46 rssDoc.Load(rssReader);
\r
48 for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
\r
50 if (rssDoc.ChildNodes[i].Name == "rss")
\r
51 nodeRss = rssDoc.ChildNodes[i];
\r
54 if (nodeRss != null)
\r
55 for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
\r
57 if (nodeRss.ChildNodes[i].Name == "channel")
\r
58 nodeChannel = nodeRss.ChildNodes[i];
\r
61 if (nodeChannel != null)
\r
62 for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
\r
64 if (nodeChannel.ChildNodes[i].Name == "item")
\r
65 nodeItem = nodeChannel.ChildNodes[i];
\r
72 /// Get Information about an update to HandBrake
\r
74 public Uri descriptionUrl { get; set; }
\r
77 /// Get HandBrake's version from the appcast.xml file.
\r
79 public string version { get; set; }
\r
82 /// Get HandBrake's Build from the appcast.xml file.
\r
84 public string build { get; set; }
\r
87 /// Get's the URL for update file.
\r
89 public string downloadFile { get; set; }
\r