public static bool WindowTitleIsSong(
            string windowTitle,
            SongClassificationInfo songClassificationInfo
            )
        {
            //First check for exempt song names
            if (songClassificationInfo.SongNames.Contains(windowTitle))
            {
                return(true);
            }

            //Then check that the window title was in the correct song format ("artist - name")
            //Ok if there's nothing before or after the separator
            if (!windowTitle.Contains(ArtistAndNameSeparator))
            {
                return(false);
            }

            //Then check for ads that match the correct song format
            if (
                songClassificationInfo.AdNames.Contains(windowTitle) ||
                songClassificationInfo.AdKeywords.Contains(windowTitle)
                )
            {
                return(false);
            }

            //If none of the prior tests matched, it's either a song or the classification info's incomplete
            return(true);
        }
Example #2
0
        /// <summary></summary>
        /// <param name="spotifyProcessManager"></param>
        /// <param name="songClassificationInfo"></param>
        /// <param name="refreshInterval"></param>
        /// <param name="logger"></param>
        /// <param name="maxSongs">
        /// Note: -1 == infinite, and numbers between 0 and 10 inclusive are not allowed
        /// (in order to guarantee current and future internal functionality)
        /// </param>
        public SongTracker(SpotifyProcessManager spotifyProcessManager, SongClassificationInfo songClassificationInfo, int refreshInterval, Logger logger, int maxSongs = -1)
        {
            if (maxSongs >= 0 && maxSongs <= 10)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(maxSongs),
                          maxSongs,
                          "To guarantee correctness of current and any future internal functionality, "
                          + nameof(maxSongs) + " cannot be between 0 and 10 inclusive"
                          );
            }

            this.MaxSongs = maxSongs;

            this._songs = new List <SongInfo>();
            this.Songs  = _songs.AsReadOnly();

            this.SpotifyProcessManager  = spotifyProcessManager;
            this.SongClassificationInfo = songClassificationInfo;

            this.RefreshInterval = refreshInterval;

            this._logger = logger;

            this.State = TrackState.Unused;
        }
        public SpotifySongInfo(string windowTitle, SongClassificationInfo songClassificationInfo)
        {
            this.WindowTitle            = windowTitle;
            this.SongClassificationInfo = songClassificationInfo;

            this.IsSong = WindowTitleIsSong(windowTitle, songClassificationInfo);
            (this.Artist, this.SongName) = ParseWindowTitle(windowTitle);
        }