Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AeonBot
- {
- public class RootObject
- {
- public List<Wowhead> wowhead { get; set; }
- public List<object> hearthstone { get; set; }
- }
- public class Lvjson
- {
- // Comments are bugged with arrays
- // Standard vars
- public int cat { get; set; }
- //public int chrclass { get; set; }
- public int id { get; set; }
- public int level { get; set; }
- public string name { get; set; }
- /*public int reqclass { get; set; }
- public int schools { get; set; }
- public List<int> talentspec { get; set; }
- public int searchpopularity { get; set; }
- public int? nskillup { get; set; }
- public List<int?> skill { get; set; }
- public string rank { get; set; }*/
- // Achievement vars
- public int category { get; set; }
- public string description { get; set; }
- public int parentcat { get; set; }
- public int points { get; set; }
- public int side { get; set; }
- public int type { get; set; }
- // NPC vars
- public int classification { get; set; }
- public string tag { get; set; }
- // Quest vars
- public int category2 { get; set; }
- public List<List<int>> itemchoices { get; set; }
- public int money { get; set; }
- public int reqlevel { get; set; }
- public int xp { get; set; }
- public List<List<int>> reprewards { get; set; }
- // Transmog vars
- public int _note { get; set; }
- public int armorType { get; set; }
- public bool elite { get; set; }
- public bool heroic { get; set; }
- public int maxlevel { get; set; }
- public int minlevel { get; set; }
- public string note { get; set; }
- public List<List<int>> pcbonus { get; set; }
- public List<int> pieces { get; set; }
- public bool raidfinder { get; set; }
- //public int source { get; set; }
- // Faction
- public int expansion { get; set; }
- // Title
- //public int gender { get; set; }
- // Follower
- public List<List<int>> rewards { get; set; }
- public int zone { get; set; }
- // Skill
- public int categorybak { get; set; }
- public int profession { get; set; }
- public int recipeSubclass { get; set; }
- public List<int> specializations { get; set; }
- public string icon { get; set; }
- // Building
- public string levelname { get; set; }
- public string leveldescription { get; set; }
- public string ingame { get; set; }
- public string texturealliance { get; set; }
- public string texturehorde { get; set; }
- public string buildtime { get; set; }
- public string costcurrency { get; set; }
- public string costamount { get; set; }
- public string costcopper { get; set; }
- public string workorders { get; set; }
- public string followerability { get; set; }
- public string firstseendate { get; set; }
- public string firstseenpatch { get; set; }
- public string firstseenbuild { get; set; }
- public string currencyicon { get; set; }
- public string alliance_file { get; set; }
- public string alliance_x1 { get; set; }
- public string alliance_x2 { get; set; }
- public string alliance_y1 { get; set; }
- public string alliance_y2 { get; set; }
- public string horde_file { get; set; }
- public string horde_x1 { get; set; }
- public string horde_x2 { get; set; }
- public string horde_y1 { get; set; }
- public string horde_y2 { get; set; }
- // Hunter Pet
- public int armor { get; set; }
- public int damage { get; set; }
- public int diet { get; set; }
- public int health { get; set; }
- // Race
- public int faction { get; set; }
- public int leader { get; set; }
- // Zone
- public int territory { get; set; }
- // Object
- public List<int> location { get; set; }
- // Event
- public List<string> dates { get; set; }
- public int duration0 { get; set; }
- public string endDate { get; set; }
- public int filtertype { get; set; }
- public string startDate { get; set; }
- // Class
- public int hero { get; set; }
- public int power { get; set; }
- public int races { get; set; }
- public int roles { get; set; }
- public int weapon { get; set; }
- }
- public class Wowhead
- {
- public int type { get; set; }
- public int typeId { get; set; }
- public Lvjson lvjson { get; set; }
- }
- // Spell = 6
- // Item = 3
- // Itemset = 4
- // Achievement = 10
- // Npc = 1
- // Title = 11
- // Follower = 21
- // Skill = 15
- // Quest = 5
- // Pet = 9
- // Race = 14
- // (Legion) Champion = ???
- // Currency = 17
- // Faction = 8
- // Building = 20
- // Zone = 7
- // Object = 2
- // Event = 12
- // Sound = ???
- // Class = 13
- // Resource = 27
- // (dont include) Transmog-set = 101
- public enum Categories
- {
- NPC = 1,
- Object,
- Item,
- Itemset,
- Quest,
- Spell,
- Zone,
- Faction,
- Pet,
- Achievement,
- Title,
- Event,
- Class,
- Race,
- Skill,
- Currency = 17,
- Building = 20,
- Follower,
- Resource = 27,
- Transmogset = 101
- }
- public class WowheadSite
- {
- private string wowheadsite = "http://www.wowhead.com";
- private string wowheadlegionsite = "http://legion.wowhead.com";
- public RootObject Search(string query, bool legion)
- {
- string wowheadSearch = "";
- if (legion)
- wowheadSearch = wowheadlegionsite + "/search?q=";
- else
- wowheadSearch = wowheadsite + "/search?q=";
- JSONHelper json = new JSONHelper();
- string page = json.GetWebsite(wowheadSearch + "" + query);
- if (String.IsNullOrEmpty(page))
- return null;
- string jsonstring = GetJsonString(page);
- if (String.IsNullOrEmpty(jsonstring))
- return null;
- return json.Parse(jsonstring);
- }
- // Example:
- // { 'type': 6, 'typeId': 33763, 'lvjson': {"cat":-12,"chrclass":1024,"id":33763,
- // "level":36,"name":"@Lifebloom","reqclass":1024,"schools":8,"talentspec":[105],searchpopularity:500}}
- private string GetJsonString(string page)
- {
- // From:
- // var popTop10 =
- int top10StartIndex = page.IndexOf("var popTop10 = ");
- //Console.WriteLine("Index: " + top10StartIndex);
- if (top10StartIndex < 0)
- return null;
- // To:
- // };
- int top10LastIndex = page.IndexOf("};", top10StartIndex);
- //Console.WriteLine("Index: " + top10LastIndex);
- if (top10LastIndex < 0)
- return null;
- string jsonstring = page.Substring(top10StartIndex + 15, (top10LastIndex + 2) - (top10StartIndex + 15) - 1);
- //Console.WriteLine("Json: " + jsonstring);
- return jsonstring;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment