Esempio n. 1
0
        private void trackBar_Scroll(object sender, EventArgs e)
        {
            var lyricsSites = new List <string>();

            switch (trackBar.Value)
            {
            case 0:
                lyricsSites = LyricsSiteFactory.LyricsSitesBySpeed(SiteSpeed.Fast);
                break;

            case 1:
                lyricsSites = LyricsSiteFactory.LyricsSitesBySpeed(SiteSpeed.Medium);
                break;

            case 2:
                lyricsSites = LyricsSiteFactory.LyricsSitesBySpeed(SiteSpeed.Slow);
                break;

            case 3:
                lyricsSites = LyricsSiteFactory.LyricsSitesBySpeed(SiteSpeed.VerySlow);
                break;
            }

            // Update sitesList & Setup
            for (var index = 0; index < sitesList.Items.Count; index++)
            {
                sitesList.SetItemChecked(index, lyricsSites.Contains(sitesList.Items[index].ToString()));
            }
            Setup.GetInstance().UpdateActiveSitesInSetup(sitesList);

            if (sender != null)
            {
                WriteMediaPortalXml(null, null);
            }
        }
Esempio n. 2
0
        private void InitSitesList()
        {
            var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames();

            sitesList.Items.Clear();
            foreach (var site in lyricsSitesNames)
            {
                sitesList.Items.Add(site);
            }
        }
        public void TestLyricsSiteFactory()
        {
            var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames();

            foreach (var lyricsSitesName in lyricsSitesNames)
            {
                Debug.WriteLine("Executing lyrics site " + lyricsSitesName);
                var abstractSite = LyricsSiteFactory.Create(lyricsSitesName, "U2", "With Or Without You", new ManualResetEvent(false), 5000);
                abstractSite.FindLyrics();
                // No assertions
            }
        }
Esempio n. 4
0
        public FindLyric(LyricsLibrary parent, string artist, string title, bool markedDatabase, int treeArtistIndex, int treeTitleIndex)
        {
            InitializeComponent();

            Text = String.Format("Find a lyric for {0} - {1}", artist, title);

            _parent          = parent;
            _markedDatabase  = markedDatabase;
            _treeArtistIndex = treeArtistIndex;
            _treeTitleIndex  = treeTitleIndex;

            // initialize delegates
            MDelegateStringUpdate    = UpdateStringMethod;
            MDelegateStatusUpdate    = UpdateStatusMethod;
            MDelegateLyricFound      = LyricFoundMethod;
            MDelegateLyricNotFound   = LyricNotFoundMethod;
            MDelegateThreadFinished  = ThreadFinishedMethod;
            MDelegateThreadException = ThreadExceptionMethod;

            // initialize events
            _mEventStopThread = new ManualResetEvent(false);

            tbArtist.Text = artist;
            tbTitle.Text  = title;

            _originalArtist = artist;
            _originalTitle  = title;

            var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames();

            singleRunSitesList.Items.Clear();
            foreach (var site in lyricsSitesNames)
            {
                singleRunSitesList.Items.Add(site, SettingManager.GetParamAsBool(SettingManager.SitePrefix + site, false));
            }

            _mAutomaticFetch              = SettingManager.GetParamAsBool(SettingManager.AutomaticFetch, true);
            _mAutomaticUpdate             = SettingManager.GetParamAsBool(SettingManager.AutomaticUpdateWhenFirstFound, false);
            _mMoveLyricFromMarkedDatabase = SettingManager.GetParamAsBool(SettingManager.MoveLyricFromMarkedDatabase, true);
            _mAutomaticWriteToMusicTag    = SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true);

            _mFind    = SettingManager.GetParamAsString(SettingManager.Find, "");
            _mReplace = SettingManager.GetParamAsString(SettingManager.Replace, "");

            _mStrippedPrefixStrings = MediaPortalUtil.GetStrippedPrefixStringArray();

            BeginSearchIfPossible(artist, title);
            ShowDialog();
        }
Esempio n. 5
0
        private void InitSitesList()
        {
            supportedSites.AutoSize = true;

            var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames();

            foreach (var site in lyricsSitesNames)
            {
                supportedSites.Rows.Add();
                var rowIndex = supportedSites.RowCount - 1;
                var row      = supportedSites.Rows[rowIndex];
                row.Cells["Site"].Value = site;
                row.Cells["Url"].Value  = LyricsSiteFactory.GetBaseUrlFromSiteName(site);
            }
            supportedSites.Refresh();
        }
        private void RunSearchForSiteInThread(string lyricsSearchSiteName)
        {
            ThreadStart job = delegate
            {
                var lyricsSearchSite = LyricsSiteFactory.Create(lyricsSearchSiteName, _mArtist, _mTitle, _mEventStopSiteSearches, TimeLimitForSite);
                lyricsSearchSite.FindLyrics();
                if (_mAllowAllToComplete)
                {
                    ValidateSearchOutputForAllowAllToComplete(lyricsSearchSite.Lyric, lyricsSearchSiteName);
                }
                else
                {
                    ValidateSearchOutput(lyricsSearchSite.Lyric, lyricsSearchSiteName);
                }
            };
            var searchThread = new Thread(job);

            searchThread.Start();
        }
Esempio n. 7
0
        private void rdTrackBar_CheckedChanged(object sender, EventArgs e)
        {
            if (rdLyricsMode.Checked)
            {
                trackBar.Enabled  = true;
                sitesList.Enabled = false;

                trackBar_Scroll(null, null);

                cbMusicTagAlwaysCheck.Checked = true;
                cbMusicTagWrite.Checked       = true;

                cbDontSearchSongsInLyricDB.Checked      = true;
                cbDontSearchSongsWithLyricInTag.Checked = true;
            }
            else if (rbUserSelectMode.Checked)
            {
                trackBar.Enabled  = false;
                sitesList.Enabled = true;
            }
            else if (rbLrcMode.Checked)
            {
                trackBar.Enabled = false;

                var lyricsSitesLrc = LyricsSiteFactory.LrcLyricsSiteNames();
                for (var index = 0; index < sitesList.Items.Count; index++)
                {
                    sitesList.SetItemChecked(index, lyricsSitesLrc.Contains(sitesList.Items[index].ToString()));
                }
                sitesList.Enabled = false;
                Setup.GetInstance().ActiveSites = lyricsSitesLrc;

                cbMusicTagAlwaysCheck.Checked = false;
                cbMusicTagWrite.Checked       = true;

                cbDontSearchSongsInLyricDB.Checked      = false;
                cbDontSearchSongsWithLyricInTag.Checked = false;
            }
        }
Esempio n. 8
0
        private void SearchOnline()
        {
            // After the tag search is completed, we now recalculate the number of lyrics to search for during online search
            _mNoOfSearchesToComplete -= _mNoOfSearchesCompleted;
            _mNoOfSearchesCompleted   = 0;
            _mNoOfCurrentlySearches   = 0;

            if (bwOnlineSearch.IsBusy)
            {
                Thread.Sleep(2000);
            }

            var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames();

            _mFind    = SettingManager.GetParamAsString(SettingManager.Find, "");
            _mReplace = SettingManager.GetParamAsString(SettingManager.Replace, "");


            _mStrippedPrefixStrings = MediaPortalUtil.GetStrippedPrefixStringArray();

            _mEventStopThread = new ManualResetEvent(false);

            // If automaticUpdate is set then return after the first positive search
            _lyricsController = new LyricsController(this, _mEventStopThread, lyricsSitesNames.Where(site => SettingManager.GetParamAsBool(SettingManager.SitePrefix + site, false)).ToArray(), false,
                                                     false,
                                                     _mFind, _mReplace);

            _lyricsController.NoOfLyricsToSearch = _mNoOfSearchesToComplete;

            ThreadStart job = delegate { _lyricsController.Run(); };

            _mLyricControllerThread = new Thread(job);
            _mLyricControllerThread.Start();

            _lyricsController.StopSearches = false;

            bwOnlineSearch.RunWorkerAsync();
        }
Esempio n. 9
0
        private void RunSearchForSiteInThread(string lyricsSearchSiteName)
        {
            // Moved the Create out of the Thread, since we sometimes got null returned
            var         lyricsSearchSite = LyricsSiteFactory.Create(lyricsSearchSiteName, _mArtist, _mTitle, _mEventStopSiteSearches, TimeLimitForSite);
            ThreadStart job = delegate
            {
                if (lyricsSearchSite != null)
                {
                    lyricsSearchSite.FindLyrics();
                    if (_mAllowAllToComplete)
                    {
                        ValidateSearchOutputForAllowAllToComplete(lyricsSearchSite.Lyric, lyricsSearchSiteName);
                    }
                    else
                    {
                        ValidateSearchOutput(lyricsSearchSite.Lyric, lyricsSearchSiteName);
                    }
                }
            };
            var searchThread = new Thread(job);

            searchThread.Start();
        }