Example #1
0
        private static void UpdateRefreshUi(int jobId = 0)
        {
            Random ran = new Random();

            Parallel.ForEach(models, new ParallelOptions {
                MaxDegreeOfParallelism = 5
            }, rm =>
            {
                RemoteScanMag entity = new RemoteScanMag();
                entity.JobId         = jobId;

                Console.WriteLine("处理 --> " + rm.Name + models.IndexOf(rm) + "/" + models.Count);

                var matchFiles = new EverythingHelper().SearchFile(rm.Id + " | " + rm.Id.Replace("-", ""), EverythingSearchEnum.Video);

                var list = MagService.SearchSukebei(rm.Id);

                if (list != null && list.Count > 0)
                {
                    ScanDataBaseManager.DeleteMagUrlById(rm.Id);

                    if (matchFiles.Count > 0)
                    {
                        entity.SearchStatus = 2;
                        entity.MatchFile    = matchFiles.FirstOrDefault(x => x.Length == matchFiles.Max(y => y.Length)).FullName;
                    }
                    else
                    {
                        entity.SearchStatus = 1;
                    }

                    foreach (var seed in list)
                    {
                        entity.AvId     = rm.Id;
                        entity.AvName   = FileUtility.ReplaceInvalidChar(rm.Name);
                        entity.AvUrl    = rm.Url;
                        entity.MagDate  = seed.Date;
                        entity.MagSize  = seed.Size;
                        entity.MagTitle = FileUtility.ReplaceInvalidChar(seed.Title);
                        entity.MagUrl   = seed.MagUrl;
                        //entity.SearchStatus = 1;

                        ScanDataBaseManager.InsertRemoteScanMag(entity);
                    }
                }
                else
                {
                    Console.WriteLine("没搜到");
                    entity.SearchStatus = 0;
                }

                Thread.Sleep(10 * ran.Next(5));
            });
        }
        private void searchbox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var pattern = searchbox.Text;

            if (pattern.Length > 1)
            {
                var i = EverythingHelper.getFilesByName(pattern);

                listview.ItemsSource = i;
            }
        }
Example #3
0
        private static void UpdateRefreshUi(int jobId = 0)
        {
            Random ran   = new Random();
            int    count = 1;

            Parallel.ForEach(models, new ParallelOptions {
                MaxDegreeOfParallelism = 10
            }, rm =>
            {
                RemoteScanMag entity = new RemoteScanMag();
                entity.JobId         = jobId;

                Console.Write("处理 --> " + rm.Name + " " + count++ + "/" + models.Count);

                var matchFiles = new EverythingHelper().SearchFile("!c:\\ " + rm.Id + " | " + rm.Id.Replace("-", ""), EverythingSearchEnum.Video);

                var list = MagService.SearchSukebei(id: rm.Id, web: "pro");
                //list.AddRange(MagService.SearchSukebei(id: rm.Id, web: "pro"));

                if (list != null && list.Count > 0)
                {
                    if (matchFiles.Count > 0)
                    {
                        var biggestFile     = matchFiles.FirstOrDefault(x => x.Length == matchFiles.Max(y => y.Length));
                        entity.SearchStatus = 2;
                        entity.MatchFile    = biggestFile.FullName;
                    }
                    else
                    {
                        entity.SearchStatus = 1;
                    }

                    foreach (var seed in list)
                    {
                        entity.AvId     = rm.Id;
                        entity.AvName   = FileUtility.ReplaceInvalidChar(rm.Name);
                        entity.AvUrl    = rm.Url;
                        entity.MagDate  = seed.Date;
                        entity.MagSize  = seed.Size;
                        entity.MagTitle = FileUtility.ReplaceInvalidChar(seed.Title);
                        entity.MagUrl   = seed.MagUrl;
                        //entity.SearchStatus = 1;

                        //if (entity.MagSize <= 0)
                        //{
                        //    Console.WriteLine("找种子");

                        //    var ret = MagService.GetTorrentInfo(entity.MagUrl, "http://itorrents.org/torrent/", "G:\\torrent", entity.MagTitle + ".torrent").Result;

                        //    if (ret != null)
                        //    {
                        //        entity.MagSize = ret.Files.Max(x => x.Length);
                        //    }
                        //}

                        try
                        {
                            if (entity.MagTitle.Contains(rm.Id) || entity.MagTitle.Contains(rm.Id.Replace("-", "")))
                            {
                                ScanDataBaseManager.InsertRemoteScanMag(entity);
                            }
                        }
                        catch (Exception ee)
                        {
                            entity.MatchFile    = "";
                            entity.SearchStatus = 1;
                            ScanDataBaseManager.InsertRemoteScanMag(entity);
                        }
                    }
                }
                else
                {
                    Console.WriteLine(" 没搜到");
                    entity.SearchStatus = 0;
                }
            });
        }
Example #4
0
        private static void TestEverything(EverythingSearchEnum type = EverythingSearchEnum.Video)
        {
            var content = "mvsd-029 | mvsd029";

            var res = new EverythingHelper().SearchFile(content, type);
        }
Example #5
0
        public ActionResult ShowMag(ShowMagType type = ShowMagType.All, int jobId = 0)
        {
            var data = ScanDataBaseManager.GetAllMagByJob(jobId).Where(x => !string.IsNullOrEmpty(x.AvId)).GroupBy(x => x.AvId).ToDictionary(x => x.Key, x => x.ToList());
            Dictionary <ShowMagKey, List <RemoteScanMag> > ret = new Dictionary <ShowMagKey, List <RemoteScanMag> >();

            foreach (var d in data)
            {
                if (d.Value.Count > 0)
                {
                    var key = new ShowMagKey();
                    key.Key   = d.Key;
                    key.Type |= ShowMagType.All;

                    //没有已存在文件
                    if (d.Value.FirstOrDefault().SearchStatus == 1)
                    {
                        d.Value.ForEach(x => x.ClassStr = "card bg-primary");
                        key.Type |= ShowMagType.OnlyNotExist;
                    }

                    //有已存在文件
                    if (d.Value.FirstOrDefault().SearchStatus == 2)
                    {
                        d.Value.ForEach(x => x.ClassStr = "card bg-success");
                        key.Type |= ShowMagType.OnlyExist;
                    }

                    if (d.Value.Exists(x => x.MagSize > 0) || (d.Value.Exists(x => x.MagTitle.ToUpper().Contains("HD")) || d.Value.Exists(x => x.MagTitle.ToUpper().Contains("FHD"))))
                    {
                        key.Type |= ShowMagType.HasMagSize;
                    }
                    else
                    {
                        key.Type |= ShowMagType.HasNoMagSize;
                    }

                    if (!string.IsNullOrEmpty(d.Value.FirstOrDefault().MatchFile))
                    {
                        var count = d.Value.Count;

                        //扫描的时候文件在浏览的时候删除或者移动了位置,重新定位
                        if (d.Value.Exists(x => !System.IO.File.Exists(x.MatchFile)))
                        {
                            var newFiles = new EverythingHelper().SearchFile(d.Value.FirstOrDefault().AvId + "-" + d.Value.FirstOrDefault().AvName, Model.Common.EverythingSearchEnum.Video);

                            int i = 0;

                            foreach (var dTemp in d.Value)
                            {
                                if (i < newFiles.Count)
                                {
                                    dTemp.MatchFile = newFiles[i++].FullName;
                                }
                            }

                            count = newFiles.Count;
                        }

                        d.Value.Take(count).ForEach(x => x.MatchFileSize = new FileInfo(x.MatchFile).Length);

                        if (d.Value.Max(x => x.MagSize >= x.MatchFileSize))
                        {
                            key.Type |= ShowMagType.GreaterThenExist;
                        }
                    }
                    else
                    {
                        if (d.Value.Max(x => x.MagSize > 0))
                        {
                            key.Type |= ShowMagType.GreaterThenNotExist;
                        }
                    }

                    if (d.Value.Exists(x => x.MagTitle.Contains(d.Key) || x.MagTitle.Contains(d.Key.Replace("-", ""))))
                    {
                        ret.Add(key, d.Value);
                    }
                }
            }

            ret = ret.Where(x => x.Key.Type.HasFlag(type)).ToDictionary(x => x.Key, x => x.Value);

            ViewData.Add("jobId", jobId);
            ViewData.Add("data", ret);

            return(View());
        }