public async void Search() { ProgressBar.Text = "搜索中..."; ProgressBar.IsVisible = true; SearchBox.IsEnabled = false; LongListSelector.IsEnabled = false; try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://mediaso.xmp.kankan.xunlei.com/search.php?keyword=" + SearchBox.Text + "&hash=" + new Random().Next()); App.ViewModel.SearchResultItems.Clear(); string name_flag_begin = "sname=\""; string name_flag_end = "\","; string id_flag_begin = "imovieid="; string id_flag_end = ","; string type_flag_begin = "Typedesc=\""; string type_flag_end = "\","; int name_index_begin = result.IndexOf(name_flag_begin); while (name_index_begin != -1) { // name int name_index_end = result.IndexOf(name_flag_end, name_index_begin); string name = result.Substring(name_index_begin + name_flag_begin.Length, name_index_end - name_index_begin - name_flag_begin.Length); // id int id_index_begin = result.IndexOf(id_flag_begin, name_index_end); int id_index_end = result.IndexOf(id_flag_end, id_index_begin); string id = result.Substring(id_index_begin + id_flag_begin.Length, id_index_end - id_index_begin - id_flag_begin.Length); // type int type_index_begin = result.IndexOf(type_flag_begin, id_index_end); string type = ""; if (type_index_begin != -1) { int type_index_end = result.IndexOf(type_flag_end, type_index_begin); type = result.Substring(type_index_begin + type_flag_begin.Length, type_index_end - type_index_begin - type_flag_begin.Length); } if (type != "电影") App.ViewModel.SearchResultItems.Add(new ViewModels.SearchResultModel() { Name = name, ID = id, Type = type }); name_index_begin = result.IndexOf(name_flag_begin, id_index_end); } } catch (Exception exception) { MessageBox.Show(exception.Message, "错误", MessageBoxButton.OK); } finally { SearchBox.IsEnabled = true; LongListSelector.IsEnabled = true; ProgressBar.IsVisible = false; ProgressBar.Text = ""; } }
public async Task<bool> GetAnimeDetail(string aid) { try { string url = "http://data.pad.kankan.com/mobile/detail/" + aid[0] + aid[1] + "/" + aid + ".json"; Debug.WriteLine(url); HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync(url); Debug.WriteLine(result); JObject json = JObject.Parse(result); animeDetail.Get(json); return true; } catch { throw; } }
public async Task<bool> SearchAnime(string keyword) { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync(""); return true; } catch { throw; } }
public async Task<bool> GetUpdateSchedule() { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/get_update_schedule?hash=" + new Random().Next()); scheduleList.Clear(); string[] list = result.Split('\n'); for (int i = 0; i < list.Length; ++i) { string[] item = list[i].Split('|'); if (item.Length < 4) continue; Anime anime = new Anime(); anime.date = item[0]; anime.aid = item[1]; anime.name = item[2]; anime.time = item[3]; scheduleList.Add(anime); } for (int i = 0; i < scheduleList.Count; ++i) scheduleList[i].num = i + 1; return true; } catch { throw; } }
public async Task<bool> ChangePsw(string oldPsw, string newPsw) { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/changepw?key=" + key + "&oldpw=" + oldPsw + "&newpw=" + newPsw + "&hash=" + new Random().Next()); ErrorProcessor(result); return true; } catch { throw; } }
public async Task<bool> SetReadEpi(string aid, string epi) { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/epiedit?key=" + key + "&aid=" + aid + "&epi=" + epi + "&hash=" + new Random().Next()); ErrorProcessor(result); return true; } catch { throw; } }
public async Task<bool> DelHighlight(string aid) { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/del_highlight?key=" + key + "&aid=" + aid + "&hash=" + new Random().Next()); ErrorProcessor(result); return true; } catch { throw; } }
public async Task<bool> SetEmailReminderStatus(bool status) { try { HttpEngine httpRequest = new HttpEngine(); string enable; if (status) enable = "1"; else enable = "0"; string result = await httpRequest.GetAsync("http://api2.ricter.info/email_reminder_set?key=" + key + "&enable=" + enable + "&hash=" + new Random().Next()); ErrorProcessor(result); emailReminderStatus = status; return true; } catch { throw; } }
public async Task<bool> GetEmailReminderStatus() { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/email_reminder_get?key=" + key + "&hash=" + new Random().Next()); ErrorProcessor(result); if (result == "0") emailReminderStatus = false; else if (result == "1") emailReminderStatus = true; else ErrorProcessor("ERROR_UNKNOWN"); return true; } catch { throw; } }
public async Task<bool> GetSubscriptionList() { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/get_subscription_list?key=" + key + "&sb=Ricter&hash=" + new Random().Next()); ErrorProcessor(result); subscriptionList.Clear(); updateNumber = 0; string[] list = result.Split('\n'); for (int i = 0; i < list.Length; ++i) { string[] item = list[i].Split('|'); if (item.Length < 6) continue; Anime anime = new Anime(); anime.aid = item[0]; anime.name = item[1]; anime.status = item[2]; anime.epi = item[3]; anime.read = item[4]; anime.highlight = item[5]; subscriptionList.Add(anime); if (anime.highlight != "0") updateNumber++; } /* subscriptionList.Sort((Anime x, Anime y) => { if (x.highlight != "0" && y.highlight == "0") return -1; if (x.highlight == "0" && y.highlight != "0") return 0; if (x.highlight != "0" && y.highlight != "0") { if (x.highlight == "1" && y.highlight == "2") return -1; if (x.highlight == "2" && y.highlight == "1") return 0; } return -1; }); */ for (int i = 0; i < subscriptionList.Count; ++i) subscriptionList[i].num = i + 1; return true; } catch { throw; } }
public async Task<bool> Register(string username, string password) { try { HttpEngine httpRequest = new HttpEngine(); string result = await httpRequest.GetAsync("http://api2.ricter.info/reg?u=" + username + "&p=" + password + "&hash=" + new Random().Next()); ErrorProcessor(result); key = result; return true; } catch { throw; } }