public AudioAssets(RiotVersion version) { Urls = new Dictionary <string, string>(); foreach (var champ in DataDragon.ChampData.Value.data.Values) { var matches = version.GetFiles("en_US/champions/" + champ.id + ".mp3"); var file = matches.Single(); Set("champ_quote", champ.key.ToString(), file.Url.AbsoluteUri); } }
private static string GetMatchDirectory(RiotVersion version, bool includePatch = true) { if (includePatch) { return(Path.Combine(MatchRoot, version.Major, version.Minor, version.Patch)); } else { return(Path.Combine(MatchRoot, version.Major, version.Minor)); } }
/// <summary> /// Process a match. /// </summary> private async Task <MatchDetail> ConsumeMatch(MatchSummary match) { long matchId = match.MatchId; // Try to mark the match as being processed if (!TryLockMatch(matchId)) { // Another thread has already started processing this match, we don't need to do anything return(null); } // Get the disk path and version of the match string matchPath = MatchDirectory.GetMatchPath(match); RiotVersion matchVersion = new RiotVersion(match.MatchVersion); // Check if the match version is older than the current realm version if (!StaticDataStore.Version.IsSamePatch(matchVersion)) { TryUnlockMatch(matchId); return(null); } // Check if the match exists on disk if (MatchDirectory.MatchFileExists(match)) { // Match file loading will handle this TryUnlockMatch(matchId); return(null); } // <TEST> download limiting long count = Interlocked.Read(ref testSynchronizer.Count); Interlocked.Increment(ref testSynchronizer.Count); if (count >= testSynchronizer.Limit) { return(null); } // </TEST> MatchDetail matchData = null; int retriesLeft = 3; while (retriesLeft > 0) { try { // Get the match with full timeline data matchData = api.GetMatch(match.Region, matchId, true); // Verify the match if (matchData == null) { throw new RiotSharpException("Null match: " + matchId); } if (matchData.Timeline == null) { throw new RiotSharpException("Null match timeline: " + matchId); } // Save it to disk MatchDirectory.SaveMatch(matchData); // Success, don't retry anymore retriesLeft = 0; Console.WriteLine(count); } catch (RiotSharpException ex) { if (ex.IsRetryable()) { --retriesLeft; } else { retriesLeft = 0; } // Don't do anything with the exception yet // TODO: log exceptions Console.ForegroundColor = retriesLeft > 0 ? ConsoleColor.Yellow : ConsoleColor.Red; Console.WriteLine("{0}: Match Error ({1} retries left): {2}", count, retriesLeft, ex.Message); Console.ResetColor(); } } // Remove the match from current downloads TryUnlockMatch(matchId); return(matchData); }
/// <summary> /// Process a match. /// </summary> private async Task<MatchDetail> ConsumeMatch(MatchSummary match) { long matchId = match.MatchId; // Try to mark the match as being processed if (!TryLockMatch(matchId)) { // Another thread has already started processing this match, we don't need to do anything return null; } // Get the disk path and version of the match string matchPath = MatchDirectory.GetMatchPath(match); RiotVersion matchVersion = new RiotVersion(match.MatchVersion); // Check if the match version is older than the current realm version if (!StaticDataStore.Version.IsSamePatch(matchVersion)) { TryUnlockMatch(matchId); return null; } // Check if the match exists on disk if (MatchDirectory.MatchFileExists(match)) { // Match file loading will handle this TryUnlockMatch(matchId); return null; } // <TEST> download limiting long count = Interlocked.Read(ref testSynchronizer.Count); Interlocked.Increment(ref testSynchronizer.Count); if (count >= testSynchronizer.Limit) return null; // </TEST> MatchDetail matchData = null; int retriesLeft = 3; while (retriesLeft > 0) { try { // Get the match with full timeline data matchData = api.GetMatch(match.Region, matchId, true); // Verify the match if (matchData == null) throw new RiotSharpException("Null match: " + matchId); if (matchData.Timeline == null) throw new RiotSharpException("Null match timeline: " + matchId); // Save it to disk MatchDirectory.SaveMatch(matchData); // Success, don't retry anymore retriesLeft = 0; Console.WriteLine(count); } catch (RiotSharpException ex) { if (ex.IsRetryable()) --retriesLeft; else retriesLeft = 0; // Don't do anything with the exception yet // TODO: log exceptions Console.ForegroundColor = retriesLeft > 0 ? ConsoleColor.Yellow : ConsoleColor.Red; Console.WriteLine("{0}: Match Error ({1} retries left): {2}", count, retriesLeft, ex.Message); Console.ResetColor(); } } // Remove the match from current downloads TryUnlockMatch(matchId); return matchData; }
private static string GetMatchDirectory(RiotVersion version, bool includePatch = true) { if (includePatch) return Path.Combine(MatchRoot, version.Major, version.Minor, version.Patch); else return Path.Combine(MatchRoot, version.Major, version.Minor); }