void downloadContent(string tid, string ver) { try { //Download metadata Directory.CreateDirectory(string.Format("{0}/{1}", Directory.GetCurrentDirectory(), tid)); var metaurl = GetMetadataUrl(tid, ver); StatusWrite("Downloading meta NCA..."); DownloadFile(metaurl, string.Format("{0}/{1}", tid, ver)); //Decrypt/parse meta data and download NCAs string meta = string.Format("{0}/{1}/{2}", Directory.GetCurrentDirectory(), tid, ver); if (File.Exists(meta)) { StatusWrite("Parsing meta..."); NCA3 nca3 = new NCA3(meta); CNMT cnmt = new CNMT(new BinaryReader(new MemoryStream(nca3.pfs0.Files[0].RawData))); WriteLine("Title: {0} v{1}\nType: {2}\nMKey: {3}\n", cnmt.TitleId.ToString("X8"), ver, cnmt.Type, nca3.CryptoType.ToString("D2")); foreach (var nca in cnmt.contEntries) { WriteLine("[{0}]\n{1}", nca.Type, nca.NcaId); StatusWrite("Downloading content NCA..."); DownloadFile(string.Format("{0}/c/c/{1}", Settings.GetCdnUrl(), nca.NcaId), string.Format("{0}/{1}", tid, nca.NcaId)); } WriteLine("Done!"); } else { WriteLine("Error retriving meta!"); } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
void downloadContent(string tid, string ver) { //Download metadata Directory.CreateDirectory(string.Format("{0}/{1}", Directory.GetCurrentDirectory(), tid)); var metaurl = GetMetadataUrl(tid, ver); DownloadFile(metaurl, string.Format("{0}/{1}", tid, ver)); //Decrypt/parse meta data and download NCAs string meta = string.Format("{0}/{1}/{2}", Directory.GetCurrentDirectory(), tid, ver); if (File.Exists(meta)) { NCA3 nca3 = new NCA3(meta); CNMT cnmt = new CNMT(new BinaryReader(new MemoryStream(nca3.pfs0.Files[0].RawData))); WriteLine("Title: {0} v{1}\nType: {2}\n", cnmt.TitleId.ToString("X8"), ver, cnmt.Type); Task.Run(() => { foreach (var nca in cnmt.contEntries) { ThreadSafe(() => { WriteLine("[{0}]\n{1}", nca.Type, nca.NcaId); }); DownloadFile(string.Format("{0}/c/c/{1}", Properties.Resources.CDNUrl, nca.NcaId), string.Format("{0}/{1}", tid, nca.NcaId)); } ThreadSafe(() => { WriteLine("Done!"); }); }); } else { WriteLine("Error retriving meta!"); } }