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
23 // Get the correct Appcast and set input.
\r
24 XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));
\r
25 string result = nodeItem.InnerXml;
\r
27 // Regular Expressions
\r
28 Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");
\r
29 Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");
\r
31 Build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
\r
32 Version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
\r
33 DownloadFile = nodeItem["windows"].InnerText;
\r
34 DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
\r
43 /// Read the RSS file.
\r
45 /// <param name="rssReader"></param>
\r
46 private static XmlNode readRss(XmlReader rssReader)
\r
48 XmlNode nodeItem = null;
\r
49 XmlNode nodeChannel = null;
\r
50 XmlNode nodeRss = null;
\r
52 XmlDocument rssDoc = new XmlDocument();
\r
53 rssDoc.Load(rssReader);
\r
55 foreach (XmlNode t in rssDoc.ChildNodes)
\r
57 if (t.Name == "rss")
\r
61 if (nodeRss != null)
\r
62 foreach (XmlNode t in nodeRss.ChildNodes)
\r
64 if (t.Name == "channel")
\r
68 if (nodeChannel != null)
\r
69 foreach (XmlNode t in nodeChannel.ChildNodes)
\r
71 if (t.Name == "item")
\r
79 /// Get Information about an update to HandBrake
\r
81 public Uri DescriptionUrl { get; set; }
\r
84 /// Get HandBrake's version from the appcast.xml file.
\r
86 public string Version { get; set; }
\r
89 /// Get HandBrake's Build from the appcast.xml file.
\r
91 public string Build { get; set; }
\r
94 /// Get's the URL for update file.
\r
96 public string DownloadFile { get; set; }
\r