public static Day GetDay(DateTime date) { Day day = new Day(date); try { string[] langs = { "US", "UK" }; foreach (string lang in langs) { XmlDocument doc = new XmlDocument(); doc.Load(@"http://services.tvrage.com/feeds/fullschedule.php?key=ADban5OxpuWX5NYR2L7h&country=" + lang + "&24_format=1"); XmlNode root = doc.SelectSingleNode("//DAY[@attr='" + date.ToString("yyyy-M-d") + "']"); foreach (XmlNode time in root.SelectNodes("time")) foreach (XmlNode show in time.SelectNodes("show")) { DateTime showtime = DateTime.ParseExact(time.Attributes["attr"].InnerText, "HH:mm", null); DateTime finaldate = new DateTime(date.Year, date.Month, date.Day, showtime.Hour, showtime.Minute, 0); switch (lang) { case "US": finaldate = finaldate.AddHours(6); break; case "UK": finaldate = finaldate.AddHours(1); break; } TvShow s = new TvShow(finaldate, show.Attributes["name"].InnerText); s.Episode = show["ep"].InnerText; s.Sid = show["sid"].InnerText; s.Title = show["title"].InnerText; s.Url = show["link"].InnerText; s.Network = show["network"].InnerText; day.Shows.Add(s); } } day.Shows.Sort(); } catch { } return day; }
public static TvShow[] GetEpisodes(string show, DateTime min, DateTime max) { List<TvShow> shows = new List<TvShow>(); try { if (show != "<fav>") { XmlDocument doc = new XmlDocument(); doc.Load(@"http://services.tvrage.com/feeds/search.php?key=ADban5OxpuWX5NYR2L7h&show=" + show.Replace("&", "and")); XmlNode fshow = doc.SelectSingleNode("//Results/show"); if (fshow != null) { string fshowid = fshow["showid"].InnerText; string fshowname = fshow["name"].InnerText; doc = new XmlDocument(); doc.Load(@"http://services.tvrage.com/feeds/full_show_info.php?key=ADban5OxpuWX5NYR2L7h&sid=" + fshowid); string country = doc.SelectSingleNode("//origin_country").InnerText; string network = doc.SelectSingleNode("//network").InnerText; DateTime time = DateTime.Parse(doc.SelectSingleNode("//airtime").InnerText); foreach (XmlNode sh in doc.SelectNodes("//Show/Episodelist/Season/episode")) { DateTime showtime = DateTime.Parse(sh["airdate"].InnerText); if (min <= showtime && showtime <= max) { showtime = showtime.AddHours(time.Hour); showtime = showtime.AddMinutes(time.Minute); switch (country) { case "US": showtime = showtime.AddHours(6); break; case "UK": showtime = showtime.AddHours(1); break; } TvShow s = new TvShow(showtime, fshowname); s.Episode = sh.ParentNode.Attributes["no"].InnerText + "x" + sh["seasonnum"].InnerText; s.Sid = string.Empty; s.Title = sh["title"].InnerText; s.Url = sh["link"].InnerText; s.Network = network; shows.Add(s); } } shows.Sort(); } } else return GetEpisodes(min, max); } catch { } return shows.Distinct().ToArray(); }
private void AfterLoadShowList(TvShow[] shows) { List<DateTime> dates = new List<DateTime>(); foreach (TvShow show in shows) { LboxShows.Items.Add(show); dates.Add(new DateTime(show.AiredDate.Year, show.AiredDate.Month, show.AiredDate.Day)); } dates.Sort(); SetCalendarAccessibility(true); GboxNetworkShow.Enabled = GboxTimeShow.Enabled = false; bolded = dates.Distinct().ToArray(); WriteLblCopy("Chargement du calendrier terminé.", true); }