Exemplo n.º 1
0
        void Director(string dir)
        {
            DirectoryInfo fdir = new DirectoryInfo(dir);

            FileSystemInfo[] fsinfos = fdir.GetFileSystemInfos();
            foreach (FileSystemInfo fsinfo in fsinfos)
            {
                if (fsinfo is DirectoryInfo)   //判断是否为文件夹
                {
                    Director(fsinfo.FullName); //递归调用
                }
                else
                {
                    if (extNames.ToUpper().IndexOf(fsinfo.Extension.ToUpper()) != -1)
                    {//视频文件
                        FileInfo ff = new System.IO.FileInfo(fsinfo.FullName);
                        //太小的视频文件 判断为损坏跳过
                        if (ff.Length < 1024)
                        {
                            textBox3.AppendText(fsinfo.Name + ":" + ff.Length + "\r\n");
                            ExeLog.WriteLog("nolist.txt", fsinfo.Name + "\r\n");
                            continue;
                        }
                        Av av = new Av();
                        av.Path = fsinfo.FullName;
                        avs.Add(av);
                        textBox2.AppendText(fsinfo.Name + "\r\n");
                    } //if 视频文件
                }     //if
            }         //foreach
        }             //method
Exemplo n.º 2
0
        }     //method

        public void Ffmpeg(string filePath)
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "\\temp";
            string name = Path.GetFileName(filePath);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string strArg = "-i \"" + filePath + "\" -y -f image2 -t 0.001 -ss 1 -s 1x1 \"" + path + "\\" + name + ".jpg\"";

            try
            {
                using (Process p = new Process())
                {
                    p.StartInfo.Arguments             = strArg;
                    p.StartInfo.RedirectStandardError = true;                                           //把外部程序错误输出写到StandardError流中(这个一定要注意,FFMPEG的所有输出信息,都为错误输出流,用StandardOutput是捕获不到任何消息的...这是我耗费了2个多月得出来的经验...mencoder就是用standardOutput来捕获的)
                    p.StartInfo.CreateNoWindow        = true;                                           //不创建进程窗口
                    p.StartInfo.UseShellExecute       = false;
                    p.StartInfo.FileName       = Directory.GetCurrentDirectory() + "\\DLL\\ffmpeg.exe"; //要调用外部程序的绝对路径
                    p.StartInfo.CreateNoWindow = true;
                    p.Start();
                    p.WaitForExit(60 * 1000);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            /*Process p = new Process();//建立外部调用线程
             * p.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\DLL\\ffmpeg.exe";//要调用外部程序的绝对路径
             * p.StartInfo.Arguments = strArg;
             * p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动线程(一定为FALSE,详细的请看MSDN)
             * p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,FFMPEG的所有输出信息,都为错误输出流,用StandardOutput是捕获不到任何消息的...这是我耗费了2个多月得出来的经验...mencoder就是用standardOutput来捕获的)
             * p.StartInfo.CreateNoWindow = false;//不创建进程窗口
             * p.ErrorDataReceived += new DataReceivedEventHandler(Output);//外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
             * p.Start();//启动线程
             * //p.BeginErrorReadLine();//开始异步读取
             * p.WaitForExit();//阻塞等待进程结束
             * p.Close();//关闭进程
             * p.Dispose();//释放资源*/

            if (File.Exists(path + "\\" + name + ".jpg"))
            {
                _syncContext.Post(OutLog, name);
            }
            else
            {
                ExeLog.WriteLog("nolist.txt", name + "\r\n");
                _syncContext.Post(OutError, name);
            }
        }
Exemplo n.º 3
0
        }     //method

        public void DownloadCover(Av av)
        {
            Match match = new Regex(@"<a class=""bigImage"" href=""(?<url>.*?)"">").Match(av.Html);

            if (match.Success)
            {
                string url = match.Groups["url"].Value;
                if (!url.StartsWith("http"))
                {
                    url = basePath + url;
                }
                Download.HttpDownloadFile(url, av.Path + "\\", "art.jpg");
                //int fg = url.LastIndexOf("/") + 1;
                //string name = url.Substring(fg, url.Length - fg - 6).Trim();
                url = url.Replace("_b", "");
                string qb = "<li class=\"active\"><a href=\"" + basePath + "/\">";
                if (av.Html.IndexOf(qb) != -1)
                {
                    url = url.Replace("cover", "thumb");
                }
                else
                {
                    url = url.Replace("cover", "thumbs");
                }

                Download.HttpDownloadFile(url, av.Path + "\\", "folder.jpg");

                //修改文件夹名称
                try
                {
                    StringBuilder   sb         = new StringBuilder();
                    MatchCollection startNames = new Regex(@"<div class=""star-name""><a href="".*?"" title="".*?"">(?<name>.*?)</a></div>").Matches(av.Html);
                    int             i          = 0;
                    int             x          = 0;
                    int             y          = 0;
                    foreach (Match m in startNames)
                    {
                        sb.Append(m.Groups["name"].Value);
                        i++;
                        if (i < startNames.Count)
                        {
                            sb.Append(",");
                        }
                        if (++x > 20)
                        {
                            y++; x = 0;
                            File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + y + ".txt").Close();
                            sb.Clear();
                        }
                    }
                    if (sb.Length > 0)
                    {
                        File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + (y == 0?"":y + 1 + "") + ".txt").Close();
                    }
                }
                catch (Exception e)
                {
                    _syncContext.Post(OutError, av.Id + " :获取女优失败");
                }

                try
                {
                    //match = new Regex(@"<h3>(?<title>.*?)</h3>[\s\S]*?<p><span class=""header"">發行日期:</span>(?<date>.*?)</p>").Match(av.Html);
                    match = new Regex(@"<h3>(?<title>[\s\S]*?)</h3>[\s\S]*?<p><span class=""header"">發行日期:</span>(?<date>.*?)</p>").Match(av.Html);

                    string newPath = null;
                    if (match.Success)
                    {
                        av.date  = match.Groups["date"].Value.Trim();
                        av.title = match.Groups["title"].Value.Trim();

                        string newfolderName = match.Groups["date"].Value.Trim() + " " + match.Groups["title"].Value.Trim();
                        newfolderName = newfolderName.Replace("\\", "‖");
                        newfolderName = newfolderName.Replace("/", "‖");
                        newfolderName = newfolderName.Replace(":", ":");
                        newfolderName = newfolderName.Replace("*", "※");
                        newfolderName = newfolderName.Replace("?", "?");
                        newfolderName = newfolderName.Replace("<", "〈");
                        newfolderName = newfolderName.Replace(">", "〉");
                        newfolderName = newfolderName.Replace("\n", " ");
                        newfolderName = newfolderName.Replace("\r", " ");
                        //newfolderName = Regex.Replace(newfolderName, @"[/n/r]", " ");

                        StringBuilder rBuilder = new StringBuilder(newfolderName);
                        foreach (char rInvalidChar in Path.GetInvalidPathChars())
                        {
                            rBuilder.Replace(rInvalidChar.ToString(), string.Empty);
                        }

                        int    fg                      = av.Path.LastIndexOf("\\");
                        string baseFilePath            = av.Path.Substring(0, fg).Trim();
                        System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(av.Path);

                        string apath = "";
                        qb = "<li class=\"active\"><a href=\"" + basePath + "/\">";
                        if (av.Html.IndexOf(qb) != -1)
                        {
                            apath += "骑兵\\";
                        }
                        else
                        {
                            apath += "步兵\\";
                        }
                        MoveFolder(av.Path, baseFilePath + "\\" + apath + newfolderName);
                        Directory.Delete(av.Path, true);
                        //folder.MoveTo();
                        newPath = baseFilePath + "\\" + apath + newfolderName;
                        av.Path = newPath;
                    }
                    else
                    {
                        ExeLog.WriteLog("获取AV名称失败:\r\n" + av.Html);
                        _syncContext.Post(OutError, av.Id + " :获取AV名称失败");
                        return;
                    }

                    //修改视频名称 改为符合 emby的规则
                    string[]      extNames = new string[] { ".avi", ".mov", ".mpg", ".RA", ".RM", ".RMVB", ".WMV", ".mkv", ".mp4", ".asf", ".m4v", ".VOB" };
                    DirectoryInfo fdir     = new DirectoryInfo(newPath);
                    FileInfo[]    file     = fdir.GetFiles();
                    if (file.Length != 0)
                    { //当前目录文件或文件夹不为空
                        for (int i = 0; i < extNames.Length; i++)
                        {
                            int x = 0;
                            foreach (FileInfo f in file)
                            {
                                if (extNames[i].ToLower().Equals(f.Extension.ToLower()))
                                {
                                    x++;
                                }
                            }
                            int y = 1;
                            foreach (FileInfo f in file) //显示当前目录所有文件
                            {
                                if (extNames[i].ToLower().Equals(f.Extension.ToLower()))
                                {
                                    string newName = newPath + "\\" + av.Id + (x > 1 ? "-cd" + y : "") + f.Extension;
                                    av.CD1 = x > 1;
                                    try
                                    {
                                        //记录文件名称
                                        ChangeNameLogTxt(f.Name, newName);
                                        File.Move(f.FullName, newName);
                                        //File.Create(folder + "\\"+ (x > 1 ? "-cd" + y : "") + f.Name + ".old.name").Close();
                                    }
                                    catch (Exception ex)
                                    {
                                        _syncContext.Post(OutError, av.Id + "-修改视频文件名称错误 \r\n");
                                    }
                                    y++;
                                } //for files
                            }
                        }         //for ext
                    }             //file
                }
                catch (Exception e)
                {
                    _syncContext.Post(OutError, av.Id + " :修改AV名称失败" + e.Message);
                }

                _syncContext.Post(OutLog, av.Id);

                try
                {
                    creNfo(av);
                }
                catch (Exception e)
                {
                    _syncContext.Post(OutLog, av.Id + ":nfo 创建失败" + e.Message);
                }
            }
        }
Exemplo n.º 4
0
        }     //method

        public void DownloadCover(Av av)
        {
            //MatchCollection matchs = new Regex(@"class=""responsive""\s+src=""(?<upload>.*?)""/>", RegexOptions.Multiline).Matches(av.Html);
            MatchCollection matchs = new Regex(@"class=""responsive""\s+src=""(?<upload>.*?)""\s*/>", RegexOptions.Multiline).Matches(av.Html);
            int             s      = 0;

            foreach (Match match in matchs)
            {
                string url = match.Groups["upload"].Value;
                Download.HttpDownloadFile(basePath + url, av.Path + "\\", s == 0 ? "poster.jpg" : "screenshot" + s + ".jpg");
                s++;
            }

            Match m = new Regex(@"<a\shref=""(.*?)""\starget=""_blank""\s><img\sid=""thumbpic""").Match(av.Html);

            if (m.Success)
            {
                string url = m.Groups[1].Value;
                Download.HttpDownloadFile(basePath + url, av.Path + "\\", "screenshot.jpg");
            }

            m = new Regex(@"<h5><strong style=""color:red;"">女优名字</strong>:<a href="".*?"">(.*?)</a></h5>
", RegexOptions.Singleline).Match(av.Html);
            if (m.Success)
            {
                string name = fileNameX(m.Groups[1].Value);
                File.Create(av.Path + "\\" + av.Id + " " + name + ".star.txt").Close();
            }

            m = new Regex(@"<h5><strong style=""color:red;"">卖家信息</strong>:<a href="".*?"">(.*?)</a>", RegexOptions.Singleline).Match(av.Html);
            if (m.Success)
            {
                string name = fileNameX(m.Groups[1].Value);
                File.Create(av.Path + "\\" + av.Id + " " + name + ".seller.txt").Close();
            }

            string newPath = null;

            try
            {
                Match nameMatch = new Regex(@"<div class=""col-sm-8"">\s+<h3>(.*?)</h3>", RegexOptions.Singleline).Match(av.Html);
                if (nameMatch.Success)
                {
                    string newfolderName           = fileNameX(nameMatch.Groups[1].Value);
                    int    fg                      = av.Path.LastIndexOf("\\");
                    string basePath                = av.Path.Substring(0, fg).Trim();
                    System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(av.Path);
                    if (!Directory.Exists(basePath + "\\ok"))
                    {
                        Directory.CreateDirectory(basePath + "\\ok");
                    }
                    folder.MoveTo(basePath + "\\ok\\" + newfolderName);
                    newPath = basePath + "\\ok\\" + newfolderName;
                }
                else
                {
                    ExeLog.WriteLog("获取AV名称失败:\r\n" + av.Html);
                    _syncContext.Post(OutError, av.Id + " :获取AV名称失败");
                    return;
                }

                //修改视频名称 改为符合 emby的规则
                string[]      extNames = new string[] { ".avi", ".mov", ".mpg", ".RA", ".RM", ".RMVB", ".WMV", ".mkv", ".mp4", ".asf", ".m4v", ".VOB" };
                DirectoryInfo fdir     = new DirectoryInfo(newPath);
                FileInfo[]    file     = fdir.GetFiles();
                if (file.Length != 0)
                {     //当前目录文件或文件夹不为空
                    for (int i = 0; i < extNames.Length; i++)
                    {
                        int x = 0;
                        foreach (FileInfo f in file)
                        {
                            if (extNames[i].ToLower().Equals(f.Extension.ToLower()))
                            {
                                x++;
                            }
                        }
                        int y = 1;
                        foreach (FileInfo f in file)     //显示当前目录所有文件
                        {
                            if (extNames[i].ToLower().Equals(f.Extension.ToLower()))
                            {
                                string newName = newPath + "\\" + av.Id + (x > 1 ? "-cd" + y : "") + f.Extension;
                                try
                                {
                                    //记录文件名称
                                    ChangeNameLogTxt(f.Name, newName);
                                    File.Move(f.FullName, newName);
                                    //File.Create(folder + "\\"+ (x > 1 ? "-cd" + y : "") + f.Name + ".old.name").Close();
                                }
                                catch (Exception ex)
                                {
                                    _syncContext.Post(OutError, av.Id + "-修改视频文件名称错误 \r\n");
                                }
                                y++;
                            } //for files
                        }
                    }         //for ext
                }             //file
            }
            catch (Exception e)
            {
                _syncContext.Post(OutError, av.Id + " :修改AV名称失败" + e.Message);
            }


            //_syncContext.Post(OutLog, av.Id);
            //}
        }
Exemplo n.º 5
0
        }     //method

        public void DownloadCover(Av av)
        {
            Match match = new Regex(@"<img id=""video_jacket_img"" src=""//(?<url>.*?)""").Match(av.Html);

            if (match.Success)
            {
                string url = match.Groups["url"].Value;
                url = "http://" + url;
                Download.HttpDownloadFile(url, av.Path + "\\", "art.jpg");
                url = url.Replace("pl.jpg", "ps.jpg");
                Download.HttpDownloadFile(url, av.Path + "\\", "folder.jpg");

                //修改文件夹名称
                try
                {
                    StringBuilder sb             = new StringBuilder();
                    Match         startNameMatch = new Regex(@"<td class=""header"">演员:</td>\s*<td class=""text"">(?<name>.*?)</td>").Match(av.Html);
                    if (startNameMatch.Success)
                    {
                        string startName = ReplaceHtmlTag(startNameMatch.Groups["name"].Value);
                        if (startName.Length > 100)
                        {
                            string[] startNames = startName.Trim().Split(' ');
                            int      x          = 0;
                            int      y          = 0;
                            foreach (string n in startNames)
                            {
                                if (++x > 20)
                                {
                                    y++; x = 0;
                                    File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + y + ".txt").Close();
                                    sb.Clear();
                                }
                            }
                            if (sb.Length > 0)
                            {
                                File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + (y == 0 ? "" : y + 1 + "") + ".txt").Close();
                            }
                        }
                        else
                        {
                            File.Create(av.Path + "\\" + av.Id + " " + startName.Trim().Replace(' ', ',') + ".star.txt").Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    _syncContext.Post(OutError, av.Id + " :获取女优失败");
                }

                try
                {
                    //match = new Regex(@"<h3>(?<title>.*?)</h3>[\s\S]*?<p><span class=""header"">發行日期:</span>(?<date>.*?)</p>").Match(av.Html);
                    match = new Regex(@"<div id=""video_title""><h3 class=""post-title text""><a.*?>(?<title>.*?)</a></h3>[.\s\S]*<td class=""header"">发行日期:</td>\s*<td class=""text"">(?<date>.*?)</td>
").Match(av.Html);
                    if (match.Success)
                    {
                        string newfolderName = match.Groups["date"].Value.Trim() + " " + match.Groups["title"].Value.Trim();
                        newfolderName = newfolderName.Replace("\\", "‖");
                        newfolderName = newfolderName.Replace("/", "‖");
                        newfolderName = newfolderName.Replace(":", ":");
                        newfolderName = newfolderName.Replace("*", "※");
                        newfolderName = newfolderName.Replace("?", "?");
                        newfolderName = newfolderName.Replace("<", "〈");
                        newfolderName = newfolderName.Replace(">", "〉");
                        newfolderName = newfolderName.Replace("\n", " ");
                        newfolderName = newfolderName.Replace("\r", " ");
                        //newfolderName = Regex.Replace(newfolderName, @"[/n/r]", " ");

                        StringBuilder rBuilder = new StringBuilder(newfolderName);
                        foreach (char rInvalidChar in Path.GetInvalidPathChars())
                        {
                            rBuilder.Replace(rInvalidChar.ToString(), string.Empty);
                        }

                        int    fg       = av.Path.LastIndexOf("\\");
                        string basePath = av.Path.Substring(0, fg).Trim();
                        System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(av.Path);
                        folder.MoveTo(basePath + "\\" + newfolderName);
                    }
                    else
                    {
                        ExeLog.WriteLog("获取AV名称失败:\r\n" + av.Html);
                        _syncContext.Post(OutError, av.Id + " :获取AV名称失败");
                    }
                }
                catch (Exception e)
                {
                    _syncContext.Post(OutError, av.Id + " :修改AV名称失败");
                }


                _syncContext.Post(OutLog, av.Id);
            }
        }