/// <summary> /// Download Server Time for TheTVDB. /// </summary> /// <returns> /// The current server time. Useful for updates. /// </returns> private static string DownloadServerTime() { var downloadItem = new DownloadItem { Url = "http://cache.thetvdb.com/api/Updates.php?type=none", Type = DownloadType.Html }; var html = new Html(); html.Get(downloadItem); string serverTimeXml = Downloader.ProcessDownload( string.Format(string.Format("http://cache.thetvdb.com/api/Updates.php?type=none")), DownloadType.Html, Section.Tv); var doc = new XmlDocument(); doc.LoadXml(serverTimeXml); var timeValue = XRead.GetString(doc, "Time"); return(timeValue); }
/// <summary> /// Populates the series detail. /// </summary> /// <param name="doc">The xml document</param> public void PopulateSeriesDetail(XmlDocument doc) { this.SeriesID = XRead.GetString(doc, "seriesid"); this.Language = XRead.GetString(doc, "language"); this.SeriesName = XRead.GetString(doc, "SeriesName"); this.Banner = XRead.GetString(doc, "banner"); this.OverView = XRead.GetString(doc, "Overview"); this.FirstAired = XRead.GetDateTime(doc, "FirstAired", "yyyy-MM-dd"); this.Imdbid = XRead.GetString(doc, "IMDB_ID"); this.ID = XRead.GetString(doc, "id"); }
/// <summary> /// Loads the series. /// </summary> /// <param name="series"> /// The series. /// </param> /// <returns> /// Loaded succeeded /// </returns> public bool LoadSeries(Series series) { string seriesName = series.GetSeriesNameOnDisk(); string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesName) || string.IsNullOrEmpty(seriesPath)) { return(false); } string nfo = Find.FindNFO(seriesName, seriesPath); if (string.IsNullOrEmpty(nfo)) { return(false); } XmlDocument doc = XRead.OpenPath(nfo); series.SeriesName = XRead.GetString(doc, "title"); series.SeriesID = XRead.GetUInt(doc, "id"); series.Rating = XRead.GetDouble(doc, "rating"); series.Overview = XRead.GetString(doc, "plot"); series.ContentRating = XRead.GetString(doc, "certification"); series.Genre = XRead.GetStrings(doc, "genre").ToBindingList(); series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd"); series.Network = XRead.GetString(doc, "country"); if (doc.GetElementsByTagName("actor").Count > 0) { series.Actors = new BindingList <PersonModel>(); foreach (XmlNode actor in doc.GetElementsByTagName("actor")) { string xmlActor = actor.InnerXml; XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>"); string name = XRead.GetString(docActor, "name"); string role = XRead.GetString(docActor, "role"); string imageurl = XRead.GetString(docActor, "thumb"); var personModel = new PersonModel(name, role, imageurl); series.Actors.Add(personModel); } } return(true); }
/// <summary> /// Scrapes the release date value /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped release date value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapeReleaseDate(string id, int threadID, out DateTime output, string logCatagory) { output = new DateTime(1700, 1, 1); try { var xmlDoc = XRead.OpenXml(this.GetHtml("main", threadID, id)); output = XRead.GetDateTime(xmlDoc, "releasedate", "yyyy-MM-dd"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the tagline value /// </summary> /// <param name="id">The MovieUniqueId for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped tagline value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns>Scrape succeeded [true/false]</returns> public new bool ScrapeTagline(string id, int threadID, out string output, string logCatagory) { output = string.Empty; try { output = XRead.GetString(XRead.OpenXml(this.GetHtml("getInfo", threadID, id)), "tagline"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Rating value /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Reting value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapeRating(string id, int threadID, out double output, string logCatagory) { output = -1; try { var xmlDoc = XRead.OpenXml(this.GetHtml("main", threadID, id)); output = XRead.GetDouble(xmlDoc, "rating"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Country copllection /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Country collection.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapeCountry(string id, int threadID, out BindingList <string> output, string logCatagory) { output = new BindingList <string>(); try { var xmlDoc = XRead.OpenXml(this.GetHtml("main", threadID, id)); output = XRead.GetStrings(xmlDoc, "country").ToBindingList(); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Plot value /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Plot value.</param> /// <param name="logCatagory">The log catagory.</param> /// <param name="returnShort">if set to <c>true</c> short plot is returned if available.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapePlot(string id, int threadID, out string output, string logCatagory, bool returnShort) { output = string.Empty; try { var xmlDoc = XRead.OpenXml(this.GetHtml("main", threadID, id)); output = XRead.GetString(xmlDoc, "plot"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Year value /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Year value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapeYear(string id, int threadID, out int output, string logCatagory) { output = 0; try { var xml = this.GetHtml("main", threadID, id); output = XRead.GetInt(XRead.OpenXml(xml), "year"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Title value /// </summary> /// <param name="id">The MovieUniqueId for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Title value.</param> /// <param name="alternatives">The alternatives.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns>Scrape succeeded [true/false]</returns> public new bool ScrapeTitle(string id, int threadID, out string output, out BindingList <string> alternatives, string logCatagory) { output = string.Empty; alternatives = new BindingList <string>(); try { var xml = this.GetHtml("main", threadID, id); output = XRead.GetString(XRead.OpenXml(xml), "title"); return(!string.IsNullOrEmpty(output)); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Year value /// </summary> /// <param name="id">The MovieUniqueId for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Year value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns>Scrape succeeded [true/false]</returns> public new bool ScrapeYear(string id, int threadID, out int output, string logCatagory) { output = 0; try { var xml = this.GetHtml("getInfo", threadID, id); var releasedDate = XRead.GetDateTime(XRead.OpenXml(xml), "released"); output = releasedDate.Year; return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Populates the current episode with episodeXml. /// </summary> /// <param name="xml">The XML used to populate the values of the episode object.</param> /// <returns> /// Population sucessful. /// </returns> public bool Populate(string xml) { var doc = new XmlDocument(); doc.LoadXml(xml); string title = XRead.GetString(doc, "EpisodeName"); if (string.IsNullOrEmpty(title)) { return(false); } this.ID = XRead.GetUInt(doc, "Id"); this.CombinedEpisodenumber = XRead.GetDouble(doc, "Combined_episodenumber"); this.CombinedSeason = XRead.GetInt(doc, "Combined_season"); this.DvdChapter = XRead.GetInt(doc, "DVD_chapter"); this.DvdDiscid = XRead.GetInt(doc, "DVD_discid"); this.DvdEpisodenumber = XRead.GetDouble(doc, "DVD_episodenumber"); this.DvdSeason = XRead.GetInt(doc, "DVD_season"); this.Director = XRead.GetString(doc, "Director").ToPersonList('|'); this.EpisodeImgFlag = XRead.GetInt(doc, "EpImgFlag"); this.EpisodeName = title; this.EpisodeNumber = XRead.GetInt(doc, "EpisodeNumber"); this.FirstAired = XRead.GetDateTime(doc, "FirstAired", "yyyy-MM-dd"); this.GuestStars = XRead.GetString(doc, "GuestStars").ToPersonList('|', "http://cache.thetvdb.com/banners/"); this.IMDBID = XRead.GetString(doc, "IMDB_ID"); this.Language = XRead.GetString(doc, "Language"); this.Overview = XRead.GetString(doc, "Overview"); this.ProductionCode = XRead.GetString(doc, "ProductionCode"); this.Rating = XRead.GetDouble(doc, "Rating"); this.SeasonNumber = XRead.GetInt(doc, "SeasonNumber"); this.Writers = XRead.GetString(doc, "Director").ToPersonList('|'); this.AbsoluteNumber = XRead.GetString(doc, "absolute_number"); this.EpisodeScreenshotUrl = XRead.GetString(doc, "filename"); this.Lastupdated = XRead.GetString(doc, "lastupdated"); this.Seasonid = XRead.GetUInt(doc, "seasonid"); this.Seriesid = XRead.GetUInt(doc, "seriesid"); return(true); }
/// <summary> /// Scrapes the Title value /// </summary> /// <param name="id">The MovieUniqueId for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Title value.</param> /// <param name="alternatives">Alternative namings found for a title.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns>Scrape succeeded [true/false]</returns> public new bool ScrapeTitle(string id, int threadID, out string output, out BindingList <string> alternatives, string logCatagory) { output = string.Empty; alternatives = new BindingList <string>(); try { var xml = this.GetHtml("getInfo", threadID, id); var doc = XRead.OpenXml(xml); output = XRead.GetString(doc, "name"); return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Director value /// </summary> /// <param name="id">The Id for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Director value.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns> /// Scrape succeeded [true/false] /// </returns> public new bool ScrapeDirector(string id, int threadID, out BindingList <PersonModel> output, string logCatagory) { output = new BindingList <PersonModel>(); try { var xml = this.GetHtml("main", threadID, id); var xmlDoc = XRead.OpenXml(xml); foreach (var director in XRead.GetStrings(xmlDoc, "director")) { output.Add(new PersonModel(director)); } return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
/// <summary> /// Scrapes the Language collection /// </summary> /// <param name="id">The MovieUniqueId for the scraper.</param> /// <param name="threadID">The thread MovieUniqueId.</param> /// <param name="output">The scraped Language collection.</param> /// <param name="logCatagory">The log catagory.</param> /// <returns>Scrape succeeded [true/false]</returns> public new bool ScrapeLanguage(string id, int threadID, out BindingList <string> output, string logCatagory) { output = new BindingList <string>(); try { output = new BindingList <string>(); var languageCode = XRead.GetString(XRead.OpenXml(this.GetHtml("getInfo", threadID, id)), "certification"); if (!string.IsNullOrEmpty(languageCode)) { output.Add(languageCode); } return(output.IsFilled()); } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message); return(false); } }
public static List <ExportTemplate> GetExportTemplates(string type = "") { var tempInfo = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "Templates"), "template.xml", SearchOption.AllDirectories); var templates = new List <ExportTemplate>(); foreach (var file in tempInfo) { XmlDocument xmlReader = XRead.OpenPath(file); if (xmlReader == null) { XtraMessageBox.Show( string.Format( "The template configuration file '{0}' is invalid!", Path.GetFileName(file) ), "Invalid Export Template" ); } var templateName = XRead.GetString(xmlReader, "name", 1); try { var author = new ExportTemplate.Author(); var xmlAuthor = xmlReader.GetElementsByTagName("author")[0].InnerXml; XmlDocument temp = XRead.OpenXml("<x>" + xmlAuthor + "</x>"); if (type != "") { if (XRead.GetString(xmlReader, "type") != type) { continue; } } templates.Add(new ExportTemplate { name = templateName, date = XRead.GetString(xmlReader, "date"), file = Path.Combine(Path.GetDirectoryName(file), XRead.GetString(xmlReader, "templatefile")), description = XRead.GetString(xmlReader, "description"), outputformat = XRead.GetString(xmlReader, "outputformat"), type = XRead.GetString(xmlReader, "type"), author = new ExportTemplate.Author { name = XRead.GetString(temp, "name"), website = XRead.GetString(temp, "website"), email = XRead.GetString(temp, "email") } }); } catch (Exception e) { if (e is XmlException || e is InvalidOperationException) { XtraMessageBox.Show( string.Format( "The template '{0}' is invalid!", templateName ), "Invalid Export Template" ); } else { throw e; } } } return(templates); }
/// <summary> /// Loads the movie. /// </summary> /// <param name="movieModel"> /// The movie model. /// </param> public void LoadMovie(MovieModel movieModel) { XmlDocument xmlReader = XRead.OpenPath(movieModel.NfoPathOnDisk); if (xmlReader == null) { return; } // Ids XmlNodeList ids = xmlReader.GetElementsByTagName("id"); foreach (XmlElement id in ids) { if (id.Attributes["moviedb"] == null) { movieModel.ImdbId = id.InnerXml.Replace("tt", string.Empty); } else { switch (id.Attributes["moviedb"].Value) { case "tmdb": movieModel.TmdbId = id.InnerXml; break; } } } // Title movieModel.Title = XRead.GetString(xmlReader, "title"); // Year movieModel.Year = XRead.GetInt(xmlReader, "year"); // Release Date movieModel.ReleaseDate = XRead.GetDateTime(xmlReader, "releasedate"); // Rating movieModel.Rating = XRead.GetDouble(xmlReader, "rating"); // Votes movieModel.Votes = XRead.GetInt(xmlReader, "votes"); // Plot movieModel.Plot = XRead.GetString(xmlReader, "plot"); // Outline movieModel.Outline = XRead.GetString(xmlReader, "outline"); // Tagline movieModel.Tagline = XRead.GetString(xmlReader, "tagline"); // Runtime string check = XRead.GetString(xmlReader, "runtime"); if (check.Contains("m")) { movieModel.RuntimeInHourMin = check; } else { movieModel.Runtime = XRead.GetInt(xmlReader, "runtime"); } // Mpaa movieModel.Mpaa = XRead.GetString(xmlReader, "mpaa"); // Certification movieModel.Certification = XRead.GetString(xmlReader, "certification"); // Company movieModel.SetStudio = XRead.GetString(xmlReader, "company"); if (movieModel.SetStudio == string.Empty) { movieModel.SetStudio = XRead.GetString(xmlReader, "studio"); } // Genre string genreList = XRead.GetString(xmlReader, "genre"); movieModel.GenreAsString = genreList.Replace(" / ", ","); // Credits movieModel.Writers.Clear(); XmlNodeList writers = xmlReader.GetElementsByTagName("writer"); foreach (XmlElement writer in writers) { movieModel.Writers.Add(new PersonModel(writer.InnerXml)); } // Director string directorList = XRead.GetString(xmlReader, "director"); movieModel.DirectorAsString = directorList.Replace(" / ", ","); // Country movieModel.CountryAsString = XRead.GetString(xmlReader, "country"); // Language movieModel.LanguageAsString = XRead.GetString(xmlReader, "language"); // Actors XmlNodeList actors = xmlReader.GetElementsByTagName("actor"); movieModel.Cast.Clear(); foreach (XmlElement actor in actors) { XmlDocument document = XRead.OpenXml("<x>" + actor.InnerXml + "</x>"); string name = XRead.GetString(document, "name"); string role = XRead.GetString(document, "role"); string thumb = XRead.GetString(document, "thumb"); movieModel.Cast.Add(new PersonModel(name, thumb, role)); } movieModel.VideoSource = XRead.GetString(xmlReader, "videosource"); // Watched movieModel.Watched = XRead.GetBool(xmlReader, "watched"); // Sets XmlNodeList sets = xmlReader.GetElementsByTagName("set"); foreach (XmlElement set in sets) { if (set.HasAttribute("order")) { int order = int.Parse(set.GetAttribute("order")); MovieSetManager.AddMovieToSet(movieModel, set.InnerXml, order); } else { MovieSetManager.AddMovieToSet(movieModel, set.InnerXml); } } }
/// <summary> /// Populates the the series object with details from a series xml object. /// </summary> /// <param name="xml">The series xml.</param> public void PopulateFullDetails(SeriesXml xml) { var docList = new XmlDocument(); docList.LoadXml(xml.En); XmlNodeList nodes = docList.GetElementsByTagName("Series"); var doc = new XmlDocument(); doc.LoadXml(nodes[0].OuterXml); this.ID = XRead.GetUInt(doc, "id"); this.AirsDayOfWeek = XRead.GetString(doc, "Airs_DayOfWeek"); this.AirsTime = XRead.GetString(doc, "Airs_Time"); this.ContentRating = XRead.GetString(doc, "ContentRating"); this.FirstAired = XRead.GetDateTime(doc, "FirstAired", "yyyy-MM-dd"); this.Genre = XRead.GetString(doc, "Genre").ToBindingStringList('|'); this.ImdbId = XRead.GetString(doc, "IMDB_ID"); this.Language = XRead.GetString(doc, "Language"); this.Network = XRead.GetString(doc, "Network"); this.NetworkID = XRead.GetString(doc, "NetworkID"); this.Overview = XRead.GetString(doc, "Overview"); this.Rating = XRead.GetDouble(doc, "Rating"); this.Runtime = XRead.GetInt(doc, "Runtime"); this.SeriesID = XRead.GetUInt(doc, "id"); this.SeriesName = XRead.GetString(doc, "SeriesName"); this.Status = XRead.GetString(doc, "Status"); this.Added = XRead.GetString(doc, "added"); this.AddedBy = XRead.GetString(doc, "addedby"); this.SeriesBannerUrl = XRead.GetString(doc, "banner"); this.FanartUrl = XRead.GetString(doc, "fanart"); this.Lastupdated = XRead.GetString(doc, "lastupdated"); this.Zap2It_Id = XRead.GetString(doc, "zap2it_id"); this.PosterUrl = XRead.GetString(doc, "poster"); nodes = docList.GetElementsByTagName("Episode"); int?count = 0; // Count Seasons foreach (XmlNode node in nodes) { var episode = new Episode(); episode.Populate(node.OuterXml); if (episode.SeasonNumber > count) { count = episode.SeasonNumber; } } // Extract main Actors var actorsDoc = new XDocument(XDocument.Parse(xml.Actors)); IEnumerable <XElement> linqActors = from a in actorsDoc.Descendants("Actor") select a; foreach (XElement a in linqActors) { string image = a.Element("Image").Value; if (!string.IsNullOrEmpty(image)) { image = TvDBFactory.GetImageUrl(image); } var m = new PersonModel(a.Element("Name").Value, image, a.Element("Role").Value); this.Actors.Add(m); } this.Banner.Populate(xml.Banners); // Create Seasons int count2; int.TryParse(count.ToString(), out count2); for (int i = 0; i < count2 + 1; i++) { var season = new Season { SeasonNumber = i }; List <string> seasonBanner = (from p in this.Banner.Season where p.BannerType2 == BannerType2.seasonwide && p.Season == season.SeasonNumber.ToString() select p.BannerPath).ToList(); if (seasonBanner.Count > 0) { season.BannerUrl = seasonBanner[0]; //this.AddHighPriorityToBackgroundQueueWithCache(season.BannerUrl); } List <string> seasonPoster = (from p in this.Banner.Season where p.Season == season.SeasonNumber.ToString() select p.BannerPath). ToList(); if (this.posterUrl != null && seasonPoster.Count > 0) { season.PosterUrl = seasonPoster[0]; //this.AddHighPriorityToBackgroundQueueWithCache(season.PosterUrl); } List <BannerDetails> seasonFanart = (from p in this.Banner.Fanart select p).ToList(); if (seasonFanart.Count > i) { season.FanartUrl = seasonFanart[i].BannerPath; } else if (seasonFanart.Count > 0) { season.FanartUrl = seasonFanart[0].BannerPath; } if (!string.IsNullOrEmpty(season.FanartUrl)) { //this.AddHighPriorityToBackgroundQueueWithCache(season.FanartUrl); } this.Seasons.Add(i, season); } foreach (XmlNode node in nodes) { var episode = new Episode(); bool result = episode.Populate(node.OuterXml); if (result) { int episodeNumber; int.TryParse(episode.SeasonNumber.ToString(), out episodeNumber); this.Seasons[episodeNumber].Episodes.Add(episode); } } this.PreCacheSeriesThumbs(); }
/// <summary> /// Populates the object with specified XML. /// </summary> /// <param name="xml">The XML used to populate the object..</param> public void Populate(string xml) { this.Fanart.Clear(); this.Poster.Clear(); this.Season.Clear(); this.Series.Clear(); var docMain = new XmlDocument(); docMain.LoadXml(xml); var nodes = docMain.GetElementsByTagName("Banner"); foreach (XmlNode node in nodes) { var doc = new XmlDocument(); doc.LoadXml(node.OuterXml); var bannerDetails = new BannerDetails { ID = XRead.GetUInt(doc, "id"), BannerPath = XRead.GetString(doc, "BannerPath"), Colors = XRead.GetString(doc, "Colors"), Language = XRead.GetString(doc, "Language"), SeriesName = XRead.GetString(doc, "SeriesName"), ThumbnailPath = XRead.GetString(doc, "ThumbnailPath"), VignettePath = XRead.GetString(doc, "VignettePath"), Season = XRead.GetString(doc, "Season") }; switch (XRead.GetString(doc, "BannerType2")) { case "1920x1080": bannerDetails.BannerType2 = BannerType2.r1920x1080; break; case "1280x720": bannerDetails.BannerType2 = BannerType2.r1280x720; break; case "600x1000": bannerDetails.BannerType2 = BannerType2.r680x1000; break; case "season": bannerDetails.BannerType2 = BannerType2.season; break; case "seasonwide": bannerDetails.BannerType2 = BannerType2.seasonwide; break; case "graphical": bannerDetails.BannerType2 = BannerType2.graphical; break; case "text": bannerDetails.BannerType2 = BannerType2.text; break; case "blank": bannerDetails.BannerType2 = BannerType2.blank; break; } switch (XRead.GetString(doc, "BannerType")) { case "fanart": bannerDetails.BannerType = BannerType.Fanart; this.Fanart.Add(bannerDetails); break; case "poster": bannerDetails.BannerType = BannerType.Poster; this.Poster.Add(bannerDetails); break; case "season": bannerDetails.BannerType = BannerType.Season; this.Season.Add(bannerDetails); break; case "series": bannerDetails.BannerType = BannerType.Series; this.Series.Add(bannerDetails); break; } } }
/// <summary> /// Loads the series. /// </summary> /// <param name="series"> /// The series. /// </param> /// <returns> /// Loaded succeeded /// </returns> public bool LoadSeries(Series series) { string seriesName = series.SeriesName; string seriesPath = series.GetSeriesPath(); if (!string.IsNullOrEmpty(seriesName) || !string.IsNullOrEmpty(seriesPath)) { var seriesNameHex = "Set_" + FileSystemCharChange.To( seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Hex) + "_1"; var seriesNameChar = "Set_" + FileSystemCharChange.To( seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Char) + "_1"; string nfo = Find.FindNFO("Set_" + seriesName + "_1", seriesPath); if (string.IsNullOrEmpty(nfo)) { nfo = Find.FindNFO(seriesNameHex, seriesPath); if (string.IsNullOrEmpty(nfo)) { nfo = Find.FindNFO(seriesNameChar, seriesPath); if (!string.IsNullOrEmpty(nfo)) { XmlDocument doc = XRead.OpenPath(nfo); series.SeriesName = XRead.GetString(doc, "title"); series.SeriesID = XRead.GetUInt(doc, "id"); series.Rating = XRead.GetDouble(doc, "rating"); series.Overview = XRead.GetString(doc, "plot"); series.ContentRating = XRead.GetString(doc, "certification"); series.Genre = XRead.GetStrings(doc, "genre").ToBindingList(); series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd"); series.Network = XRead.GetString(doc, "country"); if (doc.GetElementsByTagName("actor").Count > 0) { series.Actors = new BindingList <PersonModel>(); foreach (XmlNode actor in doc.GetElementsByTagName("actor")) { string xmlActor = actor.InnerXml; XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>"); string name = XRead.GetString(docActor, "name"); string role = XRead.GetString(docActor, "role"); string imageurl = XRead.GetString(docActor, "thumb"); var personModel = new PersonModel(name, imageurl, role); series.Actors.Add(personModel); } } } } } } foreach (var season in series.Seasons) { foreach (var episode in season.Value.Episodes) { if (File.Exists(episode.FilePath.PathAndFilename)) { var nfoPath = Path.Combine( episode.FilePath.FolderPath, episode.FilePath.FilenameWithOutExt + ".nfo"); if (File.Exists(nfoPath)) { var doc = XRead.OpenPath(nfoPath); episode.SeasonNumber = XRead.GetInt(doc, "season"); episode.EpisodeNumber = XRead.GetInt(doc, "episode"); episode.EpisodeName = XRead.GetString(doc, "title"); episode.Overview = XRead.GetString(doc, "plot"); episode.FirstAired = XRead.GetDateTime(doc, "aired"); } } } } return(true); }