/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var info = Utils.GetXML("http://api.anidb.net:9001/httpapi?request=anime&client=rstvshowtracker&clientver=2&protover=1&aid=" + id); var show = new TVShow(); try { show.Title = info.Descendants("title").First(t => t.Attributes().First().Value == language).Value; } catch { try { show.Title = info.Descendants("title").First(t => t.Attributes().First().Value == "en").Value; } catch { show.Title = info.GetValue("title"); } } show.Genre = info.Descendants("category").Aggregate(string.Empty, (current, g) => current + (g.GetValue("name") + ", ")).TrimEnd(", ".ToCharArray()); show.Description = info.GetValue("description"); show.Airing = string.IsNullOrWhiteSpace(info.GetValue("enddate")); show.Runtime = info.GetValue("length").ToInteger(); show.TimeZone = "Tokyo Standard Time"; show.Language = language; show.URL = Site + "perl-bin/animedb.pl?show=anime&aid=" + id; show.Episodes = new List<TVShow.Episode>(); show.Cover = info.GetValue("picture"); if (!string.IsNullOrWhiteSpace(show.Cover)) { show.Cover = "http://img7.anidb.net/pics/anime/" + show.Cover; } foreach (var node in info.Descendants("episode")) { try { node.GetValue("epno").ToInteger(); } catch { continue; } var ep = new TVShow.Episode(); ep.Season = 1; ep.Number = node.GetValue("epno").ToInteger(); ep.URL = Site + "perl-bin/animedb.pl?show=ep&eid=" + node.Attribute("id").Value; try { ep.Title = node.Descendants("title").First(t => t.Attributes().First().Value == language).Value; } catch { try { ep.Title = node.Descendants("title").First(t => t.Attributes().First().Value == "en").Value; } catch { ep.Title = node.GetValue("title"); } } DateTime dt; ep.Airdate = DateTime.TryParse(node.GetValue("airdate"), out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } show.Episodes = show.Episodes.OrderBy(e => e.Number).ToList(); if (show.Episodes.Count != 0) { show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString(); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var listing = Utils.GetHTML("http://www.episodeworld.com/show/" + id + "/season=all/" + Languages.List[language].ToLower() + "/episodeguide"); var show = new TVShow(); show.Title = HtmlEntity.DeEntitize(listing.DocumentNode.GetTextValue("//div[@class='orangecorner_content']//h1")); show.Description = HtmlEntity.DeEntitize(listing.DocumentNode.GetTextValue("//table/tr/td[1]/table[1]/tr[@class='centerbox_orange']/td[@class='centerbox_orange']") ?? string.Empty).Trim(); show.Cover = listing.DocumentNode.GetNodeAttributeValue("//table/tr/td[1]/table[1]/tr[@class='centerbox_orange']/td[@class='centerbox_orange_l']//img", "src"); show.Airing = !Regex.IsMatch(listing.DocumentNode.GetTextValue("//div[@class='orangecorner_content']//th[4]") ?? string.Empty, "(Canceled|Ended)"); show.AirTime = "20:00"; show.Language = language; show.URL = "http://www.episodeworld.com/show/" + id + "/season=all/" + Languages.List[language].ToLower() + "/episodeguide"; show.Episodes = new List<TVShow.Episode>(); var runtxt = Regex.Match(listing.DocumentNode.GetTextValue("//td[@class='centerbox_orange']/b[text() = 'Runtime:']/following-sibling::text()[1]") ?? string.Empty, "([0-9]+)"); show.Runtime = runtxt.Success ? int.Parse(runtxt.Groups[1].Value) : 30; var genre = listing.DocumentNode.SelectNodes("//td[@class='centerbox_orange']/a[starts-with(@href, '/browse/')]"); if (genre != null) { foreach (var gen in genre) { show.Genre += gen.InnerText + ", "; } show.Genre = show.Genre.TrimEnd(", ".ToCharArray()); } var network = listing.DocumentNode.GetTextValue("//td[@class='centerbox_orange']/b[text() = 'Premiered on Network:']/following-sibling::text()[1]"); if (!string.IsNullOrWhiteSpace(network)) { show.Network = Regex.Replace(network, @" in .+$", string.Empty); } var nodes = listing.DocumentNode.SelectNodes("//table[@id='list']/tr"); if (nodes == null) { return show; } foreach (var node in nodes) { var episode = Regex.Match(node.GetTextValue("td[2]") ?? string.Empty, "([0-9]{1,2})x([0-9]{1,3})"); if (!episode.Success) { continue; } var ep = new TVShow.Episode(); ep.Season = episode.Groups[1].Value.ToInteger(); ep.Number = episode.Groups[2].Value.ToInteger(); ep.Title = HtmlEntity.DeEntitize(node.GetTextValue("td[3]").Trim()); ep.URL = node.GetNodeAttributeValue("td[3]/a", "href"); if (ep.URL != null) { ep.URL = Site.TrimEnd('/') + ep.URL; } DateTime dt; ep.Airdate = DateTime.TryParse(HtmlEntity.DeEntitize(node.GetTextValue("td[7]") ?? string.Empty).Trim(), out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } if (show.Episodes.Count != 0) { show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString(); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var main = Utils.GetJSON(SignURL("http://app.imdb.com/title/maindetails?tconst=tt" + id)); var show = new TVShow(); show.Title = (string)main["data"]["title"]; show.Description = (string)main["data"]["plot"]["outline"]; show.Cover = (string)main["data"]["image"]["url"]; show.Airing = (string)main["data"]["year_end"] == "????"; show.Runtime = (int)main["data"]["runtime"]["time"] / 60; show.Language = "en"; show.URL = "http://www.imdb.com/title/tt" + id + "/"; show.Episodes = new List<TVShow.Episode>(); foreach (var genre in main["data"]["genres"]) { show.Genre += (string)genre + ", "; } show.Genre = show.Genre.TrimEnd(", ".ToCharArray()); var epdata = Utils.GetJSON(SignURL("http://app.imdb.com/title/episodes?tconst=tt" + id)); foreach (var season in epdata["data"]["seasons"]) { var snr = int.Parse((string)season["token"]); var enr = 0; foreach (var episode in season["list"]) { if (episode["type"] != "tv_episode") continue; var ep = new TVShow.Episode(); ep.Season = snr; ep.Number = ++enr; ep.Title = (string)episode["title"]; ep.URL = "http://www.imdb.com/title/" + (string)episode["tconst"] + "/"; DateTime dt; ep.Airdate = DateTime.TryParseExact((string)episode["release_date"]["normal"] ?? string.Empty, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } } if (show.Episodes.Count != 0) { show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString(); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var info = Utils.GetXML("http://www.thetvdb.com/api/{0}/series/{1}/all/{2}.xml".FormatWith(Key, id, language), timeout: 120000); var show = new TVShow(); show.Title = info.GetValue("SeriesName"); show.Genre = info.GetValue("Genre").Trim('|').Replace("|", ", "); show.Description = info.GetValue("Overview"); show.Airing = !Regex.IsMatch(info.GetValue("Status"), "(Canceled|Ended)"); show.AirTime = info.GetValue("Airs_Time"); show.AirDay = info.GetValue("Airs_DayOfWeek"); show.Network = info.GetValue("Network"); show.Language = language; show.URL = "http://thetvdb.com/?tab=series&id=" + info.GetValue("id"); show.Episodes = new List<TVShow.Episode>(); if (show.Network.StartsWith("BBC") || show.Network.StartsWith("ITV")) { show.TimeZone = "GMT+0"; } show.Cover = info.GetValue("poster"); if (!string.IsNullOrWhiteSpace(show.Cover)) { show.Cover = "http://thetvdb.com/banners/" + show.Cover; } show.Runtime = info.GetValue("Runtime").ToInteger(); show.Runtime = show.Runtime == 30 ? 20 : show.Runtime == 50 || show.Runtime == 60 ? 40 : show.Runtime; foreach (var node in info.Descendants("Episode")) { int sn; if ((sn = node.GetValue("SeasonNumber").ToInteger()) == 0) { continue; } var ep = new TVShow.Episode(); ep.Season = sn; ep.Number = node.GetValue("EpisodeNumber").ToInteger(); ep.Title = node.GetValue("EpisodeName"); ep.Summary = node.GetValue("Overview"); ep.URL = "http://thetvdb.com/?tab=episode&seriesid={0}&seasonid={1}&id={2}".FormatWith(node.GetValue("seriesid"), node.GetValue("seasonid"), node.GetValue("id")); ep.Picture = node.GetValue("filename"); if (!string.IsNullOrWhiteSpace(ep.Picture)) { ep.Picture = "http://thetvdb.com/banners/_cache/" + ep.Picture; } DateTime dt; ep.Airdate = DateTime.TryParse(node.GetValue("FirstAired"), out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var summary = Utils.GetHTML("http://www.tv.com/shows/{0}/".FormatWith(id)); var show = new TVShow(); show.Title = HtmlEntity.DeEntitize(summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:title']", "content")); show.Genre = Regex.Replace(summary.DocumentNode.GetTextValue("//div[contains(@class, 'categories')]") ?? string.Empty, @"\s+", string.Empty).Replace("Categories", string.Empty).Replace(",", ", "); show.Description = HtmlEntity.DeEntitize((summary.DocumentNode.GetTextValue("//div[@class='description']/span") ?? string.Empty).Replace(" ", " ").Replace("moreless", string.Empty).Trim()); show.Cover = summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:image']", "content"); show.Airing = !Regex.IsMatch(summary.DocumentNode.GetTextValue("//ul[@class='stats']/li[2]") ?? string.Empty, "(Canceled|Ended)"); show.Runtime = 30; show.Language = "en"; show.URL = "http://www.tv.com/shows/{0}/".FormatWith(id); show.Episodes = new List<TVShow.Episode>(); var airinfo = summary.DocumentNode.GetTextValue("//div[@class='tagline']"); if (airinfo != null) { airinfo = Regex.Replace(airinfo, @"\s+", " ").Trim(); var airday = Regex.Match(airinfo, @"(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)"); if (airday.Success) { show.AirDay = airday.Groups[1].Value; } var airtime = Regex.Match(airinfo, @"(\d{1,2}:\d{2}(?: (?:AM|PM))?)", RegexOptions.IgnoreCase); if (airtime.Success) { show.AirTime = airtime.Groups[1].Value; } var network = Regex.Match(airinfo, @"on ([^\s$\(]+)"); if (network.Success) { show.Network = network.Groups[1].Value; } } var epurl = "episodes"; var snr = -1; grabSeason: var listing = Utils.GetHTML("http://www.tv.com/shows/{0}/{1}/?expanded=1".FormatWith(id, epurl)); var nodes = listing.DocumentNode.SelectNodes("//li[starts-with(@class, 'episode')]"); if (nodes == null) { show.Episodes.Reverse(); return show; } foreach (var node in nodes) { var season = Regex.Match(node.GetTextValue("../../a[@class='season_name toggle']") ?? "Season " + snr, "Season ([0-9]+)"); var epnr = Regex.Match(node.GetTextValue(".//div[@class='ep_info']") ?? string.Empty, "Episode ([0-9]+)"); if (!season.Success || !epnr.Success) { continue; } var ep = new TVShow.Episode(); ep.Season = season.Groups[1].Value.ToInteger(); ep.Number = epnr.Groups[1].Value.ToInteger(); ep.Title = HtmlEntity.DeEntitize(node.GetTextValue(".//a[@class='title']")); ep.Summary = HtmlEntity.DeEntitize(node.GetTextValue(".//div[@class='description']").Replace(" ", " ").Replace("moreless", string.Empty).Trim()); ep.Picture = node.GetNodeAttributeValue(".//img[@class='thumb']", "src"); ep.URL = node.GetNodeAttributeValue(".//a[@class='title']", "href"); if (!string.IsNullOrWhiteSpace(ep.URL)) { ep.URL = "http://www.tv.com" + ep.URL; } DateTime dt; ep.Airdate = DateTime.TryParseExact(node.GetTextValue(".//div[@class='date']") ?? string.Empty, "M/d/yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } if (show.Episodes.Count != 0 && show.Episodes.Last().Season > 1) { snr = show.Episodes.Last().Season - 1; epurl = "season-" + snr; goto grabSeason; // this is a baaad fix, but this plugin is deprecated now, so it's a temorary one. } show.Episodes.Reverse(); return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> /// <exception cref="Exception">Failed to extract the listing. Maybe the EPGuides.com regex is out of date.</exception> public override TVShow GetData(string id, string language = "en") { var db = _defaultDb; if (id.Contains('\0')) { var tmp = id.Split('\0'); id = tmp[0]; db = tmp[1]; } var listing = Utils.GetURL(id, "list=" + db, autoDetectEncoding: true); var show = new TVShow { AirTime = "20:00", Language = "en", URL = id, Episodes = new List<TVShow.Episode>() }; var mc = _infoRegex.Matches(listing); foreach (Match m in mc) { if (m.Groups["title"].Success) { show.Title = m.Groups["title"].Value; } if (m.Groups["airing"].Success) { show.Airing = true; } if (m.Groups["runtime"].Success) { show.Runtime = m.Groups["runtime"].Value.Trim().ToInteger(); show.Runtime = show.Runtime == 30 ? 20 : show.Runtime == 50 || show.Runtime == 60 ? 40 : show.Runtime; } } var prod = Regex.Match(listing, @"(?<start>_+\s{1,5}_+\s{1,5})(?<length>_+\s{1,5})_+\s{1,5}_+"); listing = Regex.Replace(listing, @"(.{" + prod.Groups["start"].Value.Length + "})(.{" + prod.Groups["length"].Value.Length + "})(.+)", "$1$3"); mc = _guideRegex.Matches(listing); if (mc.Count == 0) { throw new Exception("Failed to extract the listing. Maybe the EPGuides.com regex is out of date."); } foreach (Match m in mc) { var ep = new TVShow.Episode(); ep.Season = m.Groups["season"].Value.Trim().ToInteger(); ep.Number = m.Groups["episode"].Value.Trim().ToInteger(); ep.Title = HtmlEntity.DeEntitize(m.Groups["title"].Value); var dt = DateTime.MinValue; switch (db) { case "tvrage.com": DateTime.TryParseExact(m.Groups["airdate"].Value.Trim(), "dd/MMM/yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); break; case "tv.com": DateTime.TryParseExact(m.Groups["airdate"].Value.Trim(), "d MMM yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); break; } if (dt == DateTime.MinValue && !DateTime.TryParse(m.Groups["airdate"].Value.Trim(), out dt)) { dt = Utils.UnixEpoch; } ep.Airdate = dt; show.Episodes.Add(ep); } if (show.Episodes.Count != 0) { show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString(); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var info = Utils.GetXML("http://services.tvrage.com/myfeeds/showinfo.php?key={0}&sid={1}".FormatWith(Key, id), timeout: 120000); var list = Utils.GetXML("http://services.tvrage.com/myfeeds/episode_list.php?key={0}&sid={1}".FormatWith(Key, id), timeout: 120000); var show = new TVShow(); show.Title = info.GetValue("showname"); show.Genre = info.Descendants("genre").Aggregate(string.Empty, (current, g) => current + (g.Value + ", ")).TrimEnd(", ".ToCharArray()); show.Description = info.GetValue("summary"); show.Cover = info.GetValue("image"); show.Airing = !Regex.IsMatch(info.GetValue("status"), "(Canceled|Ended)"); show.AirTime = info.GetValue("airtime"); show.AirDay = info.GetValue("airday"); show.Network = info.GetValue("network"); show.TimeZone = info.GetValue("timezone"); show.Language = "en"; show.URL = info.GetValue("showlink"); show.Episodes = new List<TVShow.Episode>(); show.Runtime = info.GetValue("runtime").ToInteger(); show.Runtime = show.Runtime == 30 ? 20 : show.Runtime == 50 || show.Runtime == 60 ? 40 : show.Runtime; foreach (var node in list.Descendants("episode")) { int sn; try { sn = node.Parent.Attribute("no").Value.ToInteger(); } catch { continue; } var ep = new TVShow.Episode(); ep.Season = sn; ep.Number = node.GetValue("seasonnum").ToInteger(); ep.Title = node.GetValue("title"); ep.Summary = node.GetValue("summary"); ep.Picture = node.GetValue("screencap"); ep.URL = node.GetValue("link"); DateTime dt; ep.Airdate = DateTime.TryParse(node.GetValue("airdate"), out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } return show; }
/// <summary> /// Extracts the data available in the database. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The preferred language of the data.</param> /// <returns>TV show data.</returns> public override TVShow GetData(string id, string language = "en") { var summary = Utils.GetXML("http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=" + id); var show = new TVShow(); show.Title = GetDescendantItemValue(summary, "info", "type", "Main title"); show.Description = GetDescendantItemValue(summary, "info", "type", "Plot Summary"); show.Cover = GetDescendantItemAttribute(summary, "info", "type", "Picture", "src"); show.Airing = !Regex.IsMatch(GetDescendantItemValue(summary, "info", "type", "Vintage"), " to "); show.AirTime = "20:00"; show.Language = "en"; show.URL = Site + "encyclopedia/anime.php?id=" + id; show.Episodes = new List<TVShow.Episode>(); var runtxt = Regex.Match(GetDescendantItemValue(summary, "info", "type", "Running time"), "([0-9]+)"); show.Runtime = runtxt.Success ? int.Parse(runtxt.Groups[1].Value) : 30; var genre = GetDescendantItemValues(summary, "info", "type", "Genres"); if (genre.Count() != 0) { foreach (var gen in genre) { show.Genre += gen.ToUppercaseFirst() + ", "; } show.Genre = show.Genre.TrimEnd(", ".ToCharArray()); } var listing = Utils.GetHTML(Site + "encyclopedia/anime.php?id=" + id + "&page=25"); var nodes = listing.DocumentNode.SelectNodes("//table[@class='episode-list']/tr"); if (nodes == null) { return show; } foreach (var node in nodes) { var epnr = Regex.Match(node.GetTextValue("td[@class='n'][1]") ?? string.Empty, "([0-9]+)"); if (!epnr.Success) { continue; } var ep = new TVShow.Episode(); ep.Season = 1; ep.Number = epnr.Groups[1].Value.ToInteger(); ep.Title = HtmlEntity.DeEntitize(node.GetTextValue("td[@valign='top'][1]/div[1]").Trim()); ep.URL = show.URL + "&page=25"; DateTime dt; ep.Airdate = DateTime.TryParse(node.GetTextValue("td[@class='d'][1]/div") ?? string.Empty, out dt) ? dt : Utils.UnixEpoch; show.Episodes.Add(ep); } if (show.Episodes.Count != 0) { show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString(); } return show; }