private static Dictionary <string, string> DecodeTickets() { Console.Write("Checking Title Keys validity against Nintendo CDN."); ConsoleUtils.PrintColorfulLine(ConsoleColor.Green, " This might take a while..."); ConsoleUtils.PrintColorfulLine( ConsoleColor.Green, "Parsing only Games and Addon DLCs. Ticket count might decrease as we weed out invalid tickets."); Func <string, bool> gameOrDlc = titleId => Nintendo3DSRelease.GetTitleType(titleId) == "Unknown Type" || Nintendo3DSRelease.GetTitleType(titleId) == "Addon DLC" || Nintendo3DSRelease.GetTitleType(titleId) == "3DS Game"; var ticketsDictionary = ParseDecTitleKeysBin(); ticketsDictionary = new SortedDictionary <string, string>( ticketsDictionary.Where(a => gameOrDlc(a.Key)).ToDictionary(a => a.Key, a => a.Value)); var validKeys = new Dictionary <string, string>(); var processedTickets = 0; var totalTickets = ticketsDictionary.Count; foreach (var pair in ticketsDictionary) { var titleId = pair.Key; var titleKey = pair.Value; var valid = CDNUtils.TitleKeyIsValid(titleId, titleKey); if (valid) { validKeys[titleId] = titleKey; const int TitleTypePad = 10; Console.Write('\r' + Nintendo3DSRelease.GetTitleType(titleId).PadRight(TitleTypePad) + pair.Key + ": Valid | "); ConsoleUtils.PrintColorful(ConsoleColor.Green, $"({++processedTickets}/{totalTickets} valid)"); } else { totalTickets--; } } Console.WriteLine(); Console.Write("Found "); ConsoleUtils.PrintColorful(ConsoleColor.Green, ticketsDictionary.Count - totalTickets); Console.WriteLine(" invalid tickets. Searching through databases for the valid ones..."); return(validKeys); }
private static List <Nintendo3DSRelease> LookUpRemainingTitles( List <Nintendo3DSRelease> remainingTitles, int titlePad, int publisherPad) { // the only reason I'm doing this unknownTitles thing is so we don't pollute the console output with them until the end. var result = new List <Nintendo3DSRelease>(); var unknownTitles = new List <Nintendo3DSRelease>(); var countOfUnknownTitles = 0; foreach ( var downloadedTitle in remainingTitles.Select(title => CDNUtils.DownloadTitleData(title.TitleId, title.DecTitleKey)) ) { if (downloadedTitle.Name != "Unknown") { result.Add(downloadedTitle); Console.WriteLine('\r' + TitleInfo(downloadedTitle, titlePad, publisherPad)); } else { Console.Write($"\r{++countOfUnknownTitles} Unknown titles found."); unknownTitles.Add(downloadedTitle); } } Console.WriteLine(); foreach (var unknownTitle in unknownTitles) { Console.WriteLine(TitleInfo(unknownTitle, titlePad, publisherPad)); } result = result.Concat(unknownTitles).ToList(); return(result); }