private async Task <List <ChannelItemInfo> > GetMenu(string url) { var doc = new HtmlDocument(); using (var stream = await _httpClient.Get(new HttpRequestOptions() { Url = BASE_URL + url, CancellationToken = CancellationToken.None }).ConfigureAwait(false)) { _logger.Warn("Stream lenght: {0}", stream.Length); doc.Load(stream, Encoding.UTF8); } var abroadOnly = SvtPlay.Plugin.Instance.Configuration.AvailableAbroadOnly.GetValueOrDefault(); var recommended = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//section[contains(@id, 'recommended-videos')]"), abroadOnly); var popular = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'popular-videos')]"), abroadOnly); var latest = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'latest-videos')]"), abroadOnly); var lastChance = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'last-chance-videos')]"), abroadOnly); var live = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'live-channels')]"), abroadOnly); var catgories = SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'categories')]"), abroadOnly); var items = new List <ChannelItemInfo>(); if (recommended.Any()) { items.Add(SvtPlaySiteParser.CreateFolderItem("Recommended", "recommended", url, recommended.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); } if (popular.Any()) { items.Add(SvtPlaySiteParser.CreateFolderItem("Popular", "popular", url, popular.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); } if (latest.Any()) { items.Add(SvtPlaySiteParser.CreateFolderItem("Latest", "latest", url, latest.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); } if (lastChance.Any()) { items.Add(SvtPlaySiteParser.CreateFolderItem("Last Chance", "lastChance", url, lastChance.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); } //if (live.Any()) // items.Add(CreateBaseFolder("live", url, live.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); if (catgories.Any()) { items.Add(SvtPlaySiteParser.CreateFolderItem("Categories", "categories", url, catgories.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.ImageUrl)))); } return(items); }
private async Task <List <ChannelItemInfo> > GetChildren(string query, string url, CancellationToken token) { var doc = new HtmlDocument(); using (var stream = await _httpClient.Get(new HttpRequestOptions() { Url = BASE_URL + url, CancellationToken = CancellationToken.None }).ConfigureAwait(false)) { doc.Load(stream, Encoding.UTF8); _logger.Info("Parsing Query: {0}", query); var abroadOnly = SvtPlay.Plugin.Instance.Configuration.AvailableAbroadOnly.GetValueOrDefault(); switch (query) { case "recommended": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//section[contains(@id, 'recommended-videos')]"), abroadOnly)); case "popular": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'popular-videos')]"), abroadOnly)); case "latest": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'latest-videos')]"), abroadOnly)); case "lastChance": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'last-chance-videos')]"), abroadOnly)); case "live": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'live-channels')]"), abroadOnly)); case "categories": return(SvtPlaySiteParser.ParseNode(doc.DocumentNode.SelectSingleNode("//div[contains(@id, 'categories')]"), abroadOnly)); default: return(SvtPlaySiteParser.ParseNode(null, abroadOnly)); } } }