Beispiel #1
0
        //******************************** Static Functions **************************************
        public static List <RssEpisode> GetRssEpisodesFromXDoc(XDocument doc, int feedItemId)
        {   //used in AddFeedItem and RefreshEpisodes
            var episodes = new List <RssEpisode>();

            try
            {
                foreach (var channel in doc.Descendants("channel"))
                {
                    foreach (var item in channel.Descendants("item"))
                    {
                        var imageLink       = RssFeedHelper.GetITunesImageUriFromXElement(item);
                        var imageFileName   = Path.GetFileName(imageLink);
                        var podcastLink     = RssFeedHelper.GetEnclosureUriFromXElement(item.Element("enclosure"));
                        var podcastFileName = Path.GetFileName(podcastLink);
                        var episode         = new RssEpisode
                        {
                            FeedItemId            = feedItemId,
                            Author                = RssFeedHelper.ConvertXElementToString(item.Element("author")),
                            Description           = RssFeedHelper.ConvertXElementToString(item.Element("description")),
                            PubDate               = RssFeedHelper.ConvertXElementToDateTime(item.Element("pubDate")),
                            Title                 = RssFeedHelper.ConvertXElementToString(item.Element("title")),
                            LinkUrl               = RssFeedHelper.ConvertXElementToString(item.Element("link")),
                            ImageLink             = imageLink,
                            ImageFileName         = imageFileName,
                            EnclosureLink         = podcastLink,
                            PodcastFileName       = podcastFileName,
                            IsDownloaded          = IsDownloadedEnum.NotDownloaded,
                            CurrentPosition       = 0,
                            Duration              = 0, //reset to correct size when downloaded
                            PodcastFileSize       = 0, //reset to correct size when downloaded
                            IsPlaying             = IsPlayingEnum.NotStarted,
                            PlayPauseDownloadIcon = IconFont.FileDownload
                        };
                        episodes.Add(episode);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("GetRssEpisodesFromXDoc Error " + ex.Message);
            }
            return(episodes);
        }
Beispiel #2
0
        public static FeedItem GetFeedItemFromXDoc(XDocument doc, string uri)
        {
            var feedItem = new FeedItem();

            //populate feedItem
            foreach (var channel in doc.Descendants("channel"))
            {
                if (channel != null)
                {
                    var imageLink     = RssFeedHelper.GetImageUriFromXElement(channel.Element("image"));
                    var imageFileName = Path.GetFileName(imageLink);
                    feedItem.Text          = RssFeedHelper.ConvertXElementToString(channel.Element("title"));
                    feedItem.Description   = RssFeedHelper.ConvertXElementToString(channel.Element("description"));
                    feedItem.Link          = uri;
                    feedItem.ImageLink     = imageLink;
                    feedItem.ImageFileName = imageFileName;
                    feedItem.LastCheck     = DateTime.Now; //save LastCheck
                }
            }
            return(feedItem);
        }