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
11 namespace Handbrake.Functions
\r
13 public class AppcastReader
\r
16 /// Get the build information from the required appcasts. Run before accessing the public vars.
\r
18 public void getInfo()
\r
20 // Get the correct Appcast and set input.
\r
21 XmlNode nodeItem = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable)) : readRss(new XmlTextReader(Properties.Settings.Default.appcast));
\r
22 string input = nodeItem.InnerXml;
\r
24 // Regular Expressions
\r
25 Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
\r
26 Match verShort = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
\r
28 build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
\r
29 version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
\r
30 downloadFile = nodeItem["windows"].InnerText;
\r
31 descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
\r
35 /// Read the RSS file.
\r
37 /// <param name="rssReader"></param>
\r
38 private static XmlNode readRss(XmlReader rssReader)
\r
40 XmlNode nodeItem = null;
\r
41 XmlNode nodeChannel = null;
\r
42 XmlNode nodeRss = null;
\r
44 XmlDocument rssDoc = new XmlDocument();
\r
45 rssDoc.Load(rssReader);
\r
47 for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
\r
49 if (rssDoc.ChildNodes[i].Name == "rss")
\r
50 nodeRss = rssDoc.ChildNodes[i];
\r
53 if (nodeRss != null)
\r
54 for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
\r
56 if (nodeRss.ChildNodes[i].Name == "channel")
\r
57 nodeChannel = nodeRss.ChildNodes[i];
\r
60 if (nodeChannel != null)
\r
61 for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
\r
63 if (nodeChannel.ChildNodes[i].Name == "item")
\r
64 nodeItem = nodeChannel.ChildNodes[i];
\r
71 /// Get Information about an update to HandBrake
\r
73 public Uri descriptionUrl { get; set; }
\r
76 /// Get HandBrake's version from the appcast.xml file.
\r
78 public string version { get; set; }
\r
81 /// Get HandBrake's Build from the appcast.xml file.
\r
83 public string build { get; set; }
\r
86 /// Get's the URL for update file.
\r
88 public string downloadFile { get; set; }
\r