コード例 #1
0
        public static TrackData.MP3Error FixMp3File(string fileName, out string strError)
        {
            ValidateOrFixFile(fileName, true);
            strError = "";
            // we might have an error in mp3val. the Log should contain the error
            if (StdOutList.Count == 0)
            {
                return(TrackData.MP3Error.NoError);
            }

            TrackData.MP3Error error = TrackData.MP3Error.NoError;

            // No errors found
            if (StdOutList[0].Contains("Done!"))
            {
                return(TrackData.MP3Error.NoError);
            }

            // This happens, if we fixed an error
            if (StdOutList.Count > 2)
            {
                if (StdOutList[StdOutList.Count - 2].Contains(@"FIXED:"))
                {
                    error = TrackData.MP3Error.Fixed;
                }
            }

            strError = StdOutList[0];
            return(error);
        }
コード例 #2
0
        public static TrackData.MP3Error ValidateMp3File(string fileName, out string strError)
        {
            ValidateOrFixFile(fileName, false);

            strError = "";
            // we might have an error in mp3val. the Log should contain the error
            if (StdOutList.Count == 0)
            {
                return(TrackData.MP3Error.NoError);
            }

            TrackData.MP3Error error = TrackData.MP3Error.NoError;

            // No errors found
            if (StdOutList[0].Contains("Done!"))
            {
                return(TrackData.MP3Error.NoError);
            }
            else if (StdOutList[0].Contains(@"No supported tags in the file"))
            {
                return(TrackData.MP3Error.NoError); // Fixed by MPTagThat :-)
            }
            else if (StdOutList[0].Contains(@"Garbage at the beginning of the file"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "01");
            }
            else if (StdOutList[0].Contains(@"Garbage at the end of the file"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "02");
            }
            else if (StdOutList[0].Contains(@"MPEG stream error, resynchronized successfully"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "03");
            }
            else if (StdOutList[0].Contains(@"This is a RIFF file, not MPEG stream"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "04");
            }
            else if (StdOutList[0].Contains(@"It seems that file is truncated or there is garbage at the end of the file"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "05");
            }
            else if (StdOutList[0].Contains(@"Wrong number of MPEG frames specified in Xing header"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "06");
            }
            else if (StdOutList[0].Contains(@"Wrong number of MPEG data bytes specified in Xing header"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "07");
            }
            else if (StdOutList[0].Contains(@"Wrong number of MPEG frames specified in VBRI header"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "08");
            }
            else if (StdOutList[0].Contains(@"Wrong number of MPEG data bytes specified in VBRI header"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "09");
            }
            else if (StdOutList[0].Contains(@"Wrong CRC in"))
            {
                error    = TrackData.MP3Error.Fixable; // Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "10");
            }
            else if (StdOutList[0].Contains(@"Several APEv2 tags in one file"))
            {
                return(TrackData.MP3Error.NoError); // Handled by MPTagThat
            }
            else if (StdOutList[0].Contains(@"Too few MPEG frames"))
            {
                error    = TrackData.MP3Error.NonFixable; // Non Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "11");
            }
            else if (StdOutList[0].Contains(@"VBR detected, but no VBR header is present. Seeking may not work properly"))
            {
                error    = TrackData.MP3Error.NonFixable; // Non Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "12");
            }
            else if (StdOutList[0].Contains(@"Different MPEG versions or layers in one file"))
            {
                error    = TrackData.MP3Error.NonFixable; // Non Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "13");
            }
            else if (StdOutList[0].Contains(@"Non-layer-III frame encountered"))
            {
                error    = TrackData.MP3Error.NonFixable; // Non Fixable error
                strError = ServiceScope.Get <ILocalisation>().ToString("mp3val", "14");
            }

            if (error == TrackData.MP3Error.Fixable)
            {
                log.Warn("MP3 Validate Fixable error: {0}", StdOutList[0]);
            }
            else if (error == TrackData.MP3Error.NonFixable)
            {
                log.Warn("MP3 Validate Non-Fixable error: {0}", StdOutList[0]);
            }

            // This happens, if we fixed an error
            if (StdOutList.Count > 2)
            {
                if (StdOutList[StdOutList.Count - 2].Contains(@"FIXED:"))
                {
                    error = TrackData.MP3Error.Fixed;
                }
            }

            return(error);
        }