Esempio n. 1
0
        List<VideoInfo> getVideos(string url, bool findOuterOL, bool fromSearch = false)
        {
            HasNextPage = false;

            var result = new List<VideoInfo>();
            var html = GetWebData<HtmlDocument>(url);

            var ol = findOuterOL ? html.DocumentNode.Descendants("ol").First() : html.DocumentNode;
            foreach (var li in ol.Elements("li"))
            {
                if (fromSearch)
                {
                    var video = new RbbVideoInfo() { Title = li.Descendants("h3").First().InnerText.Trim(), HasDetails = false };
                    FillVideoInfoFromLI(li, video, true);
                    if (!string.IsNullOrEmpty(video.VideoUrl))
                        result.Add(video);
                }
                else
                {
                    var sub_ol = li.Elements("ol").FirstOrDefault();
                    if (sub_ol != null)
                    {
                        var video = new RbbVideoInfo() { Title = li.Descendants("h3").First().InnerText.Trim() };

                        var sub_lis = sub_ol.Elements("li");

                        if (sub_lis.Count() == 1) // Sendung hat nur einen Beitrag
                        {
                            video.HasDetails = false;

                            FillVideoInfoFromLI(li, video, true);

                            if (!string.IsNullOrEmpty(video.VideoUrl))
                                result.Add(video);
                        }
                        else // Sendung hat einzelne Beiträge
                        {
                            //video.ImageUrl = category.Thumb;
                            foreach (var sub_li in sub_lis)
                            {
                                var subVideo = new DetailVideoInfo() { Title = video.Title };
                                FillVideoInfoFromLI(sub_li, subVideo, false);
                                subVideo.Length = subVideo.Length.Replace("min", "").Trim();
                                if (!string.IsNullOrEmpty(subVideo.VideoUrl))
                                    video.Children.Add(subVideo);
                            }
                            if (video.Children.Count > 0)
                                result.Add(video);
                        }
                    }
                }
            }

            var nextPageLink = html.DocumentNode.Descendants("a").Where(a => a.InnerText == "Weiter").FirstOrDefault();
            if (nextPageLink != null)
            {
                HasNextPage = true;
                nextPageUrl = "http://mediathek.rbb-online.de" + nextPageLink.GetAttributeValue("href", "");
            }

            return result;
        }
Esempio n. 2
0
        List <VideoInfo> getVideos(string url, bool findOuterOL, bool fromSearch = false)
        {
            HasNextPage = false;

            var result = new List <VideoInfo>();
            var html   = GetWebData <HtmlDocument>(url);

            var ol = findOuterOL ? html.DocumentNode.Descendants("ol").First() : html.DocumentNode;

            foreach (var li in ol.Elements("li"))
            {
                if (fromSearch)
                {
                    var video = new RbbVideoInfo()
                    {
                        Title = li.Descendants("h3").First().InnerText.Trim(), HasDetails = false
                    };
                    FillVideoInfoFromLI(li, video, true);
                    if (!string.IsNullOrEmpty(video.VideoUrl))
                    {
                        result.Add(video);
                    }
                }
                else
                {
                    var sub_ol = li.Elements("ol").FirstOrDefault();
                    if (sub_ol != null)
                    {
                        var video = new RbbVideoInfo()
                        {
                            Title = li.Descendants("h3").First().InnerText.Trim()
                        };

                        var sub_lis = sub_ol.Elements("li");

                        if (sub_lis.Count() == 1)                         // Sendung hat nur einen Beitrag
                        {
                            video.HasDetails = false;

                            FillVideoInfoFromLI(li, video, true);

                            if (!string.IsNullOrEmpty(video.VideoUrl))
                            {
                                result.Add(video);
                            }
                        }
                        else                         // Sendung hat einzelne Beiträge
                        {
                            //video.ImageUrl = category.Thumb;
                            foreach (var sub_li in sub_lis)
                            {
                                var subVideo = new DetailVideoInfo()
                                {
                                    Title = video.Title
                                };
                                FillVideoInfoFromLI(sub_li, subVideo, false);
                                subVideo.Length = subVideo.Length.Replace("min", "").Trim();
                                if (!string.IsNullOrEmpty(subVideo.VideoUrl))
                                {
                                    video.Children.Add(subVideo);
                                }
                            }
                            if (video.Children.Count > 0)
                            {
                                result.Add(video);
                            }
                        }
                    }
                }
            }

            var nextPageLink = html.DocumentNode.Descendants("a").Where(a => a.InnerText == "Weiter").FirstOrDefault();

            if (nextPageLink != null)
            {
                HasNextPage = true;
                nextPageUrl = "http://mediathek.rbb-online.de" + nextPageLink.GetAttributeValue("href", "");
            }

            return(result);
        }