Beispiel #1
0
 private static Show BuildShow(XDocument doc)
 {
     return new Show {
         ID = doc.GetSeriesData("id"),
         ImdbID = doc.GetSeriesData("IMDB_ID"),
         Name = doc.GetSeriesData("SeriesName"),
         Language = doc.GetSeriesData("Language"),
         Network = doc.GetSeriesData("Network"),
         Description = doc.GetSeriesData("Overview"),
         Rating = string.IsNullOrWhiteSpace(doc.GetSeriesData("Rating"))
                         ? (double?)null
                         : Convert.ToDouble(doc.GetSeriesData("Rating"),
                                         System.Globalization.CultureInfo.InvariantCulture),
         RatingCount = string.IsNullOrWhiteSpace(doc.GetSeriesData("RatingCount"))
                             ? 0
                             : Convert.ToInt32(doc.GetSeriesData("RatingCount")),
         Runtime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Runtime"))
                         ? (int?)null
                         : Convert.ToInt32(doc.GetSeriesData("Runtime")),
         Banner = doc.GetSeriesData("banner"),
         Fanart = doc.GetSeriesData("fanart"),
         LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated"))
                             ? (long?)null
                             : Convert.ToInt64(doc.GetSeriesData("lastupdated")),
         Poster = doc.GetSeriesData("poster"),
         Zap2ItID = doc.GetSeriesData("zap2it_id"),
         FirstAired = Utils.ParseDate(doc.GetSeriesData("FirstAired")),
         AirTime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_Time"))
                         ? (TimeSpan?)null
                         : Utils.ParseTime(doc.GetSeriesData("Airs_Time")),
         AirDay = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_DayOfWeek"))
                         ? (DayOfWeek?)null
                         : (DayOfWeek)Enum.Parse(typeof(DayOfWeek), doc.GetSeriesData("Airs_DayOfWeek")),
         Status = string.IsNullOrWhiteSpace(doc.GetSeriesData("Status"))
                         ? Status.Unknown
                         : (Status)Enum.Parse(typeof(Status), doc.GetSeriesData("Status")),
         ContentRating = Utils.GetContentRating(doc.GetSeriesData("ContentRating")),
         Genres = new List<string>(doc.GetSeriesData("Genre").Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)),
         Actors = new List<string>(doc.GetSeriesData("Actors").Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)),
         Episodes = BuildEpisodes(doc)
     };
 }
Beispiel #2
0
            public ShowBuilder(XDocument doc)
            {
                _show = doc.Root
                    .Elements("Series")
                    .Select(show => new Show
                    {
                        Id = int.Parse(show.Attribute("id").ToString()),
                        ImdbId = show.Attribute("IMDB_ID").ToString(),
                        Name = show.Attribute("SeriesName").ToString(),
                        Language = show.Attribute("Language").ToString(),
                        Network = show.Attribute("Network").ToString(),
                        Description = show.Attribute("Overview").ToString(),
                        Rating = string.IsNullOrWhiteSpace(show.Attribute("Rating").ToString())
                            ? (double?)null
                            : Convert.ToDouble(show.Attribute("Rating").ToString(), CultureInfo.InvariantCulture),
                        RatingCount = string.IsNullOrWhiteSpace(show.Attribute("RatingCount").ToString())
                            ? 0
                            : Convert.ToInt32(show.Attribute("RatingCount").ToString()),
                        Runtime = string.IsNullOrWhiteSpace(show.Attribute("Runtime").ToString())
                            ? 0
                            : Convert.ToInt32(show.Attribute("Runtime").ToString()),
                        Banner = GetBannerUri(show.Attribute("banner").ToString()),
                        Fanart = GetBannerUri(show.Attribute("fanart").ToString()),
                        LastUpdated = string.IsNullOrWhiteSpace(show.Attribute("lastupdated").ToString())
                            ? (long?)null
                            : Convert.ToInt64(show.Attribute("lastupdated").ToString()),
                        Poster = GetBannerUri(show.Attribute("poster").ToString()),
                        Zap2ItID = show.Attribute("zap2it_id").ToString(),
                        FirstAired = string.IsNullOrWhiteSpace(show.Attribute("FirstAired").ToString())
                            ? (DateTime?)null
                            : DateTime.ParseExact(show.Attribute("FirstAired").ToString(), "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal)
                    })
                    .FirstOrDefault();

                _show = new Show();
                _show.Id = int.Parse(doc.GetSeriesData("id"));
                _show.ImdbId = doc.GetSeriesData("IMDB_ID");
                _show.Name = doc.GetSeriesData("SeriesName");
                _show.Language = doc.GetSeriesData("Language");
                _show.Network = doc.GetSeriesData("Network");
                _show.Description = doc.GetSeriesData("Overview");
                _show.Rating = string.IsNullOrWhiteSpace(doc.GetSeriesData("Rating"))
                    ? (double?) null
                    : Convert.ToDouble(doc.GetSeriesData("Rating"),
                        System.Globalization.CultureInfo.InvariantCulture);
                _show.RatingCount = string.IsNullOrWhiteSpace(doc.GetSeriesData("RatingCount"))
                    ? 0
                    : Convert.ToInt32(doc.GetSeriesData("RatingCount"));
                _show.Runtime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Runtime"))
                    ? (int?) null
                    : Convert.ToInt32(doc.GetSeriesData("Runtime"));
                _show.Banner = GetBannerUri(doc.GetSeriesData("banner"));
                _show.Fanart = GetBannerUri(doc.GetSeriesData("fanart"));
                _show.LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated"))
                    ? (long?) null
                    : Convert.ToInt64(doc.GetSeriesData("lastupdated"));
                _show.Poster = GetBannerUri(doc.GetSeriesData("poster"));
                _show.Zap2ItID = doc.GetSeriesData("zap2it_id");
                _show.FirstAired = string.IsNullOrWhiteSpace(doc.GetSeriesData("FirstAired"))
                    ? (DateTime?) null
                    : Utils.ParseDate(doc.GetSeriesData("FirstAired"));
                _show.AirTime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_Time"))
                    ? (TimeSpan?) null
                    : Utils.ParseTime(doc.GetSeriesData("Airs_Time"));
                _show.AirDay = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_DayOfWeek"))
                    ? (Frequency?) null
                    : (Frequency) Enum.Parse(typeof (Frequency), doc.GetSeriesData("Airs_DayOfWeek"));
                _show.Status = string.IsNullOrWhiteSpace(doc.GetSeriesData("Status"))
                    ? Status.Unknown
                    : (Status) Enum.Parse(typeof (Status), doc.GetSeriesData("Status"));
                _show.ContentRating = Utils.GetContentRating(doc.GetSeriesData("ContentRating"));
                _show.Genres =
                    new List<string>(doc.GetSeriesData("Genre")
                        .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries));
                _show.Actors =
                    new List<string>(doc.GetSeriesData("Actors")
                        .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries));
                _show.Episodes = new EpisodesBuilder(doc).BuildEpisodes();
            }