2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace Handbrake.Functions
\r
10 using System.Text.RegularExpressions;
\r
14 /// Appcast Reader - Used for parsing HandBrakes update file
\r
16 public class AppcastReader
\r
19 /// Gets Information about an update to HandBrake
\r
21 public Uri DescriptionUrl { get; private set; }
\r
24 /// Gets HandBrake's version from the appcast.xml file.
\r
26 public string Version { get; private set; }
\r
29 /// Gets HandBrake's Build from the appcast.xml file.
\r
31 public string Build { get; private set; }
\r
34 /// Gets the URL for update file.
\r
36 public string DownloadFile { get; private set; }
\r
39 /// Get the build information from the required appcasts. Run before accessing the public vars.
\r
41 /// <param name="input">
\r
44 public void GetInfo(string input)
\r
48 // Get the correct Appcast and set input.
\r
49 XmlNode nodeItem = ReadRss(new XmlTextReader(new StringReader(input)));
\r
50 string result = nodeItem.InnerXml;
\r
52 // Regular Expressions
\r
53 Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");
\r
54 Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");
\r
56 this.Build = ver.ToString().Replace("sparkle:version=", string.Empty).Replace("\"", string.Empty);
\r
57 this.Version = verShort.ToString().Replace("sparkle:shortVersionString=", string.Empty).Replace("\"",
\r
60 this.DownloadFile = nodeItem["windows"].InnerText;
\r
61 this.DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
\r
70 /// Read the RSS file.
\r
72 /// <param name="rssReader">
\r
78 private static XmlNode ReadRss(XmlReader rssReader)
\r
80 XmlNode nodeItem = null;
\r
81 XmlNode nodeChannel = null;
\r
82 XmlNode nodeRss = null;
\r
84 XmlDocument rssDoc = new XmlDocument();
\r
85 rssDoc.Load(rssReader);
\r
87 foreach (XmlNode t in rssDoc.ChildNodes)
\r
89 if (t.Name == "rss")
\r
95 if (nodeRss != null)
\r
97 foreach (XmlNode t in nodeRss.ChildNodes)
\r
99 if (t.Name == "channel")
\r
106 if (nodeChannel != null)
\r
108 foreach (XmlNode t in nodeChannel.ChildNodes)
\r
110 if (t.Name == "item")
\r