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
42 /// Read the RSS file.
\r
44 /// <param name="rssReader"></param>
\r
45 private static XmlNode readRss(XmlReader rssReader)
\r
47 XmlNode nodeItem = null;
\r
48 XmlNode nodeChannel = null;
\r
49 XmlNode nodeRss = null;
\r
51 XmlDocument rssDoc = new XmlDocument();
\r
52 rssDoc.Load(rssReader);
\r
54 for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
\r
56 if (rssDoc.ChildNodes[i].Name == "rss")
\r
57 nodeRss = rssDoc.ChildNodes[i];
\r
60 if (nodeRss != null)
\r
61 for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
\r
63 if (nodeRss.ChildNodes[i].Name == "channel")
\r
64 nodeChannel = nodeRss.ChildNodes[i];
\r
67 if (nodeChannel != null)
\r
68 for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
\r
70 if (nodeChannel.ChildNodes[i].Name == "item")
\r
71 nodeItem = nodeChannel.ChildNodes[i];
\r
78 /// Get Information about an update to HandBrake
\r
80 public Uri descriptionUrl { get; set; }
\r
83 /// Get HandBrake's version from the appcast.xml file.
\r
85 public string version { get; set; }
\r
88 /// Get HandBrake's Build from the appcast.xml file.
\r
90 public string build { get; set; }
\r
93 /// Get's the URL for update file.
\r
95 public string downloadFile { get; set; }
\r