private static TMD LoadTmd(string id, string key, string outputDir, string titleUrl, string version) { var tmdFile = Path.Combine(outputDir, "tmd"); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(key)) { return(null); } version = int.Parse(version) == 0 ? "" : $".{version}"; if (DownloadTmd(titleUrl + $"tmd{version}", tmdFile) == null) { var url = $"http://ccs.cdn.wup.shop.nintendo.net/ccs/download/{id.ToLower()}/tmd"; DownloadTmd(url, tmdFile); } var file = new FileInfo(tmdFile); if (!file.Exists || file.Length <= 0) { return(null); } return(TMD.Load(tmdFile)); }
private static async Task <TMD> LoadTmd(string id, string key, string outputDir, string titleUrl, string version) { var tmdFile = Path.Combine(outputDir, "tmd"); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(key)) { return(null); } version = int.Parse(version) == 0 ? "" : $".{version}"; if (await DownloadTmd(titleUrl + $"tmd{version}", tmdFile) == null) { var url = $"http://192.99.69.253/?key={key.ToLower()}&title={id.ToLower()}&type=tmd"; await DownloadTmd(url, tmdFile); } var file = new FileInfo(tmdFile); if (!file.Exists || file.Length <= 0) { return(null); } return(TMD.Load(tmdFile)); }
private static TMD DownloadTmd(string url, string saveTo) { var data = DownloadData(url); if (data.Length <= 0) { return(null); } var tmd = TMD.Load(data); if (tmd.TitleVersion > 999) { return(null); } Toolbelt.AppendLog(" - Parsing TMD..."); Toolbelt.AppendLog($" + Title Version: {tmd.TitleVersion}"); Toolbelt.AppendLog($" + {tmd.NumOfContents} Contents"); File.WriteAllBytes(saveTo, data); return(tmd); }