Пример #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));
            });
        }
Пример #2
0
        private static void RestoreCorrptedFile()
        {
            Dictionary <string, List <SeedMagnetSearchModel> > seeds = new Dictionary <string, List <SeedMagnetSearchModel> >();
            List <string> fileList = new List <string>();
            var           file     = new DirectoryInfo("K:\\Fin").GetFiles();

            Parallel.ForEach(file, new ParallelOptions {
                MaxDegreeOfParallelism = 20
            }, f =>
            {
                Console.WriteLine("处理 " + f.Name);
                var split = f.Name.Split('-');
                if (split.Length >= 3)
                {
                    var searchContent = split[0] + "-" + split[1];

                    seeds.Add(searchContent, MagService.SearchSukebei(searchContent));
                }
            });

            StringBuilder sb = new StringBuilder();

            foreach (var seed in seeds)
            {
                if (seed.Value != null && seed.Value.Count > 0)
                {
                    foreach (var model in seed.Value)
                    {
                        sb.AppendLine(model.MagUrl);
                    }
                }
                else
                {
                    Console.WriteLine(seed.Key + " 没找到磁链接");
                }
            }

            Console.WriteLine(sb.ToString());
        }
Пример #3
0
        private static void UpdateRefreshUi(int jobId = 0)
        {
            Random ran     = new Random();
            int    count   = 1;
            string sukebei = JavINIClass.IniReadValue("Mag", "sukebei");

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

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

                var token = ScanDataBaseManager.GetToken();

                var htmlResult = HtmlManager.GetHtmlContentViaUrl($"http://www.cainqs.com:8087/avapi/EverythingSearch?token={token.Token}&content=" + rm.Id);

                Model.ScanModels.EverythingResult searchResult = new Model.ScanModels.EverythingResult();
                List <MyFileInfo> matchFiles = new List <MyFileInfo>();

                if (htmlResult.Success)
                {
                    searchResult = JsonConvert.DeserializeObject <Model.ScanModels.EverythingResult>(htmlResult.Content);

                    if (searchResult != null && searchResult.results != null)
                    {
                        foreach (var result in searchResult.results)
                        {
                            var temp = new MyFileInfo();

                            if (result.location == "本地")
                            {
                                temp.Length   = long.Parse(result.size);
                                temp.FullName = result.path + "\\" + result.name;
                            }
                            else
                            {
                                temp.Length   = long.Parse(result.size);
                                temp.FullName = "网盘" + long.Parse(result.size);
                            }

                            matchFiles.Add(temp);
                        }
                    }
                }

                List <SeedMagnetSearchModel> list = new List <SeedMagnetSearchModel>();

                if (sukebei == "pro" || sukebei == "si")
                {
                    list = MagService.SearchSukebei(id: rm.Id, web: sukebei);
                }
                else
                {
                    list = MagService.SearchJavBus(rm.Id, null);
                }

                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;

                        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.Write(" 没搜到");
                    entity.SearchStatus = 0;
                }

                Console.WriteLine();
            });
        }
Пример #4
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;
                }
            });
        }