private IList <ApiScore> GetPlayerScores(string username, PlayMode gamemode, ScoreSaveConditions configuration)
        {
            Log(username, string.Format(GettingScores, 1));
            var scoresFromCache =
                _scoreCache.FirstOrDefault(s => s.Key.Username == username & s.Key.PlayMode == gamemode).Value;

            if (scoresFromCache != null)
            {
                return(scoresFromCache);
            }

            List <ApiScore>  egibleScores = new List <ApiScore>();
            IList <ApiScore> scores;

            do
            {
                int i        = 1;
                int Cooldown = 20;
                do
                {
                    Log(username, string.Format(GettingScores, i));
                    scores = _osuApi.GetUserBest(username, (PlayMode)gamemode);
                } while (scores == null && i++ < 5);
                if (scores == null)
                {
                    Log(username, string.Format(GettingUserFailed, i, Cooldown));
                    Thread.Sleep(Cooldown * 1000);
                }
            } while (scores == null);

            _scoreCache.Add(new UserModePair(username, gamemode), scores);
            foreach (var s in scores)
            {
                if (configuration.IsEligibleForSaving(s))
                {
                    egibleScores.Add(s);
                }
            }
            return(egibleScores);
        }
        private Collections GetPlayerCollections(string username, string collectionNameSavePattern, int gamemode,
                                                 ScoreSaveConditions configuration)
        {
            _currentUserMissingMapCount = 0;
            var validScores = GetPlayerScores(username, (PlayMode)gamemode, configuration);
            Dictionary <string, Beatmaps> collectionsDict = new Dictionary <string, Beatmaps>();
            var collections = new Collections();

            foreach (var s in validScores)
            {
                if (configuration.IsEligibleForSaving(s))
                {
                    string collectionName = CreateCollectionName(s, username, collectionNameSavePattern);
                    if (collectionsDict.ContainsKey(collectionName))
                    {
                        collectionsDict[collectionName].Add(GetBeatmapFromId(s.BeatmapId, (PlayMode)gamemode));
                    }
                    else
                    {
                        collectionsDict.Add(collectionName, new Beatmaps()
                        {
                            GetBeatmapFromId(s.BeatmapId, (PlayMode)gamemode)
                        });
                    }
                }
            }
            foreach (var c in collectionsDict)
            {
                var collection = new Collection(_mapCacher)
                {
                    Name = c.Key
                };
                foreach (var beatmap in c.Value)
                {
                    collection.AddBeatmap(beatmap);
                }
                collections.Add(collection);
            }
            return(collections);
        }