private void UpdateTagInfo(string mp3File, string mp3MusicRootPath, bool useDirInfo, ref OperationResult op)
        {
            OperationResult _op = new OperationResult();

            try
            {
                bool            badfile = false;
                MP3FileDataType mp3     = BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(mp3File,
                                                                                                     mp3MusicRootPath, ref _op);
                if (!_op.Success)
                {
                    badfile = true;
                }

                if (_op.Success)
                {
                    BCHMP3Utilities.SaveMp3IdInfo(mp3, ref _op);
                }

                if (!_op.Success && !badfile)
                {
                    badfile = true;
                }
            }
            catch (Exception ex)
            {
                _op.AddException(ex);
            }
            op.AddOperationResult(ref _op);
        }
        public List <string> EditMP3Tags(List <string> mp3Files, string mp3MusicRootPath, bool useFileInfo, ref OperationResult op)
        {
            OperationResult _op        = new OperationResult();
            int             cnt        = 0;
            bool            badfile    = false;
            List <string>   badMp3List = new List <string>();

            foreach (string mp3File in mp3Files)
            {
                badfile = false;
                cnt++;
                if (ProgressUpdate != null)
                {
                    ProgressUpdate(cnt);
                }
                try
                {
                    MP3FileDataType mp3 = BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(mp3File,
                                                                                                     mp3MusicRootPath, ref _op);
                    if (!_op.Success)
                    {
                        badMp3List.Add(mp3File);
                        badfile = true;
                    }

                    if (_op.Success)
                    {
                        SaveMp3IdInfo(mp3, ref _op);
                    }

                    if (!_op.Success && !badfile)
                    {
                        badfile = true;
                        badMp3List.Add(mp3File);
                    }
                }
                catch (Exception ex)
                {
                    _op.AddException(ex);
                    if (!badfile)
                    {
                        badfile = true;
                        badMp3List.Add(mp3File);
                    }
                }
            }

            op.AddOperationResult(ref _op);

            return(badMp3List);
        }
Пример #3
0
        private void TestMP3Parcing()
        {
            OperationResult op           = new OperationResult();
            string          fileNamePath = @"H:\Barry Hill\My Music\Music\R&B\Anita Baker\Giving You the Best That I Got\Anita Baker-01--Priceless.mp3";
            string          mscRtDir     = @"H:\Barry Hill\My Music\Music";

            textBox1.Text = fileNamePath;
            MP3FileDataType mp3 = BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(fileNamePath, mscRtDir, ref op);

            Dictionary <string, string> dict = BCHUtilities.GetObjectNamePropDict <MP3FileDataType>(mp3, ref op);

            textBox2.Text       = BCHUtilities.DictionaryToString(dict, ";");
            listBox1.DataSource = dict.Values.ToList <string>();
        }
Пример #4
0
        private void btnGetMusicInfo_Click(object sender, EventArgs e)
        {
            if (!Path.GetExtension(ddtbMp3File.ItemText).ToLower().EndsWith(".mp3"))
            {
                MessageBox.Show("Please enter a valid MP3 file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            if (dddtbGetRootDir.ItemText.Trim().Length < 1)
            {
                MessageBox.Show("You must choose a music root folder!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OperationResult op = new OperationResult();

            string mscRtDir     = dddtbGetRootDir.ItemText;
            string fileNamePath = ddtbMp3File.ItemText;

            try
            {
                MP3FileDataType me = ckbUseDirForInfo.Checked ? BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(fileNamePath, mscRtDir, ref op)
                    : BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmt(fileNamePath, ref op);

                if (!op.Success)
                {
                    MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                tbCalcTrack.Text = me.Track != null?me.Track.ToString() : string.Empty;

                tbCalcTitle.Text   = me.SongTitleAndNumeration ?? string.Empty;
                tbCalcArtists.Text = me.ArtistsStrList ?? string.Empty;
                tbCalcAlbum.Text   = me.Album ?? string.Empty;
                tbcalcComment.Text = me.Comments ?? string.Empty;
                tbCalcGenre.Text   = me.Genre ?? string.Empty;
            }
            catch (Exception ex)
            {
                op.AddException(ex);

                MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #5
0
        public void InsertMP3s(List <string> mp3List, string mp3RtDir, bool useFolderInfo, ref OperationResult op)
        {
            try
            {
                int cnt = 0;

                foreach (string mp3Item in mp3List)
                {
                    cnt++;
                    if (onCountChange != null)
                    {
                        onCountChange(cnt);
                    }

                    OperationResult _op = new OperationResult();
                    MP3FileDataType mp3 = useFolderInfo ?
                                          BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(mp3Item, mp3RtDir, ref _op)
                        : BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmt(mp3Item, ref _op);

                    if (!_op.Success)
                    {
                        op.AddOperationResult(ref _op);
                        continue;
                    }


                    InsertMP3(mp3, ref _op);

                    if (!_op.Success)
                    {
                        op.AddOperationResult(ref _op);
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
            }
        }
Пример #6
0
        private void btnPopWithNameInfo_Click(object sender, EventArgs e)
        {
            OperationResult op = new OperationResult();

            if (!Path.GetExtension(ddtbMp3File.ItemText).ToLower().EndsWith(".mp3"))
            {
                MessageBox.Show("Please enter a valid MP3 file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MP3FileDataType me = ckbUseDirForInfo.Checked ? BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(ddtbMp3File.ItemText,
                                                                                                                       dddtbGetRootDir.ItemText, ref op) : BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmt(ddtbMp3File.ItemText, ref op);

            if (!op.Success)
            {
                MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            tbTrack3v1.Text = me.Track != null?me.Track.ToString() : string.Empty;

            tbTitle3v1.Text   = me.SongTitleAndNumeration ?? string.Empty;
            tbArtist3v1.Text  = me.ArtistsStrList ?? string.Empty;
            tbAlbum3v1.Text   = me.Album ?? string.Empty;
            tbComment3v1.Text = me.Comments ?? string.Empty;
            string genre = me.Genre ?? string.Empty;

            genre = string.IsNullOrEmpty(genre) || !BCHMP3Utilities.GetGenre().Contains(genre.Trim(),
                                                                                        StringComparer.CurrentCultureIgnoreCase) ? "150" : genre;
            cbGenre3v1.Genre = genre;

            tbTrack3v2.Text = me.Track != null?me.Track.ToString() : string.Empty;

            tbTitle3v2.Text   = me.SongTitleAndNumeration ?? string.Empty;
            tbArtist3v2.Text  = me.ArtistsStrList ?? string.Empty;
            tbAlbum3v2.Text   = me.Album ?? string.Empty;
            tbComment3v2.Text = me.Comments ?? string.Empty;
            cbGenre3v2.Genre  = me.Genre ?? string.Empty;
        }
Пример #7
0
        private void InsertMP3s(List <string> mp3List, string mp3RtDir, bool useFolderInfo, ref OperationResult op)
        {
            try
            {
                int cnt = 0;

                foreach (string mp3Item in mp3List)
                {
                    cnt++;
                    SetCount(cnt);

                    OperationResult _op = new OperationResult();
                    MP3FileDataType mp3 = useFolderInfo ?
                                          BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(mp3Item, mp3RtDir, ref _op)
                        : BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmt(mp3Item, ref _op);

                    if (!_op.Success)
                    {
                        op.AddOperationResult(ref _op);
                        return;
                    }

                    _mp3Repository.InsertMp3(mp3, ref op);

                    if (!_op.Success)
                    {
                        op.AddOperationResult(ref _op);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
            }
        }