Exemplo n.º 1
0
 public WriteTvInfoToXml(Show tvShow, string folder)
 {
     var tvdb = new TVDB(_apiKey);
     var _episodeGuide = "http://www.thetvdb.com/api/" + _apiKey + "/series/" + tvShow.Id + "/all/en.zip";
     var actors = tvShow.Actors;
     string _year;
     if (tvShow.FirstAired != null)
     {
         _year = ((DateTime) tvShow.FirstAired).Year.ToString();
     }
     else
     {
         _year = "Unkown year";
     }
     var settings = new XmlWriterSettings
     {
         Indent = true,
         OmitXmlDeclaration = true,
         NewLineOnAttributes = true
     };
     using (XmlWriter writer = XmlWriter.Create(folder + "\\tvshow.nfo", settings))
     {
         writer.WriteStartDocument();
         writer.WriteStartElement("tvshow");
             writer.WriteElementString("title", tvShow.Name);
             writer.WriteElementString("showtitle", tvShow.Name);
             writer.WriteElementString("year", _year);
             writer.WriteElementString("plot", tvShow.Description);
             writer.WriteStartElement("episodeguideurl");
                 writer.WriteElementString("url", _episodeGuide);
             writer.WriteEndElement();
             foreach (var genre in tvShow.Genres)
             {
                 writer.WriteElementString("genre", genre);
             }
             writer.WriteElementString("premiered", tvShow.FirstAired.ToString());
             foreach (var actor in actors)
             {
                 writer.WriteStartElement("actor");
                     writer.WriteElementString("name", actor);
                 writer.WriteEndElement();
             }
             writer.WriteElementString("dateadded", DateTime.Now.ToString());
         writer.WriteEndElement();
         writer.WriteEndDocument();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     This example demonstrates the retrieval and display of a show.
        /// </summary>
        public static void Print(Show show)
        {
            Console.WriteLine("{0}:\t{1}", "IMDB ID", show.ImdbId);
            Console.WriteLine("{0}:\t{1}", "ID", show.Id);
            Console.WriteLine("{0}:\t{1}", "Language", show.Language);
            Console.WriteLine("{0}:\t{1}", "Last update", show.LastUpdated);
            Console.WriteLine("{0}:\t{1}", "Name", show.Name);
            Console.WriteLine("{0}:\t{1}", "Network", show.Network);
            Console.WriteLine("{0}:\t{1}", "Poster", show.Poster);
            Console.WriteLine("{0}:\t{1}", "Rating", show.Rating);
            Console.WriteLine("{0}:\t{1}", "# Votes", show.RatingCount);
            Console.WriteLine("{0}:\t{1}", "Runtime", show.Runtime);
            Console.WriteLine("{0}:\t{1}", "Status", show.Status);
            Console.WriteLine("{0}:\t{1}", "Zap2it ID", show.Zap2ItID);
            Console.WriteLine("{0}:\t{1}", "Airday", show.AirDay);
            Console.WriteLine("{0}:\t{1}", "AirTime", show.AirTime);
            Console.WriteLine("{0}:\t{1}", "Banner", show.Banner);
            Console.WriteLine("{0}:\t{1}", "ContentRating", show.ContentRating);
            Console.WriteLine("{0}:\t{1}", "Description", show.Description);
            Console.WriteLine("{0}:\t{1}", "Fanart", show.Fanart);
            Console.WriteLine("{0}:\t{1}", "First aired", show.FirstAired);

            Console.Write("Actors:\t");
            foreach (var element in show.Actors)
            {
                Console.Write("{0} | ", element);
            }

            Console.Write("Genres:\t");
            foreach (var element in show.Genres)
            {
                Console.Write("{0} | ", element);
            }

            Console.Write("Episodes:");
            foreach (var element in show.Episodes)
            {
                Console.WriteLine(element.Title);
            }
        }
Exemplo n.º 3
0
 private void UpdateShowInfo(Show show)
 {
     Poster.Source = new BitmapImage(show.Poster);
     TxtBlockTitle.Text = show.Name;
     LblFirstAired.Content = show.FirstAired != null ? show.FirstAired.Value.ToString("dd.MM.yyyy") : "---";
     LblTvStation.Content = show.Network != string.Empty ? show.Network : "---";
     LblStatus.Content = show.Status;
     LblRating.Content = show.Rating;
     TxtBlockDesc.Text = show.Description;
 }
Exemplo n.º 4
0
        private void UpdateListWithNames(Show tvShow)
        {
            foreach (var t in _fileList)
            {
                var e = int.Parse(t.EpisodeNumber);
                var s = int.Parse(t.SeasonNumber);
                var episode = tvShow.Episodes.FirstOrDefault(x => x.EpisodeNumber == e && x.SeasonNumber == s);

                if (episode != null)
                {
                    t.EpisodeName = episode.Title;
                }

                t.SeriesName = tvShow.Name;
            }
        }
Exemplo n.º 5
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();
            }
Exemplo n.º 6
0
 public ShowBuilder(XDocument doc)
 {
     _show = new Show();
     _show.ID = 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 = doc.GetSeriesData("banner");
     _show.Fanart = doc.GetSeriesData("fanart");
     _show.LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated"))
                             ? (long?) null
                             : Convert.ToInt64(doc.GetSeriesData("lastupdated"));
     _show.Poster = doc.GetSeriesData("poster");
     _show.Zap2ItID = doc.GetSeriesData("zap2it_id");
     _show.FirstAired = 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"))
                        ? (DayOfWeek?) null
                        : (DayOfWeek) Enum.Parse(typeof(DayOfWeek), 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 EpisodeBuilder(doc).BuildEpisodes();
 }