public async Task DoGetAvatarByID() { Console.Clear(); Console.Title = $"VRChatAPIdotNET - {selected}"; Console.WriteLine("Type in the ID of the Avatar:"); string id = Console.ReadLine(); Console.WriteLine(); AvatarRES aRES = await client.Avatars.GetSingle(id); foreach (var prop in aRES.GetType().GetProperties()) { if (prop is IEnumerable) { Console.WriteLine($"--- {prop.Name} start ---"); foreach (object x in (prop as IEnumerable)) { Console.WriteLine(x.ToString()); } Console.WriteLine($"--- {prop.Name} end ---"); } else { Console.WriteLine($"{prop.Name} :: {prop.GetValue(aRES, null)}"); } } Console.WriteLine(); Console.WriteLine("Press any key to return to the Main Menu."); Console.Read(); }
public async Task <AvatarRES> GetSingle(string id) { Universal universal = new Universal(); AvatarRES avatarRES = await universal.GET <AvatarRES>($"avatars/", id, true); Console.WriteLine($"{avatarRES.id}"); Console.WriteLine($"Grabbed Avatar: ' {avatarRES.name} ' made by {avatarRES.authorName}"); Console.WriteLine(); return(avatarRES); }
public async Task MainAsync() { string username; string password; var loginFile = new FileInfo("login.txt"); if (loginFile.Exists) { Console.WriteLine($"Reading login info from {loginFile.Name}"); var lines = File.ReadAllLines(loginFile.FullName); username = lines[0]; password = lines[1]; } else { Console.WriteLine("Username:"******"Password:"******"Is banned"); } if (inErrorState) { await Task.Delay(3000); } } ConfigRES configRES = await client.Config.Get(); if (!inErrorState) { if (!txt_path.Exists || !json_path.Exists) { return; } var txt_avis = txt_path.ReadAllLines().ToList().Where(l => !string.IsNullOrWhiteSpace(l)).Select(l => l.Trim()).ToList(); Console.WriteLine($"Read {txt_avis.Count} avatars from {txt_path.FullName.Quote()}"); var json_avis = JsonConvert.DeserializeObject <List <SavedAvi> >(json_path.ReadAllText()); Console.WriteLine($"Read {json_avis.Count} avatars from {json_path.FullName.Quote()}"); foreach (var avi in txt_avis) { try { var hasAvi = json_avis.Where(a => a.AvatarID == avi).FirstOrDefault(); if (hasAvi is null) { AvatarRES aRES = await client.Avatars.GetSingle(avi); Console.WriteLine(aRES.ToJSON()); json_avis.Add(new SavedAvi() { Name = aRES.name, AvatarID = avi, ThumbnailImageUrl = aRES.thumbnailImageUrl }); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); json_avis.Add(new SavedAvi() { Name = avi, AvatarID = avi, ThumbnailImageUrl = "" }); // Console.ReadLine(); } } json_avis = json_avis.OrderByDescending(a => a.Name).ToList(); var json = JsonConvert.SerializeObject(json_avis, Formatting.Indented); Console.WriteLine(json); Console.ReadKey(); json_path.WriteAllText(json); } }