/// <summary> /// 影片信息获取 /// </summary> /// <param name="childPageId"></param> public Video GetVideoInfo(int videoId) { try { string videoUrl = baseStr + "?m=vod-detail-id-" + videoId + ".html"; Video videoInfo = new Video(); HtmlNode rootnode1 = GetHtmlDoc(videoUrl); // HtmlNode vodImg = rootnode1.SelectSingleNode("//div[@class='vodImg']"); HtmlNode vodInfo = rootnode1.SelectSingleNode("//div[@class='vodInfo']"); HtmlNode vodImgSrc = vodImg.SelectSingleNode("//img[@class='lazy']/@src"); videoInfo.videoImgUrl = vodImgSrc.Attributes["src"].Value; //影片图片地址 videoInfo.videoName = vodImgSrc.Attributes["alt"].Value; //影片名 HtmlNode vodInfoVodh = vodInfo.SelectSingleNode("//div[@class='vodh']"); videoInfo.videoType = vodInfoVodh.SelectSingleNode("span").InnerText; videoInfo.videoQuality = vodInfoVodh.SelectSingleNode("label").InnerText; //影片详情 try { var htmlVodinfobox = vodInfo.SelectNodes("//div[@class='vodinfobox']/ul/li").Where(FuncVodinfobox); List <string> tset = (from a in htmlVodinfobox select a.InnerHtml).ToList(); List <VideoInfo> strResult = new List <VideoInfo>(); foreach (string item in tset) { if (!string.IsNullOrEmpty(item) && item.Contains(":")) { //别名:<span></span> string[] items = item.Split(':'); string _value = items[1].Trim(); HtmlDocument docs = new HtmlDocument(); docs.LoadHtml(_value); strResult.Add(new VideoInfo { key = items[0].Trim(), value = docs.DocumentNode.InnerText.Replace(" ", " ").Trim() }); } else { } } videoInfo.videoTotalInfo = strResult; } catch { } //string vodin = "//div[@class='vodinfobox']/ul/li"; //var htmle = rootnode1.SelectNodes(vodin); //剧情介绍 videoInfo.videoSynopsis = Compress(rootnode1.SelectSingleNode("//div[@class='vodplayinfo']").InnerText); //地址 videoInfo.playInformation = new List <PlayAddress>(); HtmlNodeCollection playType_ = rootnode1.SelectNodes("//div[@class='vodplayinfo']/div"); if (playType_ != null) { foreach (HtmlNode playTypeOne in playType_) { var playType = playTypeOne.SelectNodes("//span[@class='suf']"); if (playType != null) { foreach (HtmlNode item in playType) { PlayAddress routing = new PlayAddress(); routing.playType = item.InnerText; routing.videoUrl = new List <VideoUrl>(); var Urls = item.SelectNodes("../../ul/li"); foreach (var item1 in Urls) { VideoUrl videourl = new VideoUrl(); string[] ars = item1.InnerText.Split('$'); videourl.playName = ars[0] != null ? ars[0] : " "; videourl.playURL = ars[1] != null ? ars[1] : " "; routing.videoUrl.Add(videourl); } videoInfo.playInformation.Add(routing); } if (videoInfo.playInformation.Count > 0) { return(videoInfo); } } else { var playTypes = playTypeOne.SelectNodes("h3"); if (playTypes != null) { foreach (var item in playTypes) { //播放类型: PlayAddress routing = new PlayAddress(); routing.playType = item.InnerText; if (routing.playType.Contains(":")) { routing.playType = routing.playType.Split(':')[1].Trim(); } routing.videoUrl = new List <VideoUrl>(); var Urls = item.SelectNodes("../ul/li"); if (Urls != null) { foreach (var item1 in Urls) { VideoUrl videourl = new VideoUrl(); string[] ars = item1.InnerText.Split('$'); videourl.playName = ars[0] != null ? ars[0] : " "; videourl.playURL = ars[1] != null ? ars[1] : " "; routing.videoUrl.Add(videourl); } videoInfo.playInformation.Add(routing); } } } } } } return(videoInfo); } catch { return(null); } }
private void menuXList1_DownClick(TPlayerList.TopItem Item) { panel7.Visible = isdownModel = false; btn_play.Text = "播放全部"; btn_down.Text = "下载"; playIndex = Item.Index; menuXList1.SelectItemIndex = Item.Index; menuXList1.Tom(Item); panel_videos.Visible = false; panel_videos.Controls.Clear(); playAddress = video.playInformation.Find(ab => ab.playType == Item.Name); List <string> _WebVideoPlayType = SystemSettings.WebVideoPlayType; if (_WebVideoPlayType.Contains(Item.Name)) { _WebVideoPlayType.Remove(Item.Name); } _WebVideoPlayType.Insert(0, Item.Name); SystemSettings.SetWebVideoPlayType = string.Join(";", _WebVideoPlayType); string _colltag = "webvideo[" + this.videotype + "]_" + playIndex + "_" + video.id; int coll = 0; if (SystemSettings.RememberLocation && File.Exists(Program.CachePath + "coll\\" + _colltag)) { int.TryParse(File.ReadAllText(Program.CachePath + "coll\\" + _colltag), out coll); } if (coll > 0) { if (playAddress.videoUrl.Count - 1 < coll) { coll = 0; try { File.Delete(Program.CachePath + "coll\\" + _colltag); } catch { } } btn_play.Text = "继续 " + playAddress.videoUrl[coll].playName; } TSkin.TBut slabel = null; for (int i = 0; i < playAddress.videoUrl.Count; i++) { int _index = i; VideoUrl item = playAddress.videoUrl[i]; TSkin.TBut but = new TSkin.TBut { TabIndex = _index, Name = video.id + "_" + menuXList1.SelectItemIndex + item.playName, ASize = true, Radius = 6, Text = item.playName, ImageSize = new Size(20, 20), ImageMargin = new Padding(6, 0, 0, 0), TextAlign = ContentAlignment.MiddleRight, TextMargin = new Padding(6, 4, 6, 4), ValueColor = Color.FromArgb(140, Color.OrangeRed), BorderColorActive = Color.OrangeRed, BorderColor = Color.OrangeRed, BackColor = Color.FromArgb(20, 0, 0, 0), BackColor2 = Color.FromArgb(20, 0, 0, 0), BackColorActive = Color.DodgerBlue, BackColorActive2 = Color.DodgerBlue, ForeColorActive = Color.White, Tag = item }; if (coll > 0 && _index == coll) { slabel = but; but.IsActive = true; //file.Icon = Properties.Resources.icon_success; } if (File.Exists(Program.DownLoadPath + video.videoName + "\\" + item.playName + Path.GetExtension(item.playURL))) { but.Image = Properties.Resources.icon_success; } panel_videos.Controls.Add(but); but.Click += (a, b) => { if (isdownModel) { if (!File.Exists(Program.DownLoadPath + video.videoName + "\\" + item.playName + Path.GetExtension(item.playURL))) { if (but.BorderWidth == 0) { but.BorderWidth = 1; } else { but.BorderWidth = 0; } } } else { string pathcoll = Program.CachePath + "coll\\" + _colltag; (Program.CachePath + "coll\\").CreateDirectory(true); File.WriteAllText(pathcoll, _index.ToString()); _play(_index, _colltag); } }; } panel_videos.Visible = true; if (slabel != null) { slabel.Focus(); } }
/// <summary> /// 影片列表获取 /// </summary> /// <param name="dataApi"></param> /// <returns></returns> public static TitleName GetVideoList(Ok_API dataApi) { TitleName titleName = new TitleName(); List <Video> videos = new List <Video>(); foreach (var item in dataApi.list) { //if (GreenMode) //{ // if (item.vod_class.Contains("伦理片") || item.vod_class.Contains("福利片")) // { // continue; // } //} Video video = new Video(); video.id = item.vod_id; video.videoName = item.vod_name; video.videoImgUrl = item.vod_pic; video.videoType = item.vod_class; video.videoTotalInfoTxt = item.vod_content; video.videoSynopsis = item.vod_content; List <PlayAddress> playAddresses = new List <PlayAddress>(); //播放地址 string[] type = item.vod_play_from.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries); string[] typeURL = item.vod_play_url.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < type.Length; i++) { if (type[i].Contains("m3u8")) { continue; } PlayAddress playAddress = new PlayAddress(); playAddress.playType = type[i]; if (type[i].Contains("kuyun")) { playAddress.playType = "播放"; } List <VideoUrl> videoUrls = new List <VideoUrl>(); string[] urls = typeURL[i].Split('#'); foreach (var item2 in urls) { VideoUrl videoUrl = new VideoUrl(); string[] ars = item2.Split('$'); if (ars.Count() == 2) { videoUrl.playName = ars[0] != null ? ars[0] : " "; videoUrl.playURL = ars[1] != null ? ars[1] : " "; } else { videoUrl.playName = item2; videoUrl.playURL = item2; } videoUrls.Add(videoUrl); } playAddress.videoUrl = videoUrls; playAddresses.Add(playAddress); } //下载地址 PlayAddress playDown = new PlayAddress(); if (!string.IsNullOrWhiteSpace(item.vod_down_from)) { playDown.playType = item.vod_down_from; if (item.vod_down_from.Contains("xunlei")) { playDown.playType = "下载"; } List <VideoUrl> xunurls = new List <VideoUrl>(); string[] url = item.vod_down_url.Split('#'); foreach (var item2 in url) { VideoUrl videoUrl = new VideoUrl(); string[] ars = item2.Split('$'); if (ars.Count() == 2) { videoUrl.playName = ars[0] != null ? ars[0] : " "; videoUrl.playURL = ars[1] != null ? ars[1] : " "; } else { videoUrl.playName = item2; videoUrl.playURL = item2; } xunurls.Add(videoUrl); } playDown.videoUrl = xunurls; playAddresses.Add(playDown); } video.playInformation = playAddresses; video.videoUpdateTime = item.vod_time; videos.Add(video); } titleName.titleVideos = videos; titleName.pageCount = dataApi.pagecount; return(titleName); }