private void btSave_Click(object sender, EventArgs e)
        {
            var capArtist = LyricUtil.CapatalizeString(_mCurrentArtist);
            var capTitle  = LyricUtil.CapatalizeString(_mCurrentTitle);

            var lyrics = LyricUtil.FixLyrics(tbLyrics.Text);

            CurrentLyricsDatabase[DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)].Lyrics = lyrics;
            DatabaseUtil.SerializeDB(CurrentLyricsDatabase);

            if (SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true))
            {
                TagReaderUtil.WriteLyrics(capArtist, capTitle, lyrics);
            }

            if (CurrentLyricsDatabase.Equals(MyLyricsUtils.LyricsMarkedDB))
            {
                if (SettingManager.GetParamAsBool(SettingManager.MoveLyricFromMarkedDatabase, true))
                {
                    MoveLyricToOtherDatabase();
                }
            }

            var lrc = new SimpleLRC(capArtist, capTitle, lyrics);

            if (lrc.IsValid && _parentMyLyricsSetup.cbUploadLrcAutomatically.Checked)
            {
                LrcFinder.SaveLrcWithGuid(lyrics, _parentMyLyricsSetup.MGuid);
            }

            btSave.Enabled = false;
            treeView.Focus();
        }
        /// <summary>
        /// AddSong with tree parameters adds a lyric to the treeView and the lyric database
        /// </summary>
        /// <param name="artist">artist</param>
        /// <param name="title">title</param>
        /// <param name="lyrics">lyircs</param>
        /// <param name="site">site</param>
        private bool AddSong(string artist, string title, string lyrics, string site)
        {
            var item = new LyricsItem(artist, title, lyrics, site);

            if (DatabaseUtil.IsSongInLyricsDatabase(CurrentLyricsDatabase, artist, title).Equals(DatabaseUtil.LyricNotFound))
            {
                CurrentLyricsDatabase.Add(DatabaseUtil.CorrectKeyFormat(artist, title), item);
                try
                {
                    AddSong(item);
                }
                catch
                {
                    ;
                }
                treeView.Update();
                DatabaseUtil.SerializeDB(CurrentLyricsDatabase);

                if (SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true))
                {
                    TagReaderUtil.WriteLyrics(artist, title, lyrics);
                }

                return(true);
            }
            return(false);
        }
        private void UpdateSong()
        {
            if (lvSearchResults.SelectedItems.Count > 0)
            {
                StopSearch();
                var site  = lvSearchResults.SelectedItems[0].Text;
                var lyric = tbLyrics.Text;

                if (_markedDatabase && _mMoveLyricFromMarkedDatabase)
                {
                    _parent.RemoveSong(_originalArtist, _originalTitle, true);
                    var key = DatabaseUtil.CorrectKeyFormat(_originalArtist, _originalTitle);
                    MyLyricsUtils.LyricsDB[key] = new LyricsItem(_originalArtist, _originalTitle, lyric, site);
                    DatabaseUtil.SerializeLyricDB();
                    _parent.UpdateInfo();
                }
                else if (_markedDatabase)
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsUtils.LyricsMarkedDB, _originalArtist, _originalTitle,
                                                         lyric, site);
                    DatabaseUtil.SerializeDBs();
                    _parent.UpdateInfo();
                    _parent.HighlightSong(_originalArtist, _originalTitle, false);
                }
                else
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsUtils.LyricsDB, _originalArtist, _originalTitle, lyric,
                                                         site);
                    DatabaseUtil.SerializeDBs();
                    _parent.UpdateInfo();
                    _parent.HighlightNextSong(_treeArtistIndex, _treeTitleIndex);
                }

                if (_mAutomaticWriteToMusicTag)
                {
                    TagReaderUtil.WriteLyrics(_originalArtist, _originalTitle, lyric);
                }

                _parent.UpdateLyricDatabaseStats();
            }
        }
Exemple #4
0
        private void LyricFoundMethod(String lyricStrings, String artist, String title, String site, int row)
        {
            foreach (ListViewItem lvi in lvSelectedSongs.Items)
            {
                if (lvi.Text.Equals(artist) && lvi.SubItems[1].Text.Equals(title))
                {
                    if (lvi.SubItems[3].Text.Equals("miss"))
                    {
                        MessageBox.Show("This is an error and should not be able to happen!");
                    }

                    lvi.ImageIndex       = 0;
                    lvi.SubItems[2].Text = "LyricsDB";
                    lvi.SubItems[3].Text = "OK";
                    lvi.EnsureVisible();

                    var capArtist = LyricUtil.CapatalizeString(artist);
                    var capTitle  = LyricUtil.CapatalizeString(title);

                    DatabaseUtil.WriteToLyricsDatabase(MyLyricsUtils.LyricsDB, MyLyricsUtils.LyricsMarkedDB, capArtist, capTitle, lyricStrings, site);
                    DatabaseUtil.SerializeLyricDB();

                    if (!site.Equals("music tag"))
                    {
                        if (SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true))
                        {
                            TagReaderUtil.WriteLyrics(capArtist, capTitle, lyricStrings);
                        }
                    }

                    _mNoOfCurrentlySearches -= 1;
                    ++_mNoOfSearchesCompleted;

                    break;
                }
            }

            //lvSelectedSongs.Update();
        }
Exemple #5
0
        private void LyricFoundMethod(String lyricStrings, String artist, String track, String site, int row)
        {
            _mArtist = artist;
            _mTrack  = track;

            --_mSongsToSearch;
            lbSongsToSearch2.Text = _mSongsToSearch.ToString(CultureInfo.InvariantCulture);

            _mSongsWithLyric += 1;
            _mLyricsFound    += 1;

            IncrementLyricsFoundBySite(site);

            lbSongsWithLyric2.Text = _mSongsWithLyric.ToString(CultureInfo.InvariantCulture);
            lbLyricsFound2.Text    = _mLyricsFound.ToString(CultureInfo.InvariantCulture);

            var capArtist = LyricUtil.CapatalizeString(_mArtist);
            var capTitle  = LyricUtil.CapatalizeString(_mTrack);

            DatabaseUtil.WriteToLyricsDatabase(MyLyricsUtils.LyricsDB, MyLyricsUtils.LyricsMarkedDB, capArtist, capTitle, lyricStrings, site);
            lbMessage.Text = GetLyricsFoundBySite();

            if (!site.Equals("music tag") && _mAutomaticWriteToMusicTag)
            {
                TagReaderUtil.WriteLyrics(capArtist, capTitle, lyricStrings);
            }

            var logText = capArtist + " - " + capTitle + " has a match at " + site;

            lbLastActivity2.Text = logText;

            BatchLogger.Info("HIT!: {0}", logText);

            progressBar.PerformStep();
            Update();
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            var mDB     = MusicDatabase.Instance;
            var counter = 0;

            for (var i = 0; i < _artists.Count; i++)
            {
                if (bw.CancellationPending)
                {
                    return;
                }

                var artist = (string)_artists[i];
                Thread.Sleep(100); // Give the GUI thread some time to update
                bw.ReportProgress(counter, artist);
                try
                {
                    mDB.GetSongsByArtist(artist, ref _songs);

                    foreach (var song in _songs)
                    {
                        var capArtist = LyricUtil.CapatalizeString(song.Artist);
                        var capTitle  = LyricUtil.CapatalizeString(song.Title);

                        if (DatabaseUtil.IsSongInLyricsDatabase(MyLyricsUtils.LyricsDB, capArtist, capTitle).Equals(DatabaseUtil.LyricFound))
                        {
                            var lyric         = MyLyricsUtils.LyricsDB[DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)].Lyrics;
                            var lrcInLyricsDb = new SimpleLRC(capArtist, capTitle, lyric);

                            // If the lyricsDB lyric is LRC always export
                            if (lrcInLyricsDb.IsValid)
                            {
                                if (TagReaderUtil.WriteLyrics(song.FileName, lyric))
                                {
                                    ++counter;
                                }
                                continue;
                            }

                            var tag = TagReader.ReadTag(song.FileName);

                            // If there is a musictag lyric
                            if (tag != null && !tag.Lyrics.Equals(string.Empty))
                            {
                                // if there is no LRC lyric in the tag, then simple export
                                var lrcInTag = new SimpleLRC(capArtist, capTitle, tag.Lyrics);
                                if (!lrcInTag.IsValid)
                                {
                                    if (TagReaderUtil.WriteLyrics(song.FileName, lyric))
                                    {
                                        ++counter;
                                    }
                                }
                            }
                            // Al if no lyric in musictag simple export
                            else
                            {
                                if (TagReaderUtil.WriteLyrics(song.FileName, lyric))
                                {
                                    ++counter;
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    ;
                }
            }
        }