public void ParsesCorrectly(string href, string expected) { var basePage = new Uri("https://example.com/episodes/1.html"); var file = PossibleEpisodeFile.Create(basePage, href); Check.That(file.Url).IsEqualTo(expected); }
public void ExtractsFilename() { var basePage = new Uri("https://example.com/episodes/1.html"); var file = PossibleEpisodeFile.Create(basePage, "/a/folder/something.mp3?foo=bar"); Check.That(file.Filename).IsEqualTo("something.mp3"); }
private static IReadOnlyList <PossibleEpisodeFile> ExtractDownloadLinks(HtmlDocument doc, string url) { var page = new Uri(url); return(doc.QuerySelectorAll("a") .Select(a => a.GetAttributeValue("href", "")) .Where(href => href.Contains(".mp3")) .Distinct() .Select(href => PossibleEpisodeFile.Create(page, href)) .ToList()); }