Exemplo n.º 1
0
 private void btn_sel_no_Click(object sender, EventArgs e)
 {
     foreach (TSkin.TBut file in panel_videos.Controls)
     {
         VideoUrl videoUrl = file.Tag as VideoUrl;
         if (!File.Exists(Program.DownLoadPath + video.videoName + "\\" + videoUrl.playName + Path.GetExtension(videoUrl.playURL)))
         {
             if (file.BorderWidth == 1)
             {
                 file.BorderWidth = 0;
             }
             else
             {
                 file.BorderWidth = 1;
             }
         }
     }
 }
Exemplo n.º 2
0
        private void btn_down_Click(object sender, EventArgs e)
        {
            if (playAddress != null)
            {
                if (!isdownModel)
                {
                    panel7.Visible = true;
                    isdownModel    = true;
                    btn_down.Text  = "下载选中";
                    foreach (TSkin.TBut file in panel_videos.Controls)
                    {
                        VideoUrl videoUrl = file.Tag as VideoUrl;
                        if (!File.Exists(Program.DownLoadPath + video.videoName + "\\" + videoUrl.playName + Path.GetExtension(videoUrl.playURL)))
                        {
                            file.BorderWidth = 1;
                        }
                    }
                }
                else
                {
                    //bool isDownok = true;
                    //if (SystemSettings.AduDownload)
                    //{
                    //    TPlayerDownLib.VideoTask videoTask = new TPlayerDownLib.VideoTask
                    //    {
                    //        name = video.videoName,
                    //        cover = video.videoImgUrl,
                    //        intro = video.videoSynopsis,
                    //        list = new List<TPlayerDownLib.VideoTaskList>()
                    //    };

                    //    foreach (TSkin.TBut file in panel3.Controls)
                    //    {
                    //        if (file.BorderWidth == 1)
                    //        {

                    //            VideoUrl videoUrl = file.Tag as VideoUrl;

                    //            TPlayerDownLib.VideoTaskList videoTaskList = new TPlayerDownLib.VideoTaskList
                    //            {
                    //                name = videoUrl.playName,
                    //                url = videoUrl.playURL,
                    //                fileName = videoUrl.playName + Path.GetExtension(videoUrl.playURL),
                    //                tempPath = Program.DownLoadPath + video.videoName + "\\" + videoUrl.playName + "\\"
                    //            };
                    //            videoTaskList.savePath = Program.DownLoadPath + video.videoName + "\\" + videoTaskList.fileName;

                    //            videoTask.list.Add(videoTaskList);
                    //        }
                    //    }
                    //    Action _action = () =>
                    //    {
                    //        if (!TPlayerDownLib.DownLib.RunDownLoad)
                    //        {
                    //            bool isRun = false;
                    //            LL2:
                    //            if (string.IsNullOrEmpty(SystemSettings.AduDownloadPath))
                    //            {
                    //                if (File.Exists("AduDownload.exe"))
                    //                {
                    //                    Api.OpenMessage(this, MessageType.Info, "正在启动 AduDownload");
                    //                    System.Diagnostics.Process.Start("AduDownload.exe");
                    //                    isRun = true;
                    //                }
                    //                else
                    //                {
                    //                    using (HasDownLoad noAduDownLoad = new HasDownLoad("AduDownLoad 下载器未找到"))
                    //                    {
                    //                        DialogResult dialogResult = DialogResult.No;
                    //                        this.Invoke(new Action(() =>
                    //                        {
                    //                            dialogResult = noAduDownLoad.ShowDialog();
                    //                        }));
                    //                        switch (dialogResult)
                    //                        {
                    //                            case DialogResult.OK:
                    //                                goto LL2;
                    //                                break;
                    //                            case DialogResult.Retry:
                    //                                SystemSettings.AduDownload = false;
                    //                                isDownok = false;
                    //                                break;
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //            else
                    //            {
                    //                Api.OpenMessage(this, MessageType.Info, "正在启动 AduDownload");
                    //                System.Diagnostics.Process.Start(SystemSettings.AduDownloadPath);
                    //                isRun = true;
                    //            }
                    //            int ErrCount = 0;
                    //            while (isRun)
                    //            {
                    //                System.Threading.Thread.Sleep(500);
                    //                if (!TPlayerDownLib.DownLib.RunDownLoad)
                    //                {
                    //                    ErrCount++;
                    //                    if (ErrCount > 10)
                    //                    {
                    //                        isRun = false; break;
                    //                    }
                    //                }
                    //                else
                    //                {
                    //                    isRun = false;
                    //                }
                    //            }
                    //        }
                    //        if (TPlayerDownLib.DownLib.SendDownLoad(videoTask))
                    //        {
                    //            Api.OpenMessage(webVideo, MessageType.Success, "下载任务已发送成功");
                    //        }
                    //        else
                    //        {
                    //            using (HasDownLoad noAduDownLoad = new HasDownLoad("AduDownLoad 下载器无法使用"))
                    //            {
                    //                DialogResult dialogResult = DialogResult.No;
                    //                this.Invoke(new Action(() =>
                    //                {
                    //                    dialogResult = noAduDownLoad.ShowDialog();
                    //                }));
                    //                switch (dialogResult)
                    //                {
                    //                    case DialogResult.OK:
                    //                        isDownok = false;
                    //                        break;
                    //                    case DialogResult.Retry:
                    //                        SystemSettings.AduDownload = false;
                    //                        isDownok = false;
                    //                        break;
                    //                }
                    //            }

                    //        }

                    //    };
                    //    _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action =>
                    //    {
                    //    }));
                    //}
                    //else
                    //{
                    List <DownItem> downItems = new List <DownItem>();
                    foreach (TBut file in panel_videos.Controls)
                    {
                        if (file.BorderWidth == 1)
                        {
                            VideoUrl videoUrl = file.Tag as VideoUrl;

                            DownItem downItem = new DownItem
                            {
                                url      = videoUrl.playURL,
                                imgUrl   = video.videoImgUrl,
                                img      = video.videoImg,
                                ID       = video.id + "_" + menuXList1.SelectItemIndex + videoUrl.playName,
                                basepath = Program.DownLoadPath + video.videoName + "\\" + videoUrl.playName + "\\",
                                name     = video.videoName + " - " + videoUrl.playName,
                                fileName = videoUrl.playName + Path.GetExtension(videoUrl.playURL),
                            };
                            downItem.savepath = Program.DownLoadPath + video.videoName + "\\" + downItem.fileName;
                            downItems.Add(downItem);
                        }
                    }

                    if (downItems.Count > 0)
                    {
                        bool   isok    = false;
                        Action _action = () =>
                        {
                            isok = webVideo.player.AddDownList(downItems);
                        };
                        webVideo.player._task.ContinueWhenAll(new Task[] { webVideo.player._task.StartNew(_action) }, (action =>
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                panel7.Visible = isdownModel = false;
                                btn_down.Text = "下载";
                            }));
                        }));
                    }
                    else
                    {
                        foreach (TSkin.TBut file in panel_videos.Controls)
                        {
                            if (file.BorderWidth == 1)
                            {
                                file.BorderWidth = 0;
                            }
                        }
                        panel7.Visible = isdownModel = false;
                        btn_down.Text  = "下载";
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <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("&nbsp;", " ").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); }
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        /// <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);
        }