public void GetEpisodesThrowsExpectedException()
        {
            string feedUrl = null;

            Assert.ThrowsAsync <ArgumentNullException>(() => finder.GetPodcastEpisodesAsync(feedUrl));

            feedUrl = "invalidURLteste";
            Assert.ThrowsAsync <UriFormatException>(() => finder.GetPodcastEpisodesAsync(feedUrl));

            feedUrl = "https://www.invalidURL.com/asdalsdkd";
            Assert.ThrowsAsync <HttpRequestException>(() => finder.GetPodcastEpisodesAsync(feedUrl));
        }
Beispiel #2
0
        public async Task <Podcast> GetPodcastAsync(Uri podcastUrl)
        {
            var podcastFinder = new PodcastFinder();

            PodcastFinder.HttpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0");
            var getPodcastWithEpisodesResult = await podcastFinder.GetPodcastEpisodesAsync(podcastUrl.AbsoluteUri);

            var podcast = PodcastConversion(getPodcastWithEpisodesResult.Podcast, getPodcastWithEpisodesResult.Episodes);

            return(podcast);

            /*
             * string podcastTitle = podcast.Name;
             *
             * string podcastTitleCard = (podcast.Image.Split('/').Last());
             *
             * Uri podcastTitleCardUri = new Uri(podcast.Image);
             *
             * var localPodcastPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), "EscapePod", podcastTitle);
             *
             * var pod = new Podcast()
             * {
             *  Url = new Uri(podcast.FeedUrl),
             *  Name = podcast.Name,
             *  TitleCard = new Uri(podcastTitleCard),
             *  LocalTitleCardFileFullName = GetFileFullName(localPodcastPath, podcastTitle, podcastTitleCard.Split('.').Last()),
             *  LocalPodcastPath = localPodcastPath
             * };
             *
             *
             * List<Episode> epilist = new List<Episode>();
             * foreach (var item in podcast.Episodes)
             * {
             *  string episodeTitle = item.Title;
             *
             *  StringWriter episodeTitleWriter = new StringWriter();
             *  StringWriter episodeDescriptionWriter = new StringWriter();
             *
             *  Regex reg = new Regex(@"\d+");
             *  Match match = reg.Match(item.Title);
             *  if (!match.Success)
             *  {
             *      continue;
             *  }
             *
             *  int episodeNumber = int.Parse(match.Value);
             *  string episodeDescription = item.Summary;
             *  var episodeUrl = item.Link;
             *
             *  DateTime? pubDateParam = null;
             *  DateTime pubDate = item.PubDate;
             *
             *  System.Web.HttpUtility.HtmlDecode(episodeDescription,episodeDescriptionWriter);
             *  episodeDescription = episodeDescriptionWriter.ToString();
             *  System.Web.HttpUtility.HtmlDecode(episodeTitle,episodeTitleWriter);
             *  episodeTitle = episodeTitleWriter.ToString();
             *  episodeDescription = EpisodeDescriptionParser(episodeDescription);
             *  double episodeTimestamp = 0.0;
             *  Episode episode = new Episode(pod, episodeTitle, episodeNumber, new Uri(episodeUrl), episodeDescription, episodeTimestamp, pubDateParam);
             *
             *  episode.LocalPath = GetFileFullName(episode.Podcast.LocalPodcastPath, episode.EpisodeName, episode.EpisodeUri.AbsoluteUri.Split('.').Last());
             *
             *  epilist.Add(episode);
             * }
             *
             * pod.EpisodeList = epilist;
             */
        }