Ejemplo n.º 1
0
 public Model(Stream stream, string m3uPath, LogEacFormat log) : base(m3uPath)
 {
     base._data = Data = new M3uFormat(this, stream, m3uPath);
     foreach (var track in log.Tracks.Items)
     {
         FilesModel.Add(track.Match.Name);
     }
 }
Ejemplo n.º 2
0
        public void Test_LogEac_StrictWeb()
        {
            var dn = baseDir + @"\Targets\EacLogs\";

            var model = new Diags.Model(dn);

            // Uncomment next line to test hash verification.  Requires the interweb.
            // model.Bind.HashFlags |= Hashes.WebCheck;

            // log1 has self-hash
            var s1 = new FileStream(dn + "Nightmare.log", FileMode.Open);
            var h1 = new byte[0x2C];

            s1.Read(h1, 0, h1.Length);
            var log1Model = LogEacFormat.CreateModel(s1, h1, dn);

            log1Model.CalcHashes(model.Data.HashFlags, 0);
            model.Data.ErrEscalator = IssueTags.ProveErr;
            log1Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b1 = log1Model.Data;

            Assert.IsFalse(b1.Issues.HasError);
            if ((model.Data.HashFlags & Hashes.WebCheck) != 0)
            {
                Assert.IsTrue(b1.ShIssue.Success == true);
            }
            else
            {
                Assert.IsNull(b1.ShIssue);
            }

            // log2 has no self-hash
            var s2 = new FileStream(dn + "EAC1NoHashOrCT.log", FileMode.Open);
            var h2 = new byte[0x2C];

            s2.Read(h2, 0, h1.Length);
            var log2Model = LogEacFormat.CreateModel(s2, h2, dn);

            log2Model.CalcHashes(model.Data.HashFlags, 0);
            model.Data.ErrEscalator = IssueTags.ProveErr | IssueTags.Fussy;
            log2Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b2 = log2Model.Data;

            Assert.IsTrue(b2.Issues.HasError);
            if ((model.Data.HashFlags & Hashes.WebCheck) != 0)
            {
                Assert.IsTrue(b2.ShIssue.Success == false);
            }
            else
            {
                Assert.IsNull(b2.ShIssue);
            }
        }
Ejemplo n.º 3
0
        public void UnitLogEac_Bad1()
        {
            var dName1 = @"Targets\Rips\Tester - 2000 - FLAC Silence Bad1\";
            var fName1 = dName1 + "Tester - 2000 - FLAC Silence Bad1.log";

            LogEacFormat.Model logModel;
            LogEacFormat       log;

            using (Stream fs = new FileStream(fName1, FileMode.Open))
            {
                var hdr = new byte[0x28];
                fs.Read(hdr, 0, hdr.Length);
                logModel = LogEacFormat.CreateModel(fs, hdr, fName1);
                log      = logModel.Data;
            }

            Assert.AreEqual(3, log.Tracks.Items.Count);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                LogEacTrack track = log.Tracks.Items[ix];

                Assert.AreEqual(ix + 1, track.Number);
                Assert.IsTrue(track.HasOk);
                Assert.AreEqual(track.TestCRC, track.CopyCRC);
            }

            var flacs  = new List <FlacFormat>();
            var dInfo1 = new DirectoryInfo(dName1);

            FileInfo[] flacInfos = dInfo1.GetFiles("*.flac");
            foreach (var flacInfo in flacInfos)
            {
                using (Stream fs = new FileStream(flacInfo.FullName, FileMode.Open, FileAccess.Read))
                {
                    var hdr = new byte[0x28];
                    fs.Read(hdr, 0, hdr.Length);
                    var flacModel = FlacFormat.CreateModel(fs, hdr, flacInfo.FullName);

                    Assert.IsNotNull(flacModel);
                    Assert.AreEqual(Severity.Warning, flacModel.Data.Issues.MaxSeverity);

                    flacModel.CalcHashes(Hashes.Intrinsic | Hashes.PcmCRC32, Validations.None);
                    flacs.Add(flacModel.Data);
                }
            }

            logModel.ValidateRip(flacs, checkTags: false);

            Assert.AreEqual(3, flacInfos.Length);
            Assert.AreEqual(3, flacs.Count);
            Assert.AreEqual(Severity.Error, log.Issues.MaxSeverity);
        }
Ejemplo n.º 4
0
        public void UnitLogEac_StrictWeb()
        {
            var fName1 = @"Targets\Singles\Nightmare.log";
            var fName2 = @"Targets\Singles\EAC1NoHashOrCT.log";
            var model  = new KaosDiags.Diags.Model(null);

            // Uncomment next line for EAC log self-hash validation. Requires the interweb!
            // model.Data.HashFlags |= Hashes._WebCheck;

            //log1 has a self-hash
            Stream s1 = new FileStream(fName1, FileMode.Open);
            var    h1 = new byte[0x2C];

            s1.Read(h1, 0, h1.Length);
            var log1Model = LogEacFormat.CreateModel(s1, h1, fName1);

            log1Model.CalcHashes(model.Data.HashFlags, Validations.None);
            model.Data.ErrEscalator = IssueTags.StrictErr;
            log1Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b1 = log1Model.Data;

            Assert.AreEqual(Severity.Error, b1.Issues.MaxSeverity);
            if ((model.Data.HashFlags & Hashes._WebCheck) != 0)
            {
                Assert.IsTrue(b1.ShIssue.Success == true);
            }
            else
            {
                Assert.IsNull(b1.ShIssue);
            }

            // log2 has no self-hash
            Stream s2 = new FileStream(fName2, FileMode.Open);
            var    h2 = new byte[0x2C];

            s2.Read(h2, 0, h1.Length);
            var log2Model = LogEacFormat.CreateModel(s2, h2, fName2);

            log2Model.CalcHashes(model.Data.HashFlags, 0);
            model.Data.ErrEscalator = IssueTags.StrictErr;
            log2Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b2 = log2Model.Data;

            Assert.IsTrue(b2.Issues.HasError);
            if ((model.Data.HashFlags & Hashes._WebCheck) != 0)
            {
                Assert.IsTrue(b2.ShIssue.Success == false);
            }
            else
            {
                Assert.IsNull(b2.ShIssue);
            }
        }
Ejemplo n.º 5
0
        public void Test_LogEac_FlacRip_Bad1()
        {
            LogEacFormat.Model logModel;
            LogEacFormat       log;

            var fn = @"Targets\Rips\Tester - 2000 - FLAC Silence Bad1\Tester - 2000 - FLAC Silence Bad1.log";

            using (var fs = new FileStream(fn, FileMode.Open))
            {
                var hdr = new byte[0x28];
                fs.Read(hdr, 0, hdr.Length);
                logModel = LogEacFormat.CreateModel(fs, hdr, fn);
                log      = logModel.Data;
            }

            Assert.AreEqual(3, log.Tracks.Items.Count);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                LogEacTrack track = log.Tracks.Items[ix];

                Assert.AreEqual(ix + 1, track.Number);
                Assert.IsTrue(track.HasOK);
                Assert.AreEqual(track.TestCRC, track.CopyCRC);
            }

            var dInfo     = new DirectoryInfo(baseDir + "\\Targets\\Rips\\Tester - 2000 - FLAC Silence Bad1");
            var flacInfos = dInfo.GetFiles("*.flac");

            Assert.AreEqual(3, flacInfos.Length);

            var flacMods = new List <FlacFormat.Model>();

            foreach (var flacInfo in flacInfos)
            {
                var ffs = new FileStream(flacInfo.FullName, FileMode.Open, FileAccess.Read);
                var hdr = new byte[0x28];
                ffs.Read(hdr, 0, hdr.Length);

                var flacModel = FlacFormat.CreateModel(ffs, hdr, flacInfo.FullName);
                Assert.IsNotNull(flacModel);

                Assert.IsTrue(flacModel.Data.Issues.MaxSeverity < Severity.Warning);
                flacModel.CalcHashes(Hashes.Intrinsic | Hashes.PcmCRC32, Validations.None);
                flacMods.Add(flacModel);
            }

            Assert.AreEqual(3, flacMods.Count);
            logModel.MatchFlacs(flacMods);

            Assert.IsTrue(log.Issues.MaxSeverity == Severity.Fatal);
        }
Ejemplo n.º 6
0
            public Model(Stream stream, string digPath, LogEacFormat log, IList <Mp3Format.Model> mp3s, string signature) : base(digPath, 16)
            {
                base._data = Data = new Sha1xFormat(this, stream, digPath);
                Data.fbs   = stream;

                CreateHistory();
                HistoryModel.Add("ripped", signature);

                HashedModel.AddActual(log.Name, log.FileSHA1);
                foreach (var mp3Model in mp3s)
                {
                    HashedModel.AddActual(mp3Model.Data.Name, mp3Model.Data.MediaSHA1, HashStyle.Media);
                }
            }
Ejemplo n.º 7
0
            public Model(Stream stream, string md5Path, LogEacFormat log, string logName, M3uFormat m3u, string signature) : base(md5Path, 16)
            {
                base._data = Data = new Md5Format(this, stream, md5Path);
                Data.fbs   = stream;

                CreateHistory();
                HistoryModel.Add("ripped", signature);

                HashedModel.AddActual(m3u.Name, m3u.FileMD5);
                HashedModel.AddActual(logName, log.FileMD5);
                foreach (var track in log.Tracks.Items)
                {
                    HashedModel.AddActual(track.Match.Name, track.Match.FileMD5);
                }
            }
Ejemplo n.º 8
0
        public void Test_LogEac_FlacRip_OK1()
        {
            LogEacFormat.Model logModel;
            LogEacFormat       log;

            var fn = @"Targets\Rips\Tester - 2000 - FLAC Silence OK1\Tester - 2000 - FLAC Silence OK1.log";

            using (var fs = new FileStream(fn, FileMode.Open))
            {
                var hdr = new byte[0x28];
                fs.Read(hdr, 0, hdr.Length);
                logModel = LogEacFormat.CreateModel(fs, hdr, fn);
                log      = logModel.Data;
            }

            Assert.AreEqual(3, log.Tracks.Items.Count);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                LogEacTrack track = log.Tracks.Items[ix];

                Assert.AreEqual(ix + 1, track.Number);
                Assert.IsTrue(track.HasOK);
                Assert.AreEqual(track.TestCRC, track.CopyCRC);
            }

            var dInfo     = new DirectoryInfo(baseDir + @"\Targets\Rips\Tester - 2000 - FLAC Silence OK1");
            var flacInfos = dInfo.GetFiles("*.flac");

            Assert.AreEqual(3, flacInfos.Length);

            var flacMods = new List <FlacFormat.Model>();

            foreach (var flacInfo in flacInfos)
            {
                var ffs = new FileStream(flacInfo.FullName, FileMode.Open, FileAccess.Read);
                var hdr = new byte[0x28];
                ffs.Read(hdr, 0, hdr.Length);

                FlacFormat.Model flacModel = FlacFormat.CreateModel(ffs, hdr, flacInfo.FullName);
                Assert.IsNotNull(flacModel);

                flacModel.CalcHashes(Hashes.Intrinsic | Hashes.PcmCRC32, Validations.None);
                flacMods.Add(flacModel);
            }

            logModel.MatchFlacs(flacMods);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                var track       = log.Tracks.Items[ix];
                var flac        = track.Match;
                var trackNumTag = flac.GetTag("TRACKNUMBER");

                Assert.IsNotNull(flac);
                Assert.AreEqual(1, flac.Issues.Items.Count);
                Assert.AreEqual(Severity.Noise, flac.Issues.MaxSeverity);
                Assert.AreEqual((ix + 1).ToString(), trackNumTag);
                Assert.IsFalse(flac.IsBadHeader);
                Assert.IsFalse(flac.IsBadData);
            }

            Assert.AreEqual(0x6522DF69u, log.Tracks.Items[0].Match.ActualPcmCRC32);
            Assert.AreEqual(0x003E740Du, log.Tracks.Items[1].Match.ActualPcmCRC32);
            Assert.AreEqual(0xFAB5205Fu, log.Tracks.Items[2].Match.ActualPcmCRC32);
        }
Ejemplo n.º 9
0
        public void UnitLogEac_OK1()
        {
            var dName1 = @"Targets\Rips\Tester - 2000 - FLAC Silence OK1\";
            var fName1 = dName1 + "Tester - 2000 - FLAC Silence OK1.log";

            LogEacFormat.Model logModel;
            LogEacFormat       log;

            using (Stream fs = new FileStream(fName1, FileMode.Open))
            {
                var hdr = new byte[0x28];
                fs.Read(hdr, 0, hdr.Length);
                logModel = LogEacFormat.CreateModel(fs, hdr, fName1);
                log      = logModel.Data;
            }

            Assert.AreEqual(3, log.Tracks.Items.Count);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                LogEacTrack track = log.Tracks.Items[ix];

                Assert.AreEqual(ix + 1, track.Number);
                Assert.IsTrue(track.HasOk);
                Assert.AreEqual(track.TestCRC, track.CopyCRC);
            }

            var dInfo     = new DirectoryInfo(dName1);
            var flacInfos = dInfo.GetFiles("*.flac");

            Assert.AreEqual(3, flacInfos.Length);

            var flacs = new List <FlacFormat>();

            foreach (var flacInfo in flacInfos)
            {
                Stream fs  = new FileStream(flacInfo.FullName, FileMode.Open, FileAccess.Read);
                var    hdr = new byte[0x28];
                fs.Read(hdr, 0, hdr.Length);

                FlacFormat.Model flacModel = FlacFormat.CreateModel(fs, hdr, flacInfo.FullName);
                Assert.IsNotNull(flacModel);

                flacModel.CalcHashes(Hashes.Intrinsic | Hashes.PcmCRC32, Validations.None);
                flacs.Add(flacModel.Data);
            }

            logModel.ValidateRip(flacs, checkTags: true);

            for (var ix = 0; ix < log.Tracks.Items.Count; ++ix)
            {
                var track = log.Tracks.Items[ix];
                var flac  = track.Match as FlacFormat;

                Assert.IsNotNull(flac, "Assure flac.exe in PATH.");

                var trackNumTag = flac.GetTagValue("TRACKNUMBER");

                Assert.AreEqual(1, flac.Issues.Items.Count);
                Assert.AreEqual(Severity.Noise, flac.Issues.MaxSeverity);
                Assert.AreEqual((ix + 1).ToString(), trackNumTag);
                Assert.IsFalse(flac.IsBadHeader);
                Assert.IsFalse(flac.IsBadData);
            }

            Assert.AreEqual(0x6522DF69u, ((FlacFormat)log.Tracks.Items[0].Match).ActualPcmCRC32);
            Assert.AreEqual(0x003E740Du, ((FlacFormat)log.Tracks.Items[1].Match).ActualPcmCRC32);
            Assert.AreEqual(0xFAB5205Fu, ((FlacFormat)log.Tracks.Items[2].Match).ActualPcmCRC32);
        }
Ejemplo n.º 10
0
            private void ValidateDirectory()
            {
                Owner.SetCurrentDirectory(Bind.DirPath);
                try
                {
                    Bind.logInfos  = Bind.Dir.GetFiles("*.log").Where(lf => lf.Name.EndsWith(".log")).ToArray();
                    Bind.mp3Infos  = Bind.Dir.GetFiles("*.mp3").Where(lf => lf.Name.EndsWith(".mp3")).ToArray();
                    Bind.digInfos  = Bind.Dir.GetFiles("*.sha1x");
                    Bind.m3uInfos  = Bind.Dir.GetFiles("*.m3u").Where(lf => lf.Name.EndsWith(".m3u")).ToArray();
                    Bind.m3u8Infos = Bind.Dir.GetFiles("*.m3u8");
                    if (!String.IsNullOrEmpty(Owner.Data.Bypass))
                    {
                        Bind.bypassInfos = Bind.Dir.GetFiles("*" + Owner.Data.Bypass);
                    }
                }
                catch (IOException ex)
                {
                    Owner.ReportLine(ex.Message.Trim(null), Severity.Fatal);
                    Bind.Status = Severity.Fatal;
                    return;
                }

                if (Bind.bypassInfos != null && Bind.bypassInfos.Length > 0)
                {
                    Owner.ReportLine($"Ignoring directory containing file ending with '{Owner.Data.Bypass}'.", Severity.Advisory);
                    return;
                }

                if (Bind.logInfos.Length == 0)
                {
                    if (Bind.mp3Infos.Length > 0)
                    {
                        ++Owner.Data.Mp3Format.TrueTotal;
                        ++Owner.Data.TotalFiles;
                        ++Owner.Data.TotalErrors;
                        ++Owner.Data.LogFormat.TotalMissing;
                        Owner.ReportLine("Found .mp3 file(s) without a .log file in same directory.", Severity.Error, Bind.Signature != null);
                        Bind.Status = Severity.Error;
                    }

                    return;
                }

                if (Bind.logInfos.Length > 1)
                {
                    Owner.Data.LogFormat.TrueTotal += Bind.logInfos.Length;
                    Owner.Data.TotalFiles          += Bind.logInfos.Length;
                    Owner.Data.TotalErrors         += Bind.logInfos.Length - 1;
                    Owner.ReportLine("Directory has more than 1 .log file.", Severity.Error, Bind.Signature != null);
                    Bind.Status = Severity.Error;
                    return;
                }

                if (Bind.mp3Infos.Length == 0)
                {
                    ++Owner.Data.LogFormat.TrueTotal;
                    ++Owner.Data.TotalFiles;
                    ++Owner.Data.TotalErrors;
                    ++Owner.Data.Mp3Format.TotalMissing;
                    Owner.ReportLine("Directory has .log file yet has no .mp3 files.", Severity.Error, Bind.Signature != null);
                    Bind.Status = Severity.Error;
                    return;
                }

                Array.Sort(Bind.mp3Infos, (f1, f2) => f1.Name.CompareTo(f2.Name));
                Owner.Data.ExpectedFiles = 1 + Bind.mp3Infos.Length;
                Bind.LogName             = Bind.logInfos[0].Name;

                if (Bind.digInfos.Length == 0)
                {
                    Bind.WorkName = Path.GetFileNameWithoutExtension(Bind.LogName);
                    if (Bind.LogTagEnabled)
                    {
                        if (Bind.WorkName.EndsWith("." + Bind.RipProfile))
                        {
                            Bind.WorkName = Bind.WorkName.Substring(0, Bind.WorkName.Length - 1 - Bind.RipProfile.Length);
                        }
                        Bind.DigName = Bind.WorkName + "." + Bind.RipProfile;
                    }
                    Bind.DigName = ".LAME." + Bind.Signature + ".sha1x";
                    Bind.DigPath = Bind.DirPath + Bind.DigName;
                }
                else
                {
                    ++Owner.Data.ExpectedFiles;
                    var digRE = new Regex(@"(.+)\.LAME\.(.+)\.sha1x");
                    Bind.DigName = Bind.digInfos[0].Name;
                    Bind.DigPath = Bind.digInfos[0].FullName;
                    Owner.SetCurrentFile(Bind.DigName);

                    MatchCollection digMat = digRE.Matches(Bind.DigName);
                    if (digMat.Count != 1)
                    {
                        Bind.WorkName = Path.GetFileNameWithoutExtension(Bind.LogName);
                    }
                    else
                    {
                        Match m1 = digMat[0];
                        if (m1.Groups.Count != 3)
                        {
                            ++Owner.Data.LogFormat.TrueTotal;
                            ++Owner.Data.TotalFiles;
                            Owner.ReportLine("Too confused by digest name, bailing out.", Severity.Error, Bind.Signature != null);
                            Bind.Status = Severity.Error;
                            return;
                        }
                        else
                        {
                            Bind.WorkName = m1.Groups[1].ToString();
                            Bind.Ripper   = m1.Groups[2].ToString();
                        }
                    }
                }

                using (var logfs = new FileStream(Bind.logInfos[0].FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var hdr = new byte[0x26];
                    int got = logfs.Read(hdr, 0, hdr.Length);
                    LogModel = LogEacFormat.CreateModel(logfs, hdr, Bind.logInfos[0].FullName);
                }

                if (LogModel == null)
                {
                    ++Owner.Data.LogFormat.TrueTotal;
                    ++Owner.Data.TotalFiles;
                    Owner.ReportLine("Invalid EAC log file or unknown layout.", Severity.Error, Bind.Signature != null);
                    Bind.Status = Severity.Error;
                    return;
                }

                LogModel.ClearFile();
                Bind.Log = LogModel.Data;

                if (Bind.Ripper == null && (Owner.Data.HashFlags & Hashes.WebCheck) != 0)
                {
                    LogModel.CalcHashWebCheck();
                }

                if (Bind.mp3Infos.Length != Bind.Log.Tracks.Items.Count)
                {
                    var sb = new StringBuilder("Directory has ");
                    sb.Append(Bind.mp3Infos.Length);
                    sb.Append(" MP3");
                    if (Bind.mp3Infos.Length != 1)
                    {
                        sb.Append("s");
                    }
                    sb.Append(", EAC log has ");
                    sb.Append(Bind.Log.Tracks.Items.Count);
                    sb.Append(" track");
                    sb.Append(Bind.Log.Tracks.Items.Count == 1? "." : "s.");
                    LogModel.TkIssue = LogModel.IssueModel.Add(sb.ToString(), Severity.Error, IssueTags.Failure);
                }

                IssueTags errEscalator = Owner.Data.ErrEscalator;

                if (Owner.Data.WillProve && Bind.Ripper == null)
                {
                    errEscalator |= IssueTags.MissingHash;
                }
                LogModel.IssueModel.Escalate(Owner.Data.WarnEscalator, errEscalator);
            }