예제 #1
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
            }
        }
예제 #3
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();
        }
예제 #4
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();
        }
예제 #5
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();
        }