private async void btn_search_Click(object sender, EventArgs e) { TVmazeShowEpData showData = await Util.GetShowEpisodesData(txtbox_show.Text); ShowEpInfo formShowEpInfo = new ShowEpInfo(showData); formShowEpInfo.Show(); }
public ShowEpInfo(TVmazeShowEpData showData) { InitializeComponent(); data = showData; BindShow(); BindEpisode(true); }
public static async Task <Tuple <string, string> > GetLastSeasonAndEpisode(string showName) { TVmazeShowEpData data = await GetShowEpisodesData(showName); var seasonAndEp = data._embedded.episodes .Where(x => x.airstamp < DateTime.Now).OrderByDescending(s => s.airstamp).First(); string season = (seasonAndEp.season < 10 ? 0 + "": "") + seasonAndEp.season; string episode = (seasonAndEp.number < 10 ? 0 + "" : "") + seasonAndEp.number; return(new Tuple <string, string>(season, episode)); }
public static async Task <TVmazeShowEpData> GetShowEpisodesData(string showName) { var client = new HttpClient(); var sb = new StringBuilder(); sb.Append("http://api.tvmaze.com/singlesearch/shows?q="); sb.Append(showName.Trim().Replace(" ", "%20")); sb.Append("&embed=episodes"); var uri = new Uri(sb.ToString()); var response = await client.GetStringAsync(uri); TVmazeShowEpData showData = JsonConvert.DeserializeObject <TVmazeShowEpData>(response); return(showData); }