private static void DownloadPackageImages() { var titlesPaths = Directory.GetFiles("metadata"); var iconsPaths = Directory.GetFiles("packages"); foreach (var titlesPath in titlesPaths) { var doc = XDocument.Parse(File.ReadAllText(titlesPath)); var url = doc.Document.Descendants("title").First().Descendants().FirstOrDefault(a => a.Name == "package_url"); if (url == null) { continue; } var filename = new FileInfo(titlesPath).Name; var titleId = filename.Split(' ')[0]; if (iconsPaths.Any(a => a.Contains(titleId))) { continue; } var name = filename.Split(new[] { " - " }, StringSplitOptions.None).Last().Trim().Replace(".xml", ".jpg"); using (var client = new CertificateWebClient(Certificate)) { File.WriteAllBytes($"packages\\{titleId} - {name}", client.DownloadData(url.Value)); Console.WriteLine($"Downloaded package image for {name}"); } } }
private static void ListTitlesForCountry(string country, X509Certificate2 certificate) { var titles = JObject.Parse(File.ReadAllText($"titles\\{country}.json"))["contents"]["content"].Where(a => a["title"] != null) .ToArray(); foreach (var id in titles) { string titleId; using (var client = new CertificateWebClient(certificate)) { client.Headers.Add("Accept", "application/json"); var response = client.DownloadString($"https://ninja.ctr.shop.nintendo.net/ninja/ws/titles/id_pair?ns_uid[]={id}"); var json = JObject.Parse(response); titleId = json["title_id_pairs"]["title_id_pair"].First["title_id"].ToString(); } Console.WriteLine($"{id} {titleId}"); File.AppendAllText("ID_Pairs.json", $"\t{id}: \"{titleId}\",\r\n"); } }