Beispiel #1
0
        private void LoadFromNfo()
        {
            string rawXml = System.IO.File.ReadAllText(this.NfoFile);
            List <TvEpisodeMeta> episodes = new List <TvEpisodeMeta>();

            foreach (Match match in Regex.Matches(rawXml, "<episodedetails>(.*?)</episodedetails>", RegexOptions.Singleline))
            {
                XDocument     doc     = XDocument.Parse(match.Value);
                TvEpisodeMeta episode = new TvEpisodeMeta(this.Filename);
                NfoLoader.Load <TvEpisodeMeta>(episode, doc.Element("episodedetails"));
                episodes.Add(episode);
            }
            this.Episodes       = episodes.ToArray();
            this.EpisodeNumbers = (from e in episodes select e.Episode).ToArray();
            if (this.Episodes.Length > 0)
            {
                this.Season = this.Episodes[0].Season;
            }
        }
Beispiel #2
0
        private bool LoadFromTheTvDb()
        {
            FileInfo fileInfo = new FileInfo(Filename);

            #region constructor TheTvdb Handler
            string cacheDirectory = Path.Combine(Settings.CachePath, "TheTvDb");
            if (!Directory.Exists(cacheDirectory))
            {
                Directory.CreateDirectory(cacheDirectory);
            }

            TvdbLib.Cache.ICacheProvider cacheProvider = new TvdbLib.Cache.XmlCacheProvider(cacheDirectory);
            TvdbLib.TvdbHandler          tvdbHandler   = new TvdbLib.TvdbHandler(cacheProvider, Settings.TvdbApiKey);
            #endregion

            LoadShowMeta(tvdbHandler);
            if (this.TvShow == null)
            {
                Trace.WriteLine(String.Format("Failed to find tv show '{0}' for file: {1}", this.ShowTitle, this.Filename));
                return(false);
            }

            TvdbLib.Data.TvdbEpisode.EpisodeOrdering ordering = TvdbLib.Data.TvdbEpisode.EpisodeOrdering.DefaultOrder;
            if (this.Filename.ToUpper().Contains("[DVD]") && this.Season > 0) // specials dont use dvd order... i think...
            {
                ordering = TvdbLib.Data.TvdbEpisode.EpisodeOrdering.DvdOrder;
            }

            int epbookmark    = 0;
            int episodeLength = 0;
            if (this.FileInfo != null && this.FileInfo.Video != null)
            {
                episodeLength = this.FileInfo.Video.DurationInSeconds / this.EpisodeNumbers.Length;
            }

            if (this.Episodes == null || this.Episodes.Length != this.EpisodeNumbers.Length)
            {
                this.Episodes = new TvEpisodeMeta[this.EpisodeNumbers.Length];
            }

            int index = 0;
            foreach (int epNumber in this.EpisodeNumbers)
            {
                TvdbLib.Data.TvdbEpisode tvdbEpisode = null;
                try
                {
                    tvdbEpisode = tvdbHandler.GetEpisode(this.TvShow.Id, this.Season, epNumber, ordering, TvdbLib.Data.TvdbLanguage.DefaultLanguage);
                }
                catch (Exception)
                {
                    if (ordering == TvdbLib.Data.TvdbEpisode.EpisodeOrdering.DvdOrder) // fail back to default ordering, incase there is no dvd ordering available (eg Sliders Season 3)
                    {
                        tvdbEpisode = tvdbHandler.GetEpisode(this.TvShow.Id, this.Season, epNumber, TvdbLib.Data.TvdbEpisode.EpisodeOrdering.DefaultOrder, TvdbLib.Data.TvdbLanguage.DefaultLanguage);
                    }
                }
                if (tvdbEpisode == null)
                {
                    continue;
                }
                if (this.Episodes[index] == null)
                {
                    this.Episodes[index] = new TvEpisodeMeta(this.Filename);
                }

                TvEpisodeMeta meta = this.Episodes[index];
                meta.TvdbId         = tvdbEpisode.Id;
                meta.TvdbSeriesId   = tvdbEpisode.SeriesId;
                meta.Actors         = (from gs in tvdbEpisode.GuestStars select new KeyValuePair <string, string>(gs, null)).ToArray();
                meta.Aired          = tvdbEpisode.FirstAired;
                meta.Directors      = tvdbEpisode.Directors.ToArray();
                meta.DisplayEpisode = tvdbEpisode.AirsBeforeEpisode >= 0 ? tvdbEpisode.AirsBeforeEpisode : -1;
                meta.DisplaySeason  = tvdbEpisode.AirsBeforeSeason >= 0 ? tvdbEpisode.AirsBeforeSeason : -1;
                meta.Episode        = tvdbEpisode.EpisodeNumber;
                meta.Season         = tvdbEpisode.SeasonNumber;
                meta.Plot           = tvdbEpisode.Overview;
                meta.Premiered      = tvdbEpisode.FirstAired;
                meta.Rating         = (float)tvdbEpisode.Rating;
                meta.ShowTitle      = this.TvShow.Title;
                meta.Mpaa           = this.TvShow.Mpaa;
                meta.Studio         = this.TvShow.Studio;
                meta.EpBookmark     = epbookmark;
                if (!String.IsNullOrEmpty(tvdbEpisode.BannerPath))
                {
                    meta.Thumb = "http://thetvdb.com/banners/" + tvdbEpisode.BannerPath;
                }
                meta.Title   = tvdbEpisode.EpisodeName;
                meta.Writers = tvdbEpisode.Writer.ToArray();
                epbookmark  += episodeLength; // not perfect, but good starting point.

                if (ordering == TvdbLib.Data.TvdbEpisode.EpisodeOrdering.DvdOrder)
                {
                    meta.Episode = (int)tvdbEpisode.DvdEpisodeNumber;
                    meta.Season  = tvdbEpisode.DvdSeason;
                }

                index++;
            }
            return(true);
        }
Beispiel #3
0
 private void LoadFromNfo()
 {
     string rawXml = System.IO.File.ReadAllText(this.NfoFile);
     List<TvEpisodeMeta> episodes = new List<TvEpisodeMeta>();
     foreach (Match match in Regex.Matches(rawXml, "<episodedetails>(.*?)</episodedetails>", RegexOptions.Singleline))
     {
         XDocument doc = XDocument.Parse(match.Value);
         TvEpisodeMeta episode = new TvEpisodeMeta(this.Filename);
         NfoLoader.Load<TvEpisodeMeta>(episode, doc.Element("episodedetails"));
         episodes.Add(episode);
     }
     this.Episodes = episodes.ToArray();
     this.EpisodeNumbers = (from e in episodes select e.Episode).ToArray();
     if(this.Episodes.Length > 0)
         this.Season = this.Episodes[0].Season;
 }