Exemplo n.º 1
0
        //向下移动
        private void btnDown_Click(object sender, EventArgs e)
        {
            int selected = lsv.SelectedIndices[0];

            if (selected == lsv.Items.Count - 1)
            {
                return;
            }
            AutoAnswer temp = aa[selected];

            aa[selected]     = aa[selected + 1];
            aa[selected + 1] = temp;
            refresh.Invoke();
            lsv.Items[selected + 1].Selected = true;
            lsv.Select();
        }
Exemplo n.º 2
0
        public static void SaveSettings(string Path)
        {
            XmlDocument Xml = new XmlDocument();

            Xml.AppendChild(Xml.CreateNode(XmlNodeType.Element, "settings", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "UserName", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Password", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Domain", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Host", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Port", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "AutoRegister", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "AutoAnswer", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "DoNotDisturb", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Prefix0", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "CallForm", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "PlaySound", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Ringtone", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "PipeName", ""));

            Xml.SelectSingleNode("settings/UserName").InnerText     = UserName;
            Xml.SelectSingleNode("settings/Password").InnerText     = Password;
            Xml.SelectSingleNode("settings/Domain").InnerText       = Domain;
            Xml.SelectSingleNode("settings/Host").InnerText         = Host;
            Xml.SelectSingleNode("settings/Port").InnerText         = Port.ToString();
            Xml.SelectSingleNode("settings/AutoRegister").InnerText = AutoRegister.ToString();
            Xml.SelectSingleNode("settings/AutoAnswer").InnerText   = AutoAnswer.ToString();
            Xml.SelectSingleNode("settings/DoNotDisturb").InnerText = DoNotDisturb.ToString();
            Xml.SelectSingleNode("settings/Prefix0").InnerText      = Prefix0.ToString();
            Xml.SelectSingleNode("settings/CallForm").InnerText     = CallForm.ToString();
            Xml.SelectSingleNode("settings/PlaySound").InnerText    = PlaySound.ToString();
            Xml.SelectSingleNode("settings/Ringtone").InnerText     = Ringtone;
            Xml.SelectSingleNode("settings/PipeName").InnerText     = PipeName;

            if (Path == "")
            {
                Xml.Save(Globals.PathSettings);
            }
            else
            {
                Xml.Save(Path);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 下载视频
        /// </summary>
        /// <returns></returns>
        public override bool Download()
        {
            //开始下载
            delegates.TipText(new ParaTipText(this.Info, "正在分析视频地址"));

            //修正井号
            Info.Url = Info.Url.TrimEnd('#');

            //修正简写URL
            if (Regex.Match(Info.Url, @"^ac\d+$").Success)
            {
                Info.Url = "http://www.acfun.tv/v/" + Info.Url;
            }
            else if (!Info.Url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase))
            {
                Info.Url = "http://" + Info.Url;
            }

            //修正URL为 http://www.acfun.tv/v/ac12345_67 形式
            Info.Url = Info.Url.Replace(".html", "").Replace("/index", "");
            if (!Info.Url.Contains("_"))
            {
                Info.Url += "_1";
            }

            //取得AC号和子编号
            Match mAcNumber = Regex.Match(Info.Url, @"(?<ac>ac\d+)_(?<sub>\d+)");

            m_acNumber    = mAcNumber.Groups["ac"].Value;
            m_acSubNumber = mAcNumber.Groups["sub"].Value;
            //设置自定义文件名
            m_customFileName = AcFunPlugin.DefaultFileNameFormat;
            if (Info.BasePlugin.Configuration.ContainsKey("CustomFileName"))
            {
                m_customFileName = Info.BasePlugin.Configuration["CustomFileName"];
            }

            //是否通过【自动应答】禁用对话框
            bool disableDialog = false;

            disableDialog = AutoAnswer.IsInAutoAnswers(Info.AutoAnswer, "acfun", "auto");

            //当前播放器地址
            Settings["PlayerUrl"] = @"http://static.acfun.tv/player/ssl/ACFlashPlayerN0102.swf";

            //取得网页源文件
            string src = Network.GetHtmlSource(Info.Url, Encoding.UTF8, Info.Proxy);

            var relatedVideoList = new Dictionary <string, string>();


            TipText("正在获取视频详细信息");
            var videoIdCollection = Regex.Matches(src,
                                                  @"<a data-vid=""(?<vid>\d+)"" data-from=""(?<from>\w+)""(?: data-did=""(?<did>\w*?)"")? data-sid=""(?<sid>\w+)"" href=""(?<href>.+?)"" title=""(?<title>.+?)"".+?>(?<content>.+?)</a>",
                                                  RegexOptions.IgnoreCase);

            foreach (Match mVideoId in videoIdCollection)
            {
                //所有子标题
                if (mVideoId.Groups["content"].Value.Contains("<i"))                 //当前标题
                {
                    m_currentPartTitle   = Regex.Replace(mVideoId.Groups["content"].Value, @"<i.+?i>", "", RegexOptions.IgnoreCase);
                    m_currentPartVideoId = mVideoId.Groups["vid"].Value;
                }
                else                 //其他标题
                {
                    relatedVideoList.Add("http://www.acfun.tv" + mVideoId.Groups["href"].Value, mVideoId.Groups["content"].Value);
                }
            }


            //取得视频标题
            var videoTitleMatchResult = Regex.Match(src, @"(?<=system\.title = \$\.parseSafe\(')(.+?)(?='\))", RegexOptions.IgnoreCase);

            if (!videoTitleMatchResult.Success)
            {
                videoTitleMatchResult = Regex.Match(src, @"(?<=<title>).+?(?=</title>)", RegexOptions.IgnoreCase);
            }
            m_videoTitle       = videoTitleMatchResult.Value;
            m_currentPartTitle = string.IsNullOrEmpty(m_currentPartTitle) ? m_videoTitle : m_currentPartTitle;
            m_currentPartTitle = m_currentPartTitle.Replace(" - AcFun弹幕视频网 - 中国宅文化基地", "");

            //取得当前视频完整标题
            Info.Title         = m_videoTitle + " - " + m_currentPartTitle;
            m_videoTitle       = Tools.InvalidCharacterFilter(m_videoTitle, "");
            m_currentPartTitle = Tools.InvalidCharacterFilter(m_currentPartTitle, "");

            //解析关联项需要同时满足的条件:
            //1.这个任务不是被其他任务所添加的
            //2.用户设置了“解析关联项”
            TipText("正在选择关联视频");
            if (!Info.IsBeAdded && Info.ParseRelated && relatedVideoList.Count > 0)
            {
                //用户选择任务
                var ba = new Collection <string>();
                if (!disableDialog)
                {
                    ba = ToolForm.CreateMultiSelectForm(relatedVideoList, Info.AutoAnswer, "acfun");
                }
                //根据用户选择新建任务
                foreach (string u in ba)
                {
                    //新建任务
                    delegates.NewTask(new ParaNewTask(Info.BasePlugin, u, this.Info));
                }
            }


            //视频地址数组
            //清空地址
            Info.FilePath.Clear();
            Info.SubFilePath.Clear();

            //下载弹幕
            DownloadSubtitle(m_currentPartVideoId);

            TipText("正在解析视频源地址");
            //解析器的解析结果
            ParseResult pr = null;

            //如果允许下载视频
            if ((Info.DownloadTypes & DownloadType.Video) != 0)
            {
                var parser = new AcfunInterfaceParser();
                pr = parser.Parse(new ParseRequest
                {
                    Id          = m_currentPartVideoId,
                    Proxy       = Info.Proxy,
                    AutoAnswers = Info.AutoAnswer
                });

                //视频地址列表
                var videos = pr.ToArray();
                //支持导出列表
                if (videos != null)
                {
                    var sb = new StringBuilder();
                    foreach (string item in videos)
                    {
                        sb.Append(item);
                        sb.Append("|");
                    }
                    Settings["ExportUrl"] = sb.ToString();
                }

                //下载视频
                TipText("正在开始下载视频文件");
                //确定视频共有几个段落
                Info.PartCount = videos.Length;

                //------------分段落下载------------
                for (int i = 0; i < Info.PartCount; i++)
                {
                    Info.CurrentPart = i + 1;

                    //取得文件后缀名
                    string ext = Tools.GetExtension(videos[i]);
                    if (string.IsNullOrEmpty(ext))
                    {
                        if (string.IsNullOrEmpty(Path.GetExtension(videos[i])))
                        {
                            ext = ".flv";
                        }
                        else
                        {
                            ext = Path.GetExtension(videos[i]);
                        }
                    }
                    if (ext == ".hlv")
                    {
                        ext = ".flv";
                    }

                    //设置文件名
                    var    renamehelper = new CustomFileNameHelper();
                    string filename     = renamehelper.CombineFileName(m_customFileName,
                                                                       m_videoTitle, m_currentPartTitle, Info.PartCount == 1 ? "" : Info.CurrentPart.ToString(),
                                                                       ext.Replace(".", ""), m_acNumber, m_acSubNumber);
                    filename = Path.Combine(Info.SaveDirectory.ToString(), filename);

                    //添加文件名到文件列表中
                    Info.FilePath.Add(filename);

                    //生成父文件夹
                    if (!Directory.Exists(Path.GetDirectoryName(filename)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(filename));
                    }

                    //设置当前DownloadParameter
                    currentParameter = new DownloadParameter()
                    {
                        //文件名
                        FilePath = filename,
                        //文件URL
                        Url = videos[i],
                        //代理服务器
                        Proxy = Info.Proxy,
                        //提取缓存
                        ExtractCache        = Info.ExtractCache,
                        ExtractCachePattern = "fla*.tmp"
                    };

                    //下载文件
                    bool success = false;

                    //提示更换新Part
                    delegates.NewPart(new ParaNewPart(this.Info, i + 1));

                    //下载视频
                    try
                    {
                        success = Network.DownloadFile(currentParameter, this.Info);
                        if (!success)                         //未出现错误即用户手动停止
                        {
                            return(false);
                        }
                    }
                    catch                     //下载文件时出现错误
                    {
                        //如果此任务由一个视频组成,则报错(下载失败)
                        if (Info.PartCount == 1)
                        {
                            throw;
                        }
                        else                         //否则继续下载,设置“部分失败”状态
                        {
                            Info.PartialFinished        = true;
                            Info.PartialFinishedDetail += "\r\n文件: " + currentParameter.Url + " 下载失败";
                        }
                    }
                }         //end for
            }             //end 判断是否下载视频


            //如果插件设置中没有GenerateAcPlay项,或此项设置为true则生成.acplay快捷方式
            if (!Info.BasePlugin.Configuration.ContainsKey("GenerateAcPlay") ||
                Info.BasePlugin.Configuration["GenerateAcPlay"] == "true")
            {
                //生成AcPlay文件
                string acplay = GenerateAcplayConfig(pr);
                //支持AcPlay直接播放
                Settings["AcPlay"] = acplay;
            }

            //生成视频自动合并参数
            if (Info.FilePath.Count > 1 && !Info.PartialFinished)
            {
                Info.Settings.Remove("VideoCombine");
                var arg = new StringBuilder();
                foreach (var item in Info.FilePath)
                {
                    arg.Append(item);
                    arg.Append("|");
                }

                var    renamehelper = new CustomFileNameHelper();
                string filename     = renamehelper.CombineFileName(m_customFileName,
                                                                   m_videoTitle, m_currentPartTitle, "",
                                                                   "mp4", m_acNumber, m_acSubNumber);
                filename = Path.Combine(Info.SaveDirectory.ToString(), filename);

                arg.Append(filename);
                Info.Settings["VideoCombine"] = arg.ToString();
            }

            //下载成功完成
            return(true);
        }
Exemplo n.º 4
0
        public FormSingleSelect(ref string[] r, string tip, Dictionary <string, string> keyValueContent, string defaultKey, List <AutoAnswer> autoAnswers, string autoAnswerPrefix)
        {
            s = r;
            InitializeComponent();

            List <KeyValueItem> contents = new List <KeyValueItem>();

            foreach (string item in keyValueContent.Keys)
            {
                contents.Add(new KeyValueItem()
                {
                    Key = item, Value = keyValueContent[item]
                });
            }
            foreach (var item in contents)
            {
                combo.Items.Add(item);
            }

            //检查自动应答设置
            foreach (KeyValueItem i in combo.Items)
            {
                if (AutoAnswer.IsInAutoAnswers(autoAnswers, autoAnswerPrefix, i.Key))
                {
                    s[0] = i.Key;
                    return;
                }
            }
            //if (autoAnswers != null)
            //{
            //    foreach (AutoAnswer item in autoAnswers)
            //    {
            //        if (item.Prefix.Equals(autoAnswerPrefix, StringComparison.CurrentCultureIgnoreCase))
            //        {
            //            foreach (KeyValueItem i in combo.Items)
            //            {
            //                if (i.Key.Equals(item.Identify, StringComparison.CurrentCultureIgnoreCase))
            //                {
            //                    s[0] = i.Key;
            //                    //this.Close();
            //                    return;
            //                }
            //            }
            //        }
            //    }
            //}

            //find defaultitem
            foreach (var item in contents)
            {
                if (item.Key.Equals(defaultKey, StringComparison.CurrentCultureIgnoreCase))
                {
                    combo.SelectedItem = item;
                    break;
                }
            }

            if (combo.SelectedIndex < 0)
            {
                combo.SelectedIndex = 0;
            }

            if (!string.IsNullOrEmpty(tip))
            {
                lblTip.Text = tip;
            }
            formtitle = this.Text;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 下载视频
        /// </summary>
        public override bool Download()
        {
            //开始下载
            TipText("正在分析视频地址");

            //修正井号
            Info.Url = Info.Url.ToLower().TrimEnd('#');
            //修正旧版URL
            Info.Url = Info.Url.Replace("bilibili.tv", "bilibili.com");
            Info.Url = Info.Url.Replace("bilibili.us", "bilibili.com");
            Info.Url = Info.Url.Replace("bilibili.smgbb.cn", "www.bilibili.com");
            Info.Url = Info.Url.Replace("bilibili.kankanews.com", "www.bilibili.com");

            //修正简写URL
            if (Regex.Match(Info.Url, @"^av\d{2,6}$").Success)
            {
                Info.Url = "http://www.bilibili.com/video/" + Info.Url + "/";
            }
            //修正index_1.html
            if (!Info.Url.EndsWith(".html"))
            {
                if (Info.Url.EndsWith("/"))
                {
                    Info.Url += "index_1.html";
                }
                else
                {
                    Info.Url += "/index_1.html";
                }
            }

            string url = Info.Url;
            //取得子页面文件名(例如"/video/av12345/index_123.html")
            //string suburl = Regex.Match(Info.Url, @"bilibili\.kankanews\.com(?<part>/video/av\d+/index_\d+\.html)").Groups["part"].Value;
            string suburl = Regex.Match(Info.Url, @"www\.bilibili\.com(?<part>/video/av\d+/index_\d+\.html)").Groups["part"].Value;
            //取得AV号和子编号
            //Match mAVNumber = Regex.Match(Info.Url, @"(?<av>av\d+)/index_(?<sub>\d+)\.html");
            Match mAVNumber = BilibiliPlugin.RegexBili.Match(Info.Url);

            if (!mAVNumber.Success)
            {
                mAVNumber = BilibiliPlugin.RegexAcg.Match(Info.Url);
            }
            Settings["AVNumber"]    = mAVNumber.Groups["id"].Value;
            Settings["AVSubNumber"] = mAVNumber.Groups["page"].Value;
            Settings["AVSubNumber"] = string.IsNullOrEmpty(Settings["AVSubNumber"]) ? "1" : Settings["AVSubNumber"];
            //设置自定义文件名
            Settings["CustomFileName"] = BilibiliPlugin.DefaultFileNameFormat;
            if (Info.BasePlugin.Configuration.ContainsKey("CustomFileName"))
            {
                Settings["CustomFileName"] = Info.BasePlugin.Configuration["CustomFileName"];
            }

            //是否通过【自动应答】禁用对话框
            bool disableDialog = AutoAnswer.IsInAutoAnswers(Info.AutoAnswer, "bilibili", "auto");

            //视频地址数组
            string[] videos = null;

            try
            {
                //解析关联项需要同时满足的条件:
                //1.这个任务不是被其他任务所添加的
                //2.用户设置了“解析关联项”
                if (!Info.IsBeAdded || Info.ParseRelated)
                {
                    //取得网页源文件
                    string src      = Network.GetHtmlSource(url, Encoding.UTF8, Info.Proxy);
                    string subtitle = "";
                    //取得子标题
                    Regex           rSubTitle  = new Regex(@"<option value='(?<part>.+?\.html)'( selected)?>(?<content>.+?)</option>");
                    MatchCollection mSubTitles = rSubTitle.Matches(src);

                    //如果存在下拉列表框
                    if (mSubTitles.Count > 0)
                    {
                        //确定当前视频的子标题
                        foreach (Match item in mSubTitles)
                        {
                            if (suburl == item.Groups["part"].Value)
                            {
                                subtitle = item.Groups["content"].Value;
                                break;
                            }
                        }

                        //准备(地址-标题)字典
                        var dict = new Dictionary <string, string>();
                        foreach (Match item in mSubTitles)
                        {
                            if (suburl != item.Groups["part"].Value)
                            {
                                dict.Add(url.Replace(suburl, item.Groups["part"].Value),
                                         item.Groups["content"].Value);
                            }
                        }
                        //用户选择任务
                        var ba = new Collection <string>();
                        if (!disableDialog)
                        {
                            ba = ToolForm.CreateMultiSelectForm(dict, Info.AutoAnswer, "bilibili");
                        }
                        //根据用户选择新建任务
                        foreach (string u in ba)
                        {
                            NewTask(u);
                        }
                    }
                }

                //获取视频信息API
                var ts         = Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds);
                var apiAddress = string.Format(@"http://api.bilibili.cn/view?appkey={0}&ts={1}&id={2}&page={3}",
                                               BilibiliPlugin.AppKey,
                                               ts,
                                               Settings["AVNumber"],
                                               Settings["AVSubNumber"]);
                //AcDown所使用的AppKey是旧AppKey,权限比新申请的要高,而且不需要加上sign验证
                //如果将来要使用sign验证的话可以使用下面的代码来算出sign
                //但是这段代码目前加上后还是不能正确工作的状态,不知道为什么
                //Tools.GetStringHash("appkey=" + BilibiliPlugin.AppKey +
                //					"&id=" + Settings["AVNumber"] +
                //					"&page=" + Settings["AVSubNumber"] +
                //					"&ts=" + ts +
                //					BilibiliPlugin.AppSecret));
                var webrequest = (HttpWebRequest)WebRequest.Create(apiAddress);
                webrequest.Accept    = @"application/json";
                webrequest.UserAgent = "AcDown/" + Application.ProductVersion + " ([email protected])";
                webrequest.Proxy     = Info.Proxy;
                var viewSrc = Network.GetHtmlSource(webrequest, Encoding.UTF8);
                //登录获取API结果
                if (viewSrc.Contains("no perm error"))
                {
                    viewSrc = LoginApi(url, apiAddress, out m_cookieContainer);
                }

                AvInfo avInfo;
                try
                {
                    //解析JSON
                    avInfo = JsonConvert.DeserializeObject <AvInfo>(viewSrc);
                }
                catch
                {
                    //由于接口原因,有时候虽然请求了json但是会返回XML格式(呃
                    var viewDoc = new XmlDocument();
                    viewDoc.LoadXml(viewSrc);
                    avInfo          = new AvInfo();
                    avInfo.title    = viewDoc.SelectSingleNode(@"/info/title").InnerText.Replace("&amp;", "&");
                    avInfo.partname = viewDoc.SelectSingleNode(@"/info/partname").InnerText.Replace("&amp;", "&");
                    avInfo.cid      = Regex.Match(viewSrc, @"(?<=\<cid\>)\d+(?=\</cid\>)", RegexOptions.IgnoreCase).Value;
                }

                //视频标题和子标题
                string title  = avInfo.title ?? "";
                string stitle = avInfo.partname ?? "";

                if (String.IsNullOrEmpty(stitle))
                {
                    Info.Title = title;
                    stitle     = title;
                }
                else
                {
                    Info.Title = title + " - " + stitle;
                }
                //过滤非法字符
                title  = Tools.InvalidCharacterFilter(title, "");
                stitle = Tools.InvalidCharacterFilter(stitle, "");

                //清空地址
                Info.FilePath.Clear();
                Info.SubFilePath.Clear();

                //CID
                Settings["chatid"] = avInfo.cid;

                //下载弹幕
                DownloadComment(title, stitle, Settings["chatid"]);

                //解析器的解析结果
                ParseResult pr = null;

                //如果允许下载视频
                if ((Info.DownloadTypes & DownloadType.Video) != 0)
                {
                    //var playurlSrc = Network.GetHtmlSource(@"http://interface.bilibili.tv/playurl?otype=xml&cid=" + Settings["chatid"] + "&type=flv", Encoding.UTF8);
                    //var playurlDoc = new XmlDocument();
                    //playurlDoc.LoadXml(playurlSrc);

                    //获得视频列表
                    var prRequest = new ParseRequest()
                    {
                        Id              = Settings["chatid"],
                        Proxy           = Info.Proxy,
                        AutoAnswers     = Info.AutoAnswer,
                        CookieContainer = m_cookieContainer
                    };
                    pr     = new BilibiliInterfaceParser().Parse(prRequest);
                    videos = pr.ToArray();

                    //支持导出列表
                    if (videos != null)
                    {
                        StringBuilder sb = new StringBuilder(videos.Length * 2);
                        foreach (string item in videos)
                        {
                            sb.Append(item);
                            sb.Append("|");
                        }
                        if (Settings.ContainsKey("ExportUrl"))
                        {
                            Settings["ExportUrl"] = sb.ToString();
                        }
                        else
                        {
                            Settings.Add("ExportUrl", sb.ToString());
                        }
                    }

                    //下载视频
                    //确定视频共有几个段落
                    Info.PartCount = videos.Length;

                    //------------分段落下载------------
                    for (int i = 0; i < Info.PartCount; i++)
                    {
                        Info.CurrentPart = i + 1;

                        //取得文件后缀名
                        string ext = Tools.GetExtension(videos[i]);
                        if (string.IsNullOrEmpty(ext))
                        {
                            if (string.IsNullOrEmpty(Path.GetExtension(videos[i])))
                            {
                                ext = ".flv";
                            }
                            else
                            {
                                ext = Path.GetExtension(videos[i]);
                            }
                        }
                        if (ext == ".hlv")
                        {
                            ext = ".flv";
                        }

                        //设置文件名
                        var    renamehelper = new CustomFileNameHelper();
                        string filename     = renamehelper.CombineFileName(Settings["CustomFileName"],
                                                                           title, stitle, Info.PartCount == 1 ? "" : Info.CurrentPart.ToString(),
                                                                           ext.Replace(".", ""), Settings["AVNumber"], Settings["AVSubNumber"]);
                        filename = Path.Combine(Info.SaveDirectory.ToString(), filename);

                        //生成父文件夹
                        if (!Directory.Exists(Path.GetDirectoryName(filename)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(filename));
                        }

                        //设置当前DownloadParameter
                        currentParameter = new DownloadParameter()
                        {
                            //文件名 例: c:\123(1).flv
                            FilePath = filename,
                            //文件URL
                            Url = videos[i],
                            //代理服务器
                            Proxy = Info.Proxy,
                            //提取缓存
                            ExtractCache        = Info.ExtractCache,
                            ExtractCachePattern = "fla*.tmp"
                        };

                        //添加文件路径到List<>中
                        Info.FilePath.Add(currentParameter.FilePath);
                        //下载文件
                        bool success;

                        //提示更换新Part
                        delegates.NewPart(new ParaNewPart(this.Info, i + 1));

                        //下载视频
                        try
                        {
                            success = Network.DownloadFile(currentParameter, this.Info);
                            if (!success)                             //未出现错误即用户手动停止
                            {
                                return(false);
                            }
                        }
                        catch                         //下载文件时出现错误
                        {
                            //如果此任务由一个视频组成,则报错(下载失败)
                            if (Info.PartCount == 1)
                            {
                                throw;
                            }
                            else                             //否则继续下载,设置“部分失败”状态
                            {
                                Info.PartialFinished        = true;
                                Info.PartialFinishedDetail += "\r\n文件: " + currentParameter.Url + " 下载失败";
                            }
                        }
                    }            //end for
                }                //end 判断是否下载视频


                //如果插件设置中没有GenerateAcPlay项,或此项设置为true则生成.acplay快捷方式
                if (!Info.BasePlugin.Configuration.ContainsKey("GenerateAcPlay") ||
                    Info.BasePlugin.Configuration["GenerateAcPlay"] == "true")
                {
                    //生成AcPlay文件
                    string acplay = GenerateAcplayConfig(pr, title, stitle);
                    //支持AcPlay直接播放
                    Settings["AcPlay"] = acplay;
                }

                //生成视频自动合并参数
                if (Info.FilePath.Count > 1 && !Info.PartialFinished)
                {
                    Info.Settings.Remove("VideoCombine");
                    var arg = new StringBuilder();
                    foreach (var item in Info.FilePath)
                    {
                        arg.Append(item);
                        arg.Append("|");
                    }

                    var    renamehelper = new CustomFileNameHelper();
                    string filename     = renamehelper.CombineFileName(Settings["CustomFileName"],
                                                                       title, stitle, "",
                                                                       "mp4", Info.Settings["AVNumber"], Info.Settings["AVSubNumber"]);
                    filename = Path.Combine(Info.SaveDirectory.ToString(), filename);

                    arg.Append(filename);
                    Info.Settings["VideoCombine"] = arg.ToString();
                }
            }
            catch
            {
                Settings["user"]     = "";
                Settings["password"] = "";
                throw;
            }

            return(true);
        }