当前位置: 首页>>代码示例>>C#>>正文


C# VideoInfo.CleanDescriptionAndTitle方法代码示例

本文整理汇总了C#中System.VideoInfo.CleanDescriptionAndTitle方法的典型用法代码示例。如果您正苦于以下问题:C# VideoInfo.CleanDescriptionAndTitle方法的具体用法?C# VideoInfo.CleanDescriptionAndTitle怎么用?C# VideoInfo.CleanDescriptionAndTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.VideoInfo的用法示例。


在下文中一共展示了VideoInfo.CleanDescriptionAndTitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadVideosFromUrl

        /// <summary>
        /// Load all video summary from the specified url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static List<VideoInfo> LoadVideosFromUrl(this string url, AmazonBrowserSession session)
        {
            var results = new List<VideoInfo>();
            HtmlDocument doc = null;
            var tmpWeb = session;
            HtmlNode detailNode = null;

            // Attempt the URL up to 15 times as amazon wants us to use the api!
            for (int i = 0; i <= 15; i++)
            {
                doc = tmpWeb.Load(url);
                detailNode = doc.GetElementbyId("aiv-main-content");

                if (detailNode == null)
                    Thread.Sleep(400);
                else
                    break;
            }

            if (detailNode != null)
            {
                var episodeContainer = doc.GetElementbyId("dv-episode-list");
                if (episodeContainer == null || (episodeContainer != null &&  episodeContainer.FindFirstChildElement() == null))
                { 
                    // Movie, load this video
                    var video = new VideoInfo();

                    video.Title = detailNode.SelectSingleNode(".//h1[@id = 'aiv-content-title']").FirstChild.GetInnerText().Replace("\n", string.Empty).Trim();
                    //doc.DocumentNode.GetNodeByClass("product_image").Attributes["alt"].Value;
                    var infoNode = detailNode.GetNodeByClass("dv-info");

                    video.Description = video.Title + " (" + detailNode.NavigatePath(new[] { 0, 0 }).FirstChild.GetInnerText().Replace("\n", string.Empty).Trim() + ", amazon " + (doc.GetElementbyId("summaryStars").FindFirstChildElement() == null ? string.Empty : doc.GetElementbyId("summaryStars").FindFirstChildElement().Attributes["title"].Value) + ")\r\n" +
                                                            infoNode.GetNodeByClass("synopsis").GetInnerText().Replace("\n", string.Empty).Trim() + "\r\n" +
                                                            infoNode.GetNodeByClass("dv-meta-info").NavigatePath(new[] { 0 }).GetInnerText().Replace("\n", string.Empty).Trim() + " " +
                                                            infoNode.GetNodeByClass("dv-meta-info").NavigatePath(new[] { 1 }).GetInnerText().Replace("\n", string.Empty).Trim();

                    var imageUrlNode = doc.GetElementbyId("dv-dp-left-content").GetNodeByClass("dp-meta-icon-container");
                    video.Thumb = imageUrlNode == null ? string.Empty : imageUrlNode.SelectSingleNode(".//img").Attributes["src"].Value;
                    video.Length = infoNode.NavigatePath(new[] { 2, 3 }).GetInnerText().Replace("\n", string.Empty).Trim();
                    video.Other = doc.GetElementbyId("ASIN").Attributes["value"].Value;
                    results.Add(video);
                }
                else
                {
                    // TV Series, load all videos
                    var episodeList = episodeContainer.GetNodesByClass("episode-list-link");
                    var usesAltLayout = false;

                    if (episodeList == null) 
                    {
                        usesAltLayout = true;
                        episodeList = episodeContainer.GetNodesByClass("episode-list-item-inner");
                    }
                    
                    foreach (var item in episodeList)
                    {
                        var video = new VideoInfo();
                        var titleNode = usesAltLayout ? item.GetNodeByClass("dv-extender").NavigatePath(new[]{0,0}) : item.GetNodeByClass("episode-title");
                         
                        var seen = "";
                        /*if (item.GetNodeByClass("progress-bar") == null)
                        {
                            seen = " (new)";
                        }*/
                        video.Title = Regex.Replace(titleNode.GetInnerText().Replace("\n", String.Empty).Trim(), @"^\d+", m => m.Value.PadLeft(2, '0')) + seen;

                        video.Description = titleNode.NextSibling.GetInnerText().Replace("\n", string.Empty).Trim() + "\r\n" +
                                             "Released: " + item.GetNodeByClass("release-date").GetInnerText().Replace("\n", string.Empty).Trim();

                        var imageUrlNode = item.GetNodeByClass("episode-list-image");
                        if (imageUrlNode != null)
                        {
                            video.Thumb = imageUrlNode.Attributes["src"].Value;
                        }
                        else
                        {
                            imageUrlNode = doc.GetElementbyId("dv-dp-left-content").GetNodeByClass("dp-meta-icon-container");
                            video.Thumb = imageUrlNode == null ? string.Empty : imageUrlNode.SelectSingleNode(".//img").Attributes["src"].Value;
                        }
                        video.Length = item.GetNodeByClass("runtime").GetInnerText().Replace("\n", string.Empty).Trim();
                        var videoUrl = usesAltLayout ? titleNode.GetAttribute("href") : item.GetAttribute("href");
                        videoUrl = videoUrl.Substring(videoUrl.IndexOf("/product/") + 9);
                        videoUrl = videoUrl.Substring(0, videoUrl.IndexOf("/"));
                        video.Other = videoUrl;
                        video.CleanDescriptionAndTitle();
                        results.Add(video);
                    }
                }
            }
            
            
            return results;
        }
开发者ID:JSurf,项目名称:mp-onlinevideos2,代码行数:98,代码来源:AmazonPrimeVideoParser.cs


注:本文中的System.VideoInfo.CleanDescriptionAndTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。