public void Start(ChannelItem channelItem) { HttpDownload download = new HttpDownload(_parent, channelItem.Guid, channelItem.Enclosure.Url); download.ResponseReceived += new ProgressChangedEventHandler(ResponseReceived); download.DownloadProgress += new ProgressChangedEventHandler(this.DownloadProgress); download.DownloadComplete += new RunWorkerCompletedEventHandler(this.DownloadComplete); if (_downloads.Contains(download.Guid) == false) { string filename = Path.Combine(channelItem.Channel.GetDirectory(), channelItem.Enclosure.GetFilename()); OdeoApplication.TraceMessage("Downloading file {0}...", channelItem.Enclosure.Url); _downloads.Add(download.Guid, download); download.Start(filename); } }
public void Process(Stream stream) { XmlTextReader rss = null; ChannelItem item = null; ChannelItemCollection items = new ChannelItemCollection(); Exception error = null; rss = new XmlTextReader(stream); rss.WhitespaceHandling = WhitespaceHandling.None; try { while (rss.Read()) { try { if (rss.IsStartElement()) { if (String.Compare(rss.Name, "title", true) == 0) this.Title = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "link", true) == 0) this.Link = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "description", true) == 0) this.Description = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "language", true) == 0) this.Language = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "ttl", true) == 0) this.TTL = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "item", true) == 0) { item = new ChannelItem(this); while ((String.Compare(rss.Name, "item", true) == 0 && rss.NodeType == XmlNodeType.EndElement) == false) { if (rss.Read() && rss.IsStartElement()) { if (String.Compare(rss.Name, "title", true) == 0) item.Title = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "link", true) == 0) item.Link = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "description", true) == 0) item.Description = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "guid", true) == 0) item.Guid = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "pubDate", true) == 0) item.PublicationDate = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "enclosure", true) == 0) { item.Enclosure.Url = XmlHelper.Decode(rss.GetAttribute("url")); try { item.Enclosure.Length = long.Parse(rss.GetAttribute("length")); } catch (Exception) { item.Enclosure.Length = 0; } item.Enclosure.Type = XmlHelper.Decode(rss.GetAttribute("type")); } else if (String.Compare(rss.Name, "itunes:author", true) == 0) item.Author = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "itunes:keywords", true) == 0) item.Keywords = XmlHelper.Decode(rss.ReadString()); else if (String.Compare(rss.Name, "media:thumbnail", true) == 0) { item.Thumbnail = new Thumbnail(item); item.Thumbnail.Url = XmlHelper.Decode(rss.GetAttribute("url")); try { item.Thumbnail.Height = int.Parse(rss.GetAttribute("height")); } catch (Exception) { item.Thumbnail.Height = 0; } try { item.Thumbnail.Width = int.Parse(rss.GetAttribute("width")); } catch (Exception) { item.Thumbnail.Width = 0; } } } } items.Add(item); } } } catch (XmlException ex) { if (error == null) { error = new XmlException(String.Format("An XML error occurred while processing {0}.", item.Title), ex); } } catch (Exception ex) { if (error == null) error = ex; } } } catch (Exception ex) { error = new Exception(String.Format("An unknown error occurred while processing {0}.", item.Title), ex); } finally { if (rss != null) rss.Close(); } if (error != null) throw error; _items.Merge(items); }
public Enclosure(ChannelItem parent) { _channelItem = parent; }
public Thumbnail(ChannelItem parent) { _parent = parent; }