예제 #1
0
        //public static Regex QualityRegex { get; } = new Regex(@"(?:\.|\s)(?<quality>[0-9]{3,4}p)(?:\.|\s)", RegexOptions.ExplicitCapture);
        //public static Regex NumberingRegex { get; } = new Regex(@"(?:\.|\s)S(?<season>[0-9]{1,2})(?:E)*(?<episode>[0-9]{1,2})*(?:\.|\s)", RegexOptions.ExplicitCapture & RegexOptions.IgnoreCase);
        //public static Regex TraitRegex { get; } = new Regex(@"(?:\.|\s)(?<trait>(BluRay)|(DTS-HD\.MA)|(DTS-HD)|(DTS)|(Atmos)|((?:[A-Z]*)5\.1)|(7\.1)|(AAC)|(WEB-DL)|(REPACK)|(PROPER))+", RegexOptions.ExplicitCapture);
        //public static Regex GroupRegex { get; } = new Regex(@"(?:-)(?<group>\w*)(?:[^\.])*$", RegexOptions.ExplicitCapture);
        //public static Regex NameRegex { get; } = new Regex(@"^(?<name>[\w\-\s\._]+?)([0-9]{4})", RegexOptions.ExplicitCapture);

        //public IndexerResult(string title, string magnet)
        //{
        //    this.Title = title;
        //    this.Magnet = magnet;

        //    if (VideoQuality == VideoQualityLevel.Unknown)
        //    {
        //        switch (QualityRegex.Match(title).Groups["quality"]?.Value)
        //        {
        //            case "720p":
        //                this.VideoQuality = VideoQualityLevel.HD_720p;
        //                break;
        //            case "1080p":
        //                this.VideoQuality = VideoQualityLevel.FHD_1080p;
        //                break;
        //            case "2160p":
        //                this.VideoQuality = VideoQualityLevel.UHD_2160p;
        //                break;
        //        }
        //    }
        //    if (!Season.HasValue && !Episode.HasValue)
        //    {
        //        var matches = NumberingRegex.Match(title);
        //        if (matches.Success)
        //        {
        //            this.Season = matches.Groups["season"].Value.ToInt();
        //            this.Episode = matches.Groups["episode"].Value.ToInt();
        //        }
        //    }
        //    if (Traits == null)
        //    {
        //        var matches = TraitRegex.Match(title);
        //        if (matches.Success)
        //        {
        //            var traits = new List<QualityTrait>();
        //            foreach (var capture in matches.Groups["trait"].Captures)
        //            {
        //                switch (capture)
        //                {
        //                    case "BluRay":
        //                        traits.Add(QualityTrait.BluRay);
        //                        break;
        //                    case "DTS-HD.MA":
        //                        traits.Add(QualityTrait.DTS_HD_MA);
        //                        break;
        //                    case "DTS_HD":
        //                        traits.Add(QualityTrait.DTS_HD);
        //                        break;
        //                    case "DTS":
        //                        traits.Add(QualityTrait.DTS);
        //                        break;
        //                    case "Atmos":
        //                        traits.Add(QualityTrait.Atmos);
        //                        break;
        //                    case "5.1":
        //                        traits.Add(QualityTrait.AC5_1);
        //                        break;
        //                    case "7.1":
        //                        traits.Add(QualityTrait.AC7_1);
        //                        break;
        //                    case "AAC":
        //                        traits.Add(QualityTrait.AAC);
        //                        break;
        //                    case "WEB-DL":
        //                        traits.Add(QualityTrait.WEB_DL);
        //                        break;
        //                    case "PROPER":
        //                        this.IsProper = true;
        //                        break;
        //                    case "REPACK":
        //                        this.IsRepack = true;
        //                        break;
        //                }
        //            }
        //            this.Traits = traits.ToArray();
        //        }
        //        else this.Traits = new QualityTrait[0];
        //    }
        //    if (string.IsNullOrEmpty(Group))
        //    {
        //        this.Group = GroupRegex.Match(title).Groups["group"].Value;
        //    }
        //    if (string.IsNullOrEmpty(Name))
        //    {
        //        this.Name = NameRegex.Match(title).Groups["name"].Value;
        //    }
        //}

        public IndexerResult(IIndexer source, string title, string magnet, int seeds, int peers)
        {
            this.Title        = title;
            this.Magnet       = magnet;
            this.Name         = source.GetName(title);
            this.VideoQuality = source.GetQualityLevel(title);
            this.Traits       = source.GetTraits(title);
            this.Group        = source.GetGroup(title);

            this.Seeds = seeds;
            this.Peers = peers;
        }