Exemplo n.º 1
0
        private async void AddToLibraryMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem item = sender as MenuFlyoutItem;

            if (item != null)
            {
                entryToEdit = item.DataContext as SearchResponseEntry;
            }

            var flyout = RootGrid.Resources["AddToLibraryFlyout"] as Flyout;

            var listViewItem = ResultsListView.ContainerFromItem(entryToEdit) as GridViewItem;

            if (flyout != null)
            {
                var editor = ((FrameworkElement)flyout.Content).FindDescendantByName("AddToMyPodcastsEditor") as AddToMyPodcasts;

                WaitRingManager.IsWaitRingVisible = true;
                var podcast = await Podcast.ParseAsync(entryToEdit.feedUrl, false);

                WaitRingManager.IsWaitRingVisible = false;

                if (podcast != null)
                {
                    editor?.SetPodcast(podcast);
                    flyout.ShowAt(listViewItem);
                }
            }
        }
Exemplo n.º 2
0
        public static async Task <Podcast> ParseAsync(string url, bool checkDownloads, string login = null, string password = null)
        {
            try
            {
                var data = await CoreTools.DownloadStringAsync(url, true, login, password);

                var document = new Windows.Data.Xml.Dom.XmlDocument();

                try
                {
                    document.LoadXml(data);
                }
                catch
                {
                    data = await CoreTools.DownloadStringAsync(url, false, login, password);

                    document.LoadXml(data);
                }

                var channel = document.GetElementsByTagName("channel")[0] as Windows.Data.Xml.Dom.XmlElement;

                var result = new Podcast
                {
                    Title       = channel.GetChildNodeTextValue("title", "").Sanitize(),
                    Description = channel.GetChildNodeTextValue("description", "").Sanitize(),
                    Link        = channel.GetChildNodeTextValue("link", ""),
                    Image       = channel.GetChildNodeAttribute("itunes:image", "href", ""),
                    FeedUrl     = url,
                    Login       = login,
                    Password    = password
                };

                if (string.IsNullOrEmpty(result.Image))
                {
                    result.LocalImage = "ms-appx:///Assets/IconFull.png";
                }

                if (string.IsNullOrEmpty(result.Description))
                {
                    result.Description = channel.GetChildNodeTextValue("itunes:summary", "").Sanitize();
                }

                await result.ParseAsync(document, false, checkDownloads);

                result.ReOrder();

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        private async void ResultsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var source = e.ClickedItem as SearchResponseEntry;

            if (source == null)
            {
                return;
            }

            WaitRingManager.IsWaitRingVisible = true;

            var podcast = await Podcast.ParseAsync(source.feedUrl, false);

            WaitRingManager.IsWaitRingVisible = false;

            if (podcast != null)
            {
                GlobalStateManager.CurrentShell.Navigate(typeof(PodcastPage), podcast.ToString());
            }
        }
Exemplo n.º 4
0
        private async void BrowseControl_OnUpdate(string url, string login, string password)
        {
            WaitRingManager.IsWaitRingVisible = true;

            try
            {
                if (!url.ContainsIgnoreCase("http"))
                {
                    url = "http://" + url;
                }

                var podcast = await Podcast.ParseAsync(url, false, login, password);

                GlobalStateManager.CurrentShell.Navigate(typeof(PodcastPage), podcast.ToString());
            }
            catch
            {
                await Messenger.ErrorAsync(StringsHelper.Error_UnableToParseRSS);
            }
            WaitRingManager.IsWaitRingVisible = false;
        }
Exemplo n.º 5
0
        public static async Task LoadOPMLFile(StorageFile libraryFile, bool merge)
        {
            var document = new Windows.Data.Xml.Dom.XmlDocument();
            var content  = await FileIO.ReadTextAsync(libraryFile);

            document.LoadXml(content);

            var bodyNode        = document.DocumentElement.GetChildByName("body");
            var categoriesNodes = bodyNode.ChildNodes.Where(n => n is Windows.Data.Xml.Dom.XmlElement).Cast <Windows.Data.Xml.Dom.XmlElement>().ToArray();

            SuccessfullyLoaded = false;
            if (!merge)
            {
                Clear();
            }

            foreach (var categoryNode in categoriesNodes)
            {
                if (categoryNode.HasChildNodes())
                {
                    var category      = categoryNode.GetAttributeValue("text");
                    var podcastsNodes = categoryNode.ChildNodes.Where(n => n is Windows.Data.Xml.Dom.XmlElement).Cast <Windows.Data.Xml.Dom.XmlElement>().ToArray();
                    foreach (var podcastNode in podcastsNodes)
                    {
                        var feedUrl = podcastNode.GetAttributeValue("xmlUrl");

                        if (string.IsNullOrEmpty(feedUrl))
                        {
                            feedUrl = podcastNode.GetAttributeValue("text");
                        }

                        if (GetPodcastByFeedUrl(feedUrl) != null)
                        {
                            continue;
                        }

                        var podcast = await Podcast.ParseAsync(feedUrl, true);

                        if (podcast != null)
                        {
                            podcast.Category = category;
                            Podcasts.Add(podcast);
                            podcast.Clean();
                            podcast.CheckDownloads();
                            podcast.GetLocalImage();
                        }
                    }
                }
                else
                {
                    var feedUrl = categoryNode.GetAttributeValue("xmlUrl");

                    if (string.IsNullOrEmpty(feedUrl))
                    {
                        feedUrl = categoryNode.GetAttributeValue("text");
                    }

                    var podcast = await Podcast.ParseAsync(feedUrl, true);

                    if (podcast != null)
                    {
                        podcast.Category = StringsHelper.NoCategory;
                        Podcasts.Add(podcast);
                        podcast.CheckDownloads();
                        podcast.GetLocalImage();
                    }
                }
            }

            CheckZombieFolders();

            SuccessfullyLoaded = true;
        }