private static void AssertContainsTvStreams(ICollection <AnimeStreamInfo> streams) { // Check first, last, and some in between AnimeStreamInfo firstStream = new AnimeStreamInfo("A Little Snow Fairy Sugar", "https://www.hidive.com/stream/a-little-snow-fairy-sugar/s01e001", StreamingService.Hidive); Assert.Contains(firstStream, streams); AnimeStreamInfo lastStream = new AnimeStreamInfo("Yuyushiki", "https://www.hidive.com/stream/yuyushiki/s01e001", StreamingService.Hidive); Assert.Contains(lastStream, streams); AnimeStreamInfo middleStream1 = new AnimeStreamInfo("Hayate the Combat Butler! Can't Take My Eyes Off You", "https://www.hidive.com/stream/hayate-the-combat-butler-cant-take-my-eyes-off-you/s03e001", StreamingService.Hidive); Assert.Contains(middleStream1, streams); AnimeStreamInfo middleStream2 = new AnimeStreamInfo("The Familiar of Zero: \"Rondo\" of Princesses", "https://www.hidive.com/stream/the-familiar-of-zero-rondo-of-princesses/s03e001", StreamingService.Hidive); Assert.Contains(middleStream2, streams); AnimeStreamInfo middleStream3 = new AnimeStreamInfo("Dog & Scissors", "https://www.hidive.com/stream/dog-scissors/s01e001", StreamingService.Hidive); Assert.Contains(middleStream3, streams); AnimeStreamInfo middleStream4 = new AnimeStreamInfo("Croisée in a Foreign Labyrinth", "https://www.hidive.com/stream/croisee-in-a-foreign-labyrinth/s01e001", StreamingService.Hidive); Assert.Contains(middleStream4, streams); }
private static void AssertContainsMovieStreams(ICollection <AnimeStreamInfo> streams) { // Check first, last, and some in between AnimeStreamInfo firstStream = new AnimeStreamInfo("Amagi Brilliant Park OVA", "https://www.hidive.com/stream/amagi-brilliant-park-ova/2015062614", StreamingService.Hidive); Assert.Contains(firstStream, streams); AnimeStreamInfo lastStream = new AnimeStreamInfo("The World God Only Knows OVA", "https://www.hidive.com/stream/the-world-god-only-knows-ova/2011091601", StreamingService.Hidive); Assert.Contains(lastStream, streams); AnimeStreamInfo middleStream1 = new AnimeStreamInfo("Rozen Maiden: Ouvertüre", "https://www.hidive.com/stream/rozen-maiden-ouverture/2006122201", StreamingService.Hidive); Assert.Contains(middleStream1, streams); AnimeStreamInfo middleStream2 = new AnimeStreamInfo("Love, Chunibyo & Other Delusions! OVA", "https://www.hidive.com/stream/love-chunibyo-other-delusions-ova/2013061913", StreamingService.Hidive); Assert.Contains(middleStream2, streams); }
public ICollection <AnimeStreamInfo> GetAnimeStreamInfo() { HtmlRegexAnimeStreamInfoSource regexSource = new HtmlRegexAnimeStreamInfoSource(AnimeListUrl, AnimeRegex.Value, _html, StreamingService.Crunchyroll, animeNameContext: HtmlRegexContext.Body, urlContext: HtmlRegexContext.Attribute); ICollection <AnimeStreamInfo> streams = regexSource.GetAnimeStreamInfo(); List <AnimeStreamInfo> fixedStreams = new List <AnimeStreamInfo>(streams); for (int i = 0; i < fixedStreams.Count; i++) { // Hack to work around Crunchyroll having this where "IDOLM@STER" would normally be: // <span class=""__cf_email__"" data-cfemail=""8fc6cbc0c3c2cfdcdbcadd"">[email protected]</span><script data-cfhash='f9e31' type=""text/javascript"">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> if (fixedStreams[i].Url == "http://www.crunchyroll.com/the-idolmster-cinderella-girls-theater") { fixedStreams[i] = new AnimeStreamInfo("THE IDOLM@STER CINDERELLA GIRLS Theater", fixedStreams[i].Url, StreamingService.Crunchyroll); } if (fixedStreams[i].Url == "http://www.crunchyroll.com/the-idolmster-side-m") { fixedStreams[i] = new AnimeStreamInfo("THE IDOLM@STER Side M", fixedStreams[i].Url, StreamingService.Crunchyroll); } if (fixedStreams[i].Url == "http://www.crunchyroll.com/the-idolmster-cinderella-girls") { fixedStreams[i] = new AnimeStreamInfo("THE IDOLM@STER CINDERELLA GIRLS", fixedStreams[i].Url, StreamingService.Crunchyroll); } if (fixedStreams[i].Url == "http://www.crunchyroll.com/puchims") { fixedStreams[i] = new AnimeStreamInfo("PUCHIM@S", fixedStreams[i].Url, StreamingService.Crunchyroll); } if (fixedStreams[i].Url == "http://www.crunchyroll.com/the-idolmster-sidem-wakeatte-mini") { fixedStreams[i] = new AnimeStreamInfo("THE IDOLM@STER SideM Wakeatte Mini!", fixedStreams[i].Url, StreamingService.Crunchyroll); } } return(fixedStreams); }
public ICollection<AnimeStreamInfo> GetAnimeStreamInfo() { string responseBody; using (CompressionWebClient client = new CompressionWebClient()) { responseBody = client.DownloadString(Url); } // HTML Agility Pack does not convert "Ä" to an A with an umlaut // but it doesn't really matter as long as it's readable by the human editing the csv and consistent across program runs. HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(responseBody); HtmlNodeCollection matchingNodes = htmlDoc.DocumentNode.SelectNodes(XPath); List<AnimeStreamInfo> streams = new List<AnimeStreamInfo>(); foreach (HtmlNode matchingNode in matchingNodes) { AnimeStreamInfo stream = GetStreamInfoFromMatch(matchingNode); // Convert possibly relative url to an absolute url stream = new AnimeStreamInfo(stream.AnimeName, Utils.PossiblyRelativeUrlToAbsoluteUrl(stream.Url, Url), stream.Service); streams.Add(stream); } return streams; }