예제 #1
0
 public NewMovieDialogResult(string text, int option) : base(text, option)
 {
     VedioType = (VedioType)(option + 1);
 }
예제 #2
0
        /// <summary>
        /// 分类视频并导入
        /// </summary>
        /// <param name="MoviePaths"></param>
        /// <param name="ct"></param>
        /// <param name="IsEurope"></param>
        /// <returns></returns>
        public static double DistinctMovieAndInsert(List <string> MoviePaths, CancellationToken ct, bool IsEurope = false)
        {
            Logger.LogScanInfo(Environment.NewLine + "-----【" + DateTime.Now.ToString() + "】-----");
            Logger.LogScanInfo(Environment.NewLine + $"扫描出 => {MoviePaths.Count}  个 \n");

            DataBase cdb = new DataBase();

            //检查未识别出番号的视频
            List <string> r1             = new List <string>();
            string        c1             = "";
            string        id             = "";
            VedioType     vt             = 0;
            double        totalinsertnum = 0;
            double        unidentifynum  = 0;

            foreach (var item in MoviePaths)
            {
                if (File.Exists(item))
                {
                    id = IsEurope ? Identify.GetEuFanhao(new FileInfo(item).Name) : Identify.GetFanhao(new FileInfo(item).Name);
                    //Console.WriteLine($"{id}=>{item}");
                    if (IsEurope)
                    {
                        if (string.IsNullOrEmpty(id))
                        {
                            vt = 0;
                        }
                        else
                        {
                            vt = VedioType.欧美;
                        }
                    }
                    else
                    {
                        vt = Identify.GetVedioType(id);
                    }

                    if (vt != 0)
                    {
                        r1.Add(item);
                    }
                    else
                    {
                        //写日志
                        c1 += "   " + item + Environment.NewLine;
                        unidentifynum++;
                    }
                }
            }
            Logger.LogScanInfo($"\n【未识别出的视频:{unidentifynum}个】\n" + c1);

            //检查 重复|分段 视频
            Dictionary <string, List <string> > repeatlist = new Dictionary <string, List <string> >();
            string c2 = "";

            foreach (var item in r1)
            {
                if (File.Exists(item))
                {
                    id = IsEurope ? Identify.GetEuFanhao(new FileInfo(item).Name) : Identify.GetFanhao(new FileInfo(item).Name);
                    if (!repeatlist.ContainsKey(id))
                    {
                        List <string> pathlist = new List <string>();
                        pathlist.Add(item);
                        repeatlist.Add(id, pathlist);
                    }
                    else
                    {
                        repeatlist[id].Add(item);
                    }
                }
            }

            Console.WriteLine("repeatlist:" + repeatlist.Count);

            List <string>         removelist     = new List <string>();
            List <List <string> > subsectionlist = new List <List <string> >();

            foreach (KeyValuePair <string, List <string> > kvp in repeatlist)
            {
                if (kvp.Value.Count > 1)
                {
                    bool issubsection = IsSubSection(kvp.Value);
                    if (issubsection)
                    {
                        subsectionlist.Add(kvp.Value);
                    }
                    else
                    {
                        c2 += $"   识别码为:{kvp.Key}" + Environment.NewLine;
                        (string maxfilepath, List <string> Excludelsist) = ExcludeMaximumSize(kvp.Value);
                        removelist.AddRange(Excludelsist);
                        c2 += $"      导入的:{maxfilepath},文件大小:{new FileInfo(maxfilepath).Length}" + Environment.NewLine;
                        Excludelsist.ForEach(arg =>
                        {
                            c2 += $"      未导入:{arg},文件大小:{new FileInfo(arg).Length}" + Environment.NewLine;
                        });
                    }
                }
                else
                {
                }
            }
            Logger.LogScanInfo($"\n【重复的视频:{removelist.Count + subsectionlist.Count}个】" + Environment.NewLine + c2);
            List <string> insertList = r1.Except(removelist).ToList();

            Console.WriteLine("removelist:" + removelist.Count);
            Console.WriteLine("subsectionlist:" + subsectionlist.Count);


            //导入分段视频
            foreach (var item in subsectionlist)
            {
                insertList = insertList.Except(item).ToList();

                try
                {
                    ct.ThrowIfCancellationRequested();
                }
                catch (OperationCanceledException ex)
                {
                    Logger.LogE(ex);
                    break;
                }
                string   subsection = "";
                FileInfo fileinfo   = new FileInfo(item[0]);
                id = IsEurope ? Identify.GetEuFanhao(fileinfo.Name) : Identify.GetFanhao(fileinfo.Name);
                if (IsEurope)
                {
                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    else
                    {
                        vt = VedioType.欧美;
                    }
                }
                else
                {
                    vt = Identify.GetVedioType(id);
                }
                if (string.IsNullOrEmpty(id) | vt == 0)
                {
                    continue;
                }

                //文件大小视为所有文件之和
                double filesize = 0;
                for (int i = 0; i < item.Count; i++)
                {
                    if (!File.Exists(item[i]))
                    {
                        continue;
                    }
                    FileInfo fi = new FileInfo(item[i]);
                    subsection += item[i] + ";";
                    filesize   += fi.Length;
                }

                //获取创建日期
                string createDate = "";
                try { createDate = fileinfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"); }
                catch { }
                if (createDate == "")
                {
                    createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                Movie movie = new Movie()
                {
                    filepath   = item[0],
                    id         = id,
                    filesize   = filesize,
                    vediotype  = (int)vt,
                    subsection = subsection.Substring(0, subsection.Length - 1),
                    scandate   = createDate
                };
                cdb.InsertScanMovie(movie); totalinsertnum += 1;
            }

            Console.WriteLine("insertList:" + insertList.Count);


            //导入所有视频


            foreach (var item in insertList)
            {
                try
                {
                    ct.ThrowIfCancellationRequested();
                }
                catch (OperationCanceledException ex)
                {
                    Logger.LogE(ex);
                    break;
                }
                if (!File.Exists(item))
                {
                    continue;
                }
                FileInfo fileinfo = new FileInfo(item);

                string createDate = "";
                try { createDate = fileinfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"); }
                catch { }
                if (createDate == "")
                {
                    createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                id = IsEurope ? Identify.GetEuFanhao(fileinfo.Name) : Identify.GetFanhao(fileinfo.Name);
                if (IsEurope)
                {
                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    else
                    {
                        vt = VedioType.欧美;
                    }
                }
                else
                {
                    vt = Identify.GetVedioType(id);
                }
                Movie movie = new Movie()
                {
                    filepath  = item,
                    id        = id,
                    filesize  = fileinfo.Length,
                    vediotype = (int)vt,
                    scandate  = createDate
                };
                cdb.InsertScanMovie(movie); totalinsertnum += 1;
            }
            cdb.CloseDB();
            Logger.LogScanInfo(Environment.NewLine + $"总计导入 => {totalinsertnum}个" + Environment.NewLine);


            //从 主数据库中 复制信息
            if (Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First().ToLower() != "info")
            {
                try
                {
                    //待修复 的 bug
                    CopyDatabaseInfo(Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First().ToLower());
                }
                catch { }
            }



            return(totalinsertnum);
        }
예제 #3
0
        /// <summary>
        /// 分类视频并导入
        /// </summary>
        /// <param name="MoviePaths"></param>
        /// <param name="ct"></param>
        /// <param name="IsEurope"></param>
        /// <returns></returns>
        public static double DistinctMovieAndInsert(List <string> MoviePaths, CancellationToken ct, bool IsEurope = false)
        {
            Logger.LogScanInfo(Environment.NewLine + "-----【" + DateTime.Now.ToString() + "】-----");
            Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.ScanVideo} => {MoviePaths.Count} " + Environment.NewLine);

            List <string> properIdList    = new List <string>();
            StringBuilder logStr          = new StringBuilder();
            string        id              = "";
            VedioType     vt              = 0;
            double        insertCount     = 0; //总的导入数目
            double        unidentifyCount = 0; //无法识别的数目

            //检查未识别出番号的视频
            foreach (var item in MoviePaths)
            {
                if (File.Exists(item))
                {
                    id = IsEurope ? Identify.GetEuFanhao(new FileInfo(item).Name) : Identify.GetFanhao(new FileInfo(item).Name);

                    if (IsEurope)
                    {
                        if (string.IsNullOrEmpty(id))
                        {
                            vt = 0;
                        }
                        else
                        {
                            vt = VedioType.欧美;
                        }
                    }
                    else
                    {
                        vt = Identify.GetVideoType(id);
                    }


                    if (vt != 0)
                    {
                        properIdList.Add(item);
                    }
                    else
                    {
                        logStr.Append("   " + item + Environment.NewLine);
                        unidentifyCount++;
                    }
                }
            }
            Logger.LogScanInfo(Environment.NewLine + $"【{Jvedio.Language.Resources.NotRecognizeNumber} :{unidentifyCount}】" + Environment.NewLine + logStr.ToString());

            //检查 重复|分段 视频
            Dictionary <string, List <string> > repeatlist = new Dictionary <string, List <string> >();
            StringBuilder logSubSection = new StringBuilder();

            foreach (var item in properIdList)
            {
                if (File.Exists(item))
                {
                    id = IsEurope ? Identify.GetEuFanhao(new FileInfo(item).Name) : Identify.GetFanhao(new FileInfo(item).Name);
                    if (!repeatlist.ContainsKey(id))
                    {
                        List <string> pathlist = new List <string> {
                            item
                        };
                        repeatlist.Add(id, pathlist);
                    }
                    else
                    {
                        repeatlist[id].Add(item);//每个 id 对应一组视频路径,视频路径最多的视为分段视频
                    }
                }
            }

            List <string>         removelist     = new List <string>();
            List <List <string> > subsectionlist = new List <List <string> >();

            foreach (KeyValuePair <string, List <string> > kvp in repeatlist)
            {
                if (kvp.Value.Count > 1)
                {
                    //路径个数大于1 才为分段视频
                    (bool issubsection, List <string> filepathlist, List <string> notsubsection) = IsSubSection(kvp.Value);
                    if (issubsection)
                    {
                        subsectionlist.Add(filepathlist);
                        if (filepathlist.Count < kvp.Value.Count)
                        {
                            //其中几个不是分段视频
                            logSubSection.Append($"   {Jvedio.Language.Resources.ID} :{kvp.Key}" + Environment.NewLine);
                            removelist.AddRange(notsubsection);
                            logSubSection.Append($"      {Jvedio.Language.Resources.ImportSubSection}: {filepathlist.Count} ,:{string.Join(";", filepathlist)}" + Environment.NewLine);
                            notsubsection.ForEach(arg =>
                            {
                                logSubSection.Append($"      {Jvedio.Language.Resources.NotImport} :{arg}" + Environment.NewLine);
                            });
                        }
                    }
                    else
                    {
                        //TODO
                        logSubSection.Append($"   {Jvedio.Language.Resources.ID}:{kvp.Key}" + Environment.NewLine);
                        (string maxfilepath, List <string> Excludelsist) = ExcludeMaximumSize(kvp.Value);
                        removelist.AddRange(Excludelsist);
                        logSubSection.Append($"      {Jvedio.Language.Resources.ImportFile} :{maxfilepath},{Jvedio.Language.Resources.FileSize} :{new FileInfo(maxfilepath).Length}" + Environment.NewLine);
                        Excludelsist.ForEach(arg =>
                        {
                            logSubSection.Append($"      {Jvedio.Language.Resources.NotImport} :{arg},{Jvedio.Language.Resources.FileSize} :{new FileInfo(arg).Length}" + Environment.NewLine);
                        });
                    }
                }
            }
            Logger.LogScanInfo(Environment.NewLine + $"【 {Jvedio.Language.Resources.RepeatVideo}:{removelist.Count + subsectionlist.Count}】" + Environment.NewLine + logSubSection.ToString());

            List <string> insertList = properIdList.Except(removelist).ToList();//需要导入的视频

            //导入分段视频
            foreach (var item in subsectionlist)
            {
                insertList = insertList.Except(item).ToList();
                ct.ThrowIfCancellationRequested();
                string   subsection = "";
                FileInfo fileinfo   = new FileInfo(item[0]);//获得第一个视频的文件信息
                id = IsEurope ? Identify.GetEuFanhao(fileinfo.Name) : Identify.GetFanhao(fileinfo.Name);
                if (IsEurope)
                {
                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    else
                    {
                        vt = VedioType.欧美;
                    }
                }
                else
                {
                    vt = Identify.GetVideoType(id);
                }
                if (string.IsNullOrEmpty(id) || vt == 0)
                {
                    continue;
                }

                //文件大小视为所有文件之和
                double filesize = 0;
                for (int i = 0; i < item.Count; i++)
                {
                    if (!File.Exists(item[i]))
                    {
                        continue;
                    }
                    FileInfo fi = new FileInfo(item[i]);
                    subsection += item[i] + ";";
                    filesize   += fi.Length;
                }

                //获取创建日期
                //TODO 国际化
                string createDate = "";
                try { createDate = fileinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); }
                catch { }
                if (createDate == "")
                {
                    createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                Movie movie = new Movie()
                {
                    filepath   = item[0],
                    id         = id,
                    filesize   = filesize,
                    vediotype  = (int)vt,
                    subsection = subsection.Substring(0, subsection.Length - 1),
                    otherinfo  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    scandate   = createDate
                };

                DataBase.InsertScanMovie(movie);
                insertCount += 1;
            }

            //导入剩余的所有视频
            foreach (var item in insertList)
            {
                ct.ThrowIfCancellationRequested();
                if (!File.Exists(item))
                {
                    continue;
                }
                FileInfo fileinfo = new FileInfo(item);

                string createDate = "";
                try { createDate = fileinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); }
                catch { }
                if (createDate == "")
                {
                    createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                id = IsEurope ? Identify.GetEuFanhao(fileinfo.Name) : Identify.GetFanhao(fileinfo.Name);
                if (string.IsNullOrEmpty(id))
                {
                    continue;
                }

                if (IsEurope)
                {
                    vt = VedioType.欧美;
                }
                else
                {
                    vt = Identify.GetVideoType(id);
                }

                if (vt == 0)
                {
                    continue;
                }

                Movie movie = new Movie()
                {
                    filepath  = item,
                    id        = id,
                    filesize  = fileinfo.Length,
                    vediotype = (int)vt,
                    otherinfo = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    scandate  = createDate
                };
                DataBase.InsertScanMovie(movie);
                insertCount += 1;
            }

            Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.TotalImport} => {insertCount},{Jvedio.Language.Resources.ImportAttention}" + Environment.NewLine);

            //TODO 从主数据库中复制信息
            //从 主数据库中 复制信息
            //if (Path.GetFileNameWithoutExtension(Properties.Settings.Default.DataBasePath).ToLower() != "info")
            //{
            //    try
            //    {
            //        string src = AppDomain.CurrentDomain.BaseDirectory + "DataBase\\info.sqlite";
            //        string dst = AppDomain.CurrentDomain.BaseDirectory + $"DataBase\\{Path.GetFileNameWithoutExtension(Properties.Settings.Default.DataBasePath).ToLower()}.sqlite"; ;
            //        DataBase.CopyDatabaseInfo(src, dst);
            //    }
            //    catch { }
            //}
            return(insertCount);
        }
예제 #4
0
 public Jav321Parse(string id, string htmlText, VedioType vedioType = 0) : base(htmlText, id, vedioType)
 {
 }
예제 #5
0
 public Fc2ClubParse(string id, string htmlText, VedioType vedioType = 0) : base(htmlText, id, vedioType)
 {
 }
예제 #6
0
 public BusParse(string id, string htmlText, VedioType vedioType) : base(htmlText, id, vedioType)
 {
 }
예제 #7
0
 public LibraryParse(string id, string htmlText, VedioType vedioType = 0) : base(htmlText, id, vedioType)
 {
 }
예제 #8
0
 public InfoParse(string htmlText, string id = "", VedioType vedioType = VedioType.步兵)
 {
     ID        = id;
     HtmlText  = htmlText;
     VedioType = vedioType;
 }