private void LoadScrobbleUserSettings() { string currentUID = Convert.ToString(m_database.AddScrobbleUser(_currentScrobbleUser)); ScrobblerOn = (m_database.AddScrobbleUserSettings(currentUID, "iScrobbleDefault", -1) == 1) ? true : false; _maxScrobbledArtistsForSongs = m_database.AddScrobbleUserSettings(currentUID, "iAddArtists", -1); _maxScrobbledSongsPerArtist = m_database.AddScrobbleUserSettings(currentUID, "iAddTracks", -1); _preferCountForTracks = m_database.AddScrobbleUserSettings(currentUID, "iPreferCount", -1); _rememberStartTrack = (m_database.AddScrobbleUserSettings(currentUID, "iRememberStartArtist", -1) == 1) ? true : false; _maxScrobbledArtistsForSongs = (_maxScrobbledArtistsForSongs > 0) ? _maxScrobbledArtistsForSongs : 3; _maxScrobbledSongsPerArtist = (_maxScrobbledSongsPerArtist > 0) ? _maxScrobbledSongsPerArtist : 1; int tmpRMode = m_database.AddScrobbleUserSettings(currentUID, "iOfflineMode", -1); switch (tmpRMode) { case 0: currentOfflineMode = offlineMode.random; break; case 1: currentOfflineMode = offlineMode.timesplayed; break; case 2: currentOfflineMode = offlineMode.favorites; break; default: currentOfflineMode = offlineMode.random; break; } Log.Info("GUIMusicPlayList: Scrobblesettings loaded for {0} - dynamic playlist inserts: {1}", _currentScrobbleUser, Convert.ToString(ScrobblerOn)); }
private List<Song> fetchRandomTracks(offlineMode randomMode_) { int addedSongs = 0; MusicDatabase dbs = MusicDatabase.Instance; List<Song> randomSongList = new List<Song>(_limitRandomListCount); Song randomSong = new Song(); Song lookupSong = new Song(); int loops = 0; // fetch more than needed since there could be double entries while (addedSongs < _limitRandomListCount * 3) { loops++; lookupSong.Clear(); dbs.GetRandomSong(ref lookupSong); randomSong = lookupSong.Clone(); bool found = false; for (int i = 0; i < randomSongList.Count; i++) { if (randomSongList[i].Artist == randomSong.Artist) { found = true; break; } } if (!found) { switch (randomMode_) { case offlineMode.timesplayed: if (randomSong.TimesPlayed == 0) { randomSongList.Add(randomSong); addedSongs++; } break; case offlineMode.favorites: if (randomSong.Favorite) { randomSongList.Add(randomSong); addedSongs++; } break; case offlineMode.random: randomSongList.Add(randomSong); addedSongs++; break; } } // quick check; 3x rlimit times because every pass could try different artists in dbs.GetRandomSong(ref lookupSong); if (loops > 20) { if (randomMode_ == offlineMode.timesplayed) { Log.Debug("AudioScrobblerUtils: Not enough unique unheard tracks for random mode"); } break; } } return randomSongList; }