async Task ParseAsync(Windows.Data.Xml.Dom.XmlDocument document, bool notify, bool checkDownloads) { try { GetLocalImage(); var channel = document.GetElementsByTagName("channel")[0]; var tempList = new List <Episode>(); foreach (var currentItem in channel.ChildNodes) { if (currentItem.NodeName != "item") { continue; } var item = currentItem as Windows.Data.Xml.Dom.XmlElement; var episode = new Episode { Link = item.GetChildNodeTextValue("link", ""), Title = item.GetChildNodeTextValue("title", "").Sanitize(), Subtitle = item.GetChildNodeTextValue("itunes:subtitle", "").Sanitize(), Author = item.GetChildNodeTextValue("itunes:author", "").Sanitize(), Summary = item.GetChildNodeTextValue("description", "").SanitizeAsHTML(), Enclosure = item.GetChildNodeAttribute("enclosure", "url", ""), PictureUrl = item.GetChildNodeAttribute("itunes:image", "href", ""), DeclaredDuration = item.GetChildNodeTextValue("itunes:duration", ""), Keywords = item.GetChildNodeTextValue("itunes:keywords", ""), PublicationDate = item.GetChildNodeTextValue("pubDate", "").TryParseAsDateTime(), PodcastFeedUrl = FeedUrl }; var length = item.GetChildNodeAttribute("enclosure", "length", ""); double estimatedLength; if (Double.TryParse(length, out estimatedLength)) { episode.EstimatedFileSize = estimatedLength; } if (!episode.DeclaredDuration.Contains(":")) { episode.DeclaredDuration = ""; } var itunesSummary = item.GetChildNodeTextValue("itunes:summary", "").SanitizeAsHTML(); if (itunesSummary.Length > episode.Summary.Length) { episode.Summary = itunesSummary; } var contentSummary = item.GetChildNodeTextValue("content:encoded", "").SanitizeAsHTML(); if (contentSummary.Length > episode.Summary.Length) { episode.Summary = contentSummary; } if (string.IsNullOrEmpty(episode.Author)) { episode.Author = Title; } if (string.IsNullOrEmpty(episode.Enclosure)) { episode.Enclosure = episode.Link; } if (string.IsNullOrEmpty(episode.PictureUrl)) { episode.PictureUrl = LocalImage; } episode.Clean(); tempList.Add(episode); } var addedEpisodes = new List <Episode>(); var indexToInject = 0; foreach (var episode in tempList.OrderByDescending(e => e.PublicationDate)) { var inLibraryEpisode = Episodes.FirstOrDefault(e => e.Enclosure == episode.Enclosure); if (inLibraryEpisode != null) { inLibraryEpisode.Author = episode.Author; inLibraryEpisode.DeclaredDuration = episode.DeclaredDuration; inLibraryEpisode.Keywords = episode.Keywords; inLibraryEpisode.Link = episode.Link; inLibraryEpisode.PictureUrl = episode.PictureUrl; inLibraryEpisode.PodcastFeedUrl = episode.PodcastFeedUrl; inLibraryEpisode.Title = episode.Title; inLibraryEpisode.Subtitle = episode.Subtitle; inLibraryEpisode.Summary = episode.Summary; inLibraryEpisode.PublicationDate = episode.PublicationDate; inLibraryEpisode.EstimatedFileSize = episode.EstimatedFileSize; continue; } await DispatchManager.RunOnDispatcherAsync(() => { Episodes.Insert(indexToInject, episode); }); indexToInject++; addedEpisodes.Add(episode); if (notify && IsInLibrary && LocalSettings.Instance.Notifications) { Messenger.Notify(string.Format(LocalSettings.Instance.NotificationMessage, episode.Title), Title, "", LocalImage); } } if (addedEpisodes.Count > 0 && IsInLibrary && AppSettings.Instance.AutomaticallyAddNewEpisodeToPlaylist) { await DispatchManager.RunOnDispatcherAsync(() => { var reversedAddedEpisodes = addedEpisodes.OrderBy(e => e.PublicationDate).ToList(); if (Playlist.CurrentPlaylist != null) { Playlist.CurrentPlaylist.AddEpisodes(reversedAddedEpisodes); } else { Playlist.EpisodesToAdd.AddRange(reversedAddedEpisodes); } }); } LocalSettings.Instance.NewEpisodesCount += addedEpisodes.Count; if (checkDownloads) { CheckForAutomaticDownloads(); } if (toExecuteWhenReady != null) { toExecuteWhenReady(); toExecuteWhenReady = null; } } catch { await Messenger.ErrorAsync(StringsHelper.Error_UnableToParseRSS + " (" + Title + ")"); } }