//根据 视频后缀文件大小筛选 public static List <string> FirstFilter(List <string> FilePathList, string ID = "") { if (FilePathList == null || FilePathList.Count == 0) { return(new List <string>()); } try { if (ID == "") { return(FilePathList .Where(s => FilePattern.Contains(Path.GetExtension(s).ToLower())) .Where(s => !File.Exists(s) || new FileInfo(s).Length >= MinFileSize). OrderBy(s => s).ToList()); } else { return(FilePathList .Where(s => FilePattern.Contains(Path.GetExtension(s).ToLower())) .Where(s => !File.Exists(s) || new FileInfo(s).Length >= MinFileSize) .Where(s => { try { return Identify.GetFanhao(new FileInfo(s).Name).ToUpper() == ID.ToUpper(); } catch { Logger.LogScanInfo($"错误路径:{s}"); return false; } }) .OrderBy(s => s).ToList()); } } catch (Exception ex) { Logger.LogF(ex); } return(new List <string>()); }
private void SaveInfo(string filepath) { if (vieModel.DetailMovie == null) { return; } if (!string.IsNullOrEmpty(vieModel.DetailMovie.id)) { //视频类型、文件大小、创建时间 vieModel.DetailMovie.filepath = filepath; FileInfo fileInfo = new FileInfo(filepath); string id = Identify.GetFanhao(fileInfo.Name); int vt = (int)Identify.GetVedioType(id); if (vt > 0) { vieModel.DetailMovie.vediotype = vt; } if (File.Exists(filepath)) { vieModel.DetailMovie.filesize = fileInfo.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"); } vieModel.DetailMovie.otherinfo = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); vieModel.DetailMovie.scandate = createDate; } vieModel.SaveModel(); string table = ((Main)Jvedio.GetWindow.Get("Main")).GetCurrentList(); if (string.IsNullOrEmpty(table)) { vieModel.Query(vieModel.id); } else { vieModel.Query(vieModel.id, table); } HandyControl.Controls.Growl.Success("路径、视频类型、文件大小、创建时间、导入时间成功更新!", "EditGrowl"); } else { vieModel.Refresh(filepath); } }
//根据 视频后缀文件大小筛选 public static List <string> FirstFilter(List <string> FilePathList, string ID = "") { if (ID == "") { return(FilePathList .Where(s => SearchPattern.Contains(Path.GetExtension(s).ToLower())) .Where(s => !File.Exists(s) || new FileInfo(s).Length >= MinFileSize).OrderBy(s => s).ToList()); } else { return(FilePathList .Where(s => SearchPattern.Contains(Path.GetExtension(s).ToLower())) .Where(s => !File.Exists(s) || new FileInfo(s).Length >= MinFileSize) .Where(s => Identify.GetFanhao(new FileInfo(s).Name).ToUpper() == ID.ToUpper()) .OrderBy(s => s).ToList()); } }
public static string GetFanhaoFromDMMUrl(string url) { string result = ""; var values = url.Split('/').ToList(); string cid = ""; foreach (var item in values) { if (!string.IsNullOrEmpty(item) && item.IndexOf("cid=") >= 0) { cid = item; break; } } if (cid.IndexOf("cid=") >= 0) { return(Identify.GetFanhao(cid.Replace("cid=", ""))); } return(result); }
public static string GetFanhaoFromDMMUrl(string url) { string result = ""; //https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=apns006dod/?i3_ref=search&i3_ord=1 //https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=mmus032/?i3_ref=search&i3_ord=1 var values = url.Split('/').ToList(); string cid = ""; foreach (var item in values) { if (!string.IsNullOrEmpty(item) && item.IndexOf("cid=") >= 0) { cid = item; break; } } if (cid.IndexOf("cid=") >= 0) { return(Identify.GetFanhao(cid.Replace("cid=", ""))); } return(result); }
/// <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("\n-----【" + DateTime.Now.ToString() + "】-----"); Logger.LogScanInfo($"\n扫描出 => {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 + "\n"; 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}\n"; (string maxfilepath, List <string> Excludelsist) = ExcludeMaximumSize(kvp.Value); removelist.AddRange(Excludelsist); c2 += $" 导入的:{maxfilepath},文件大小:{new FileInfo(maxfilepath).Length}\n"; Excludelsist.ForEach(arg => { c2 += $" 未导入:{arg},文件大小:{new FileInfo(arg).Length}\n"; }); } } else { } } Logger.LogScanInfo($"\n【重复的视频:{removelist.Count + subsectionlist.Count}个】\n" + 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($"\n总计导入 => {totalinsertnum}个\n"); //从 主数据库中 复制信息 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); }
/// <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> 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); 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(Environment.NewLine + $"【{Jvedio.Language.Resources.NotRecognizeNumber} :{unidentifynum}】" + Environment.NewLine + 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> { item }; repeatlist.Add(id, pathlist); } else { repeatlist[id].Add(item); } } } 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, List <string> filepathlist, List <string> notsubsection) = IsSubSection(kvp.Value); if (issubsection) { subsectionlist.Add(filepathlist); if (filepathlist.Count < kvp.Value.Count) { //其中几个不是分段视频 c2 += $" {Jvedio.Language.Resources.ID} :{kvp.Key}" + Environment.NewLine; removelist.AddRange(notsubsection); c2 += $" {Jvedio.Language.Resources.ImportSubSection}: {filepathlist.Count} ,:{string.Join(";",filepathlist)}" + Environment.NewLine; notsubsection.ForEach(arg => { c2 += $" {Jvedio.Language.Resources.NotImport} :{arg}" + Environment.NewLine; }); } } else { c2 += $" {Jvedio.Language.Resources.ID}:{kvp.Key}" + Environment.NewLine; (string maxfilepath, List <string> Excludelsist) = ExcludeMaximumSize(kvp.Value); removelist.AddRange(Excludelsist); c2 += $" {Jvedio.Language.Resources.ImportFile} :{maxfilepath},{Jvedio.Language.Resources.FileSize} :{new FileInfo(maxfilepath).Length}" + Environment.NewLine; Excludelsist.ForEach(arg => { c2 += $" {Jvedio.Language.Resources.NotImport} :{arg},{Jvedio.Language.Resources.FileSize} :{new FileInfo(arg).Length}" + Environment.NewLine; }); } } else { } } Logger.LogScanInfo(Environment.NewLine + $"【 {Jvedio.Language.Resources.RepeatVideo}:{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.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); 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.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 (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, otherinfo = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), scandate = createDate }; DataBase.InsertScanMovie(movie); totalinsertnum += 1; } Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.TotalImport} => {totalinsertnum},{Jvedio.Language.Resources.ImportAttention}" + Environment.NewLine); //从 主数据库中 复制信息 if (Path.GetFileNameWithoutExtension(Properties.Settings.Default.DataBasePath).ToLower() != "info") { try { //待修复 的 bug string src = AppDomain.CurrentDomain.BaseDirectory + "info.sqlite"; string dst = AppDomain.CurrentDomain.BaseDirectory + $"DataBase\\{Path.GetFileNameWithoutExtension(Properties.Settings.Default.DataBasePath).ToLower()}.sqlite";; DataBase.CopyDatabaseInfo(src, dst); } catch { } } return(totalinsertnum); }
/// <summary> /// 给出一组视频路径,返回否是分段视频,并返回分段的视频列表,以及不是分段的视频列表 /// </summary> /// <param name="FilePathList"></param> /// <returns></returns> public static (bool, List <string>, List <string>) IsSubSection(List <string> FilePathList) { if (Identify.GetFanhao(FilePathList[0].ToUpper()) == "FC2-1552855") { Console.WriteLine("123"); } bool result = true; List <string> notSubSection = new List <string>(); string FatherPath = new FileInfo(FilePathList[0]).Directory.FullName; bool IsAllFileSameFP = FilePathList.All(arg => new FileInfo(arg).Directory.FullName == FatherPath); if (!IsAllFileSameFP) { //并不是所有父目录都相同,提取出父目录最多的文件 Dictionary <string, int> fatherpathDic = new Dictionary <string, int>(); FilePathList.ForEach(path => { string fatherPath = new FileInfo(path).Directory.FullName; if (fatherpathDic.ContainsKey(fatherPath)) { fatherpathDic[fatherPath] += 1; } else { fatherpathDic.Add(fatherPath, 1); } }); string maxValueKey = fatherpathDic.FirstOrDefault(x => x.Value == fatherpathDic.Values.Max()).Key; if (!string.IsNullOrEmpty(maxValueKey)) { try { var notsub = fatherpathDic.Where(arg => arg.Key != null && new FileInfo(arg.Key)?.Directory.FullName != maxValueKey).ToList(); notsub.ForEach(arg => notSubSection.Add(arg.Key)); } catch (Exception e) { Logger.LogE(e); } FilePathList = FilePathList.Where(arg => new FileInfo(arg).Directory.FullName == maxValueKey).ToList(); } } //目录都相同,判断是否分段视频的特征 // -1 cd1 _1 fhd1 string regexFeature = ""; foreach (var item in GetSubSectionFeature()) { regexFeature += item + "|"; } regexFeature = "(" + regexFeature.Substring(0, regexFeature.Length - 1) + ")[1-9]{1}"; string MatchesName = ""; foreach (var item in FilePathList) { foreach (var re in Regex.Matches(item, regexFeature)) { MatchesName += re.ToString(); } } for (int i = 1; i <= FilePathList.Count; i++) { result &= MatchesName.IndexOf(i.ToString()) >= 0; } if (!result) { result = true; //数字后面存在 A,B,C…… //XXX-000-A //XXX-000-B regexFeature = ""; foreach (var item in GetSubSectionFeature()) { regexFeature += item + "|"; } regexFeature = "((" + regexFeature.Substring(0, regexFeature.Length - 1) + ")|[0-9]{1,})[a-n]{1}"; MatchesName = ""; foreach (var item in FilePathList) { foreach (var re in Regex.Matches(item, regexFeature, RegexOptions.IgnoreCase)) { MatchesName += re.ToString(); } } MatchesName = MatchesName.ToLower(); string characters = "abcdefghijklmn"; for (int i = 0; i < Math.Min(FilePathList.Count, characters.Length); i++) { result &= MatchesName.IndexOf(characters[i]) >= 0; } } return(result, FilePathList, notSubSection); }
/// <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); }