示例#1
0
        /// <summary>
        /// Get season super tip.
        /// </summary>
        /// <param name="season">
        /// The season.
        /// </param>
        /// <returns>
        /// The season super tip.
        /// </returns>
        public static SuperToolTip GetSeasonSuperTip(Season season)
        {
            if (season == null)
            {
                return new SuperToolTip();
            }

            var superTip = new SuperToolTip { AllowHtmlText = DefaultBoolean.True };

            superTip.Items.AddTitle(string.Format("Season {0}", season.SeasonNumber));

            foreach (Episode episode in season.Episodes)
            {
                var tip = new ToolTipItem();

                string found = File.Exists(episode.FilePath.FileNameAndPath)
                                   ? "<color=206,244,208>File Exists</color>"
                                   : "<b><color=244,206,206>File Does Not Exist</color></b>";

                tip.Text = string.Format("<b>{0}</b>:{1} - {2}", episode.EpisodeNumber, episode.EpisodeName, found);

                superTip.Items.Add(tip);
            }

            return superTip;
        }
示例#2
0
        public static string TvSeason(Season season, string replace, string fromFile, string altFirstEpisode = null)
        {
            string seriesName = "test show";
            string firstEpisodeFullPath = @"c:\test show\season 1\test show.s01e01.avi";
            bool settings = false;
            

            if (season == null)
            {
                season = new Season();
                season.Episodes.Add(new Episode { FilePath = new MediaModel { PathAndFilename = @"c:\test show\season 1\test show.s01e01.avi" } });
                settings = true;
            }

            string firstEpisodeOfSeasonPath;
            string firstEpisodeOfSeason;

            if (altFirstEpisode != null)
            {
                if (altFirstEpisode == string.Empty)
                {
                    return string.Empty;
                }

                if (MovieNaming.IsDVD(altFirstEpisode))
                {
                    firstEpisodeFullPath = MovieNaming.GetDvdPath(altFirstEpisode) + MovieNaming.GetDvdName(altFirstEpisode);
                    firstEpisodeOfSeasonPath = MovieNaming.GetDvdPath(altFirstEpisode);
                    firstEpisodeOfSeason = MovieNaming.GetDvdName(altFirstEpisode);
                }
                else if (MovieNaming.IsBluRay(altFirstEpisode))
                {
                    firstEpisodeFullPath = MovieNaming.GetBluRayPath(altFirstEpisode) + MovieNaming.GetBluRayName(altFirstEpisode);
                    firstEpisodeOfSeasonPath = MovieNaming.GetBluRayPath(altFirstEpisode);
                    firstEpisodeOfSeason = MovieNaming.GetBluRayName(altFirstEpisode);
                }
                else
                {
                    firstEpisodeFullPath = altFirstEpisode;
                    firstEpisodeOfSeasonPath = Path.GetDirectoryName(altFirstEpisode);
                    firstEpisodeOfSeason = Path.GetFileNameWithoutExtension(altFirstEpisode);
                }

                seriesName = Regex.Match(Path.GetFileNameWithoutExtension(firstEpisodeFullPath), "(?<seriesName>.*?)" + Settings.ConstSettings.DefaultRegex.Tv, RegexOptions.IgnoreCase).Groups["seriesName"].Value.Trim();
                
            }
            else
            {
                if (!settings)
                {
                    firstEpisodeFullPath = season.GetFirstEpisode();
                    seriesName = Restructure.FileSystemCharChange.To(season.GetSeries().SeriesName, FileSystemCharChange.ConvertArea.Tv);
                }

                if (MovieNaming.IsDVD(firstEpisodeFullPath))
                {
                    firstEpisodeOfSeasonPath = MovieNaming.GetDvdPath(firstEpisodeFullPath);
                    firstEpisodeOfSeason = MovieNaming.GetDvdName(firstEpisodeFullPath);
                }
                else if (MovieNaming.IsBluRay(firstEpisodeFullPath))
                {
                    firstEpisodeOfSeasonPath = MovieNaming.GetBluRayPath(firstEpisodeFullPath);
                    firstEpisodeOfSeason = MovieNaming.GetBluRayName(firstEpisodeFullPath);
                }
                else
                {
                    firstEpisodeOfSeasonPath = Path.GetDirectoryName(firstEpisodeFullPath);
                    firstEpisodeOfSeason = Path.GetFileNameWithoutExtension(firstEpisodeFullPath);
                }
            }

            var firstEpisodePath = Path.GetDirectoryName(firstEpisodeFullPath);

            replace = replace.Replace(Settings.Get.InOutCollection.TvSeriesName, seriesName);
            replace = replace.Replace(Settings.Get.InOutCollection.TvFirstEpisodePathOfSeries, firstEpisodePath);
            replace = replace.Replace(Settings.Get.InOutCollection.TvFirstEpisodeOfSeasonPath, firstEpisodeOfSeasonPath);
            replace = replace.Replace(Settings.Get.InOutCollection.TvFirstEpisodeOfSeason, firstEpisodeOfSeason);
            replace = replace.Replace(Settings.Get.InOutCollection.TvSeasonNumber, season.SeasonNumber.ToString());
            replace = replace.Replace(Settings.Get.InOutCollection.TvSeasonNumber2, string.Format("{0:d2}", season.SeasonNumber));

            if (settings)
            {
                replace = replace.Replace(Settings.Get.InOutCollection.TvSeriesPath, @"c:\testshow\season 1\");
            }
            else
            {
                replace = replace.Replace(Settings.Get.InOutCollection.TvSeriesPath, season.GetSeries().GetSeriesPath());
            }

            return replace + Path.GetExtension(fromFile); ;
        }
示例#3
0
        /// <summary>
        /// Processes the season to the background queue.
        /// </summary>
        /// <param name="season">
        /// The season.
        /// </param>
        private static void ProcessSeasonToBackground(Season season)
        {
            if (season.ContainsEpisodesWithFiles())
            {
                var current = GenerateOutput.AccessCurrentIOHandler() as IoInterface;

                if (current == null)
                {
                    return;
                }

                string bannerPath = current.GetSeasonBanner(season);

                if (string.IsNullOrEmpty(bannerPath))
                {
                    var downloadItem = new DownloadItem
                        {
                            Url = TvDBFactory.GetImageUrl(season.BannerUrl), 
                            Type = DownloadType.Binary, 
                            Section = Section.Tv
                        };

                    Downloader.AddToBackgroundQue(downloadItem);
                }
                else
                {
                    season.BannerPath = bannerPath;
                }

                string posterPath = current.GetSeasonPoster(season);

                if (string.IsNullOrEmpty(posterPath))
                {
                    var downloadItem = new DownloadItem
                        {
                            Url = TvDBFactory.GetImageUrl(season.PosterUrl), 
                            Type = DownloadType.Binary, 
                            Section = Section.Tv
                        };

                    Downloader.AddToBackgroundQue(downloadItem);
                }
                else
                {
                    season.PosterPath = posterPath;
                }

                string fanartPath = current.GetSeasonFanart(season);

                if (string.IsNullOrEmpty(fanartPath))
                {
                    var downloadItem = new DownloadItem
                        {
                            Url = TvDBFactory.GetImageUrl(season.FanartUrl), 
                            Type = DownloadType.Binary, 
                            Section = Section.Tv
                        };

                    Downloader.AddToBackgroundQue(downloadItem);
                }
                else
                {
                    season.FanartPath = fanartPath;
                }
            }
        }
示例#4
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Loads the season.
 /// </summary>
 /// <param name="season">
 /// The season.
 /// </param>
 /// <returns>
 /// Season object
 /// </returns>
 public bool LoadSeason(Season season)
 {
     throw new NotImplementedException();
 }
示例#5
0
        /// <summary>
        /// The save specific season.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <param name="type">The SeasonIOType type.</param>
        /// <returns>
        /// Process Succeeded
        /// </returns>
        public static bool SaveSpecificSeason(Season season, SeasonIOType type = SeasonIOType.All)
        {
            try
            {
                if (Get.InOutCollection.IoType == NFOType.YAMJ)
                {
                    yamj.SaveSeason(season, type);
                }
                else if (Get.InOutCollection.IoType == NFOType.XBMC)
                {
                    xbmc.SaveSeason(season, type);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveSpecificSeason", exception.Message);
                return false;
            }

            return true;
        }
示例#6
0
        public string GetSeasonImage(Season season, string stringFormat)
        {
            string firstEpisode = season.GetFirstEpisode();

            if (string.IsNullOrEmpty(firstEpisode))
            {
                return string.Empty;
            }

            var path = Path.GetDirectoryName(firstEpisode);
            var fileName = Path.GetFileNameWithoutExtension(firstEpisode);

            return this.GetImageWithParse(path, fileName, stringFormat);
        }
示例#7
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Gets the season fanart.
 /// </summary>
 /// <param name="season">The season.</param>
 /// <returns>
 /// Season fanart path
 /// </returns>
 public string GetSeasonFanart(Season season)
 {
     return this.GetSeasonImage(season, "{0}.fanart.jpg");
 }
示例#8
0
 public static void LockSeason(Season season)
 {
     season.IsLocked = true;
 }
示例#9
0
 public static void UnlockSeason(Season season)
 {
     season.IsLocked = false;
 }
示例#10
0
        /// <summary>
        /// Update episode.
        /// </summary>
        /// <param name="season">
        /// The season to update
        /// </param>
        /// <param name="newEpisode">
        /// The new episode.
        /// </param>
        public static void UpdateEpisode(Season season, Episode newEpisode, bool force = false)
        {
            InternalApps.Logs.Log.WriteToLog(
                        LogSeverity.Debug,
                        0,
                        "Factories > TvDBFactory > UpdateEpisode",
                        string.Format(
                            "Updating episode {0} in season {1} ({2}). Forced: {3}",
                            newEpisode.EpisodeNumber, newEpisode.SeasonNumber, newEpisode.GetSeriesName(), force ? "true" : "false"
                        )
            );

            Episode episode =
                (from e in season.Episodes where e.EpisodeNumber == newEpisode.EpisodeNumber select e).SingleOrDefault();

            if (episode == null)
            {
                season.Episodes.Add(newEpisode);
                return;
            }

            if (!newEpisode.IsLocked && (episode.Lastupdated != newEpisode.Lastupdated || force))
            {
                episode.AbsoluteNumber = newEpisode.AbsoluteNumber;
                episode.CombinedEpisodenumber = newEpisode.CombinedEpisodenumber;
                episode.CombinedSeason = newEpisode.CombinedSeason;
                episode.Director = newEpisode.Director;
                episode.DvdChapter = newEpisode.DvdChapter;
                episode.DvdDiscid = newEpisode.DvdDiscid;
                episode.DvdEpisodenumber = newEpisode.DvdEpisodenumber;
                episode.DvdSeason = newEpisode.DvdSeason;
                episode.EpisodeImgFlag = newEpisode.EpisodeImgFlag;
                episode.EpisodeName = newEpisode.EpisodeName;
                episode.EpisodeNumber = newEpisode.EpisodeNumber;
                episode.FirstAired = newEpisode.FirstAired;
                episode.GuestStars = newEpisode.GuestStars;
                episode.IMDBID = newEpisode.IMDBID;
                episode.Language = newEpisode.Language;
                episode.Overview = newEpisode.Overview;
                episode.ProductionCode = newEpisode.ProductionCode;
                episode.Rating = newEpisode.Rating;
                episode.SeasonNumber = newEpisode.SeasonNumber;
                episode.Writers = newEpisode.Writers;

                if (string.IsNullOrEmpty(episode.EpisodeScreenshotPath)
                    && string.IsNullOrEmpty(episode.EpisodeScreenshotUrl))
                {
                    episode.EpisodeScreenshotUrl = newEpisode.EpisodeScreenshotUrl;
                }
            }
        }
示例#11
0
        /// <summary>
        /// The update season.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="newSeason">
        /// The new season.
        /// </param>
        public static void UpdateSeason(Series series, Season newSeason, int? episodeNumber = null, bool force = false)
        {
            InternalApps.Logs.Log.WriteToLog(
                        LogSeverity.Debug,
                        0,
                        "Factories > TvDBFactory > UpdateSeason",
                        string.Format(
                            "Called with episodeNumber {0} ({1}). Forced: {2}",
                            episodeNumber.GetValueOrDefault(0), series.SeriesName, force ? "true" : "false"
                        )
            );

            if (!series.Seasons.ContainsKey(newSeason.SeasonNumber))
            {
                series.Seasons.Add(newSeason.SeasonNumber, newSeason);
                return;
            }

            Season season = series.Seasons[newSeason.SeasonNumber];

            if (!season.IsLocked)
            {
                if (string.IsNullOrEmpty(season.BannerPath) && string.IsNullOrEmpty(season.BannerUrl))
                {
                    season.BannerUrl = newSeason.BannerUrl;
                }

                if (string.IsNullOrEmpty(season.FanartPath) && string.IsNullOrEmpty(season.FanartUrl))
                {
                    season.FanartPath = newSeason.FanartUrl;
                }

                if (string.IsNullOrEmpty(season.PosterPath) && string.IsNullOrEmpty(season.PosterUrl))
                {
                    season.PosterPath = newSeason.PosterUrl;
                }
            }
            
            foreach (Episode episode in newSeason.Episodes)
            {
                if (episodeNumber == null)
                {
                    UpdateEpisode(season, episode, force);
                }
                else if (episode.EpisodeNumber == episodeNumber)
                {
                    UpdateEpisode(season, episode, true);
                }
            }
        }
示例#12
0
文件: XBMC.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Gets the season poster.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <returns>
        /// Season Poster path
        /// </returns>
        public string GetSeasonPoster(Season season)
        {
            string seasonPath = season.GetSeasonPath();

            if (string.IsNullOrEmpty(seasonPath))
            {
                return string.Empty;
            }

            string path = Path.GetDirectoryName(seasonPath);
            // <root>/<tv series>/season<00>.tbn
            // <root>/<tv series>/season <00>/<episodes>
            string checkPath = path + "season" + string.Format("{0:d2}", season.SeasonNumber) +".tbn";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
示例#13
0
文件: XBMC.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Gets the season fanart.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <returns>
        /// Season fanart path
        /// </returns>
        public string GetSeasonFanart(Season season)
        {
            // Not sure this is supported by XBMC
            string firstEpisode = season.GetFirstEpisode();

            if (string.IsNullOrEmpty(firstEpisode))
            {
                return string.Empty;
            }

            string path = Path.GetDirectoryName(firstEpisode);

            string checkPath = path + Path.DirectorySeparatorChar + "fanart.jpg";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
示例#14
0
文件: XBMC.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Gets the season banner.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <returns>
        /// Season banner path
        /// </returns>
        public string GetSeasonBanner(Season season)
        {
            // Having folder.jpg inside the season folder, might overwrite the season poster named seasonxx.tbn in season root
            if (string.IsNullOrEmpty(season.GetSeasonPath()))
            {
                return string.Empty;
            }

            string path = season.GetSeasonPath();

            string checkPath = path + Path.DirectorySeparatorChar + "folder.jpg";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
示例#15
0
        /// <summary>
        /// Initializes static members of the <see cref="TvDBFactory"/> class. 
        /// </summary>
        static TvDBFactory()
        {
            tvDatabase = new SortedList<string, Series>();

            CurrentSeries = new Series();
            CurrentSeason = new Season();
            CurrentEpisode = new Episode();

            galleryGroup = new GalleryItemGroup();

            masterSeriesNameList = new BindingList<MasterSeriesListModel>();

            currentSelectedSeries = new List<Series>();
            currentSelectedSeason = new List<Season>();
            currentSelectedEpisode = new List<Episode>();
        }
示例#16
0
 public static void HideSeason(Season season)
 {
     // TODO: Hide season
 }
示例#17
0
        /// <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();
        }
示例#18
0
        /// <summary>
        /// Gets the season poster.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <returns>
        /// Season Poster path
        /// </returns>
        public string GetSeasonPoster(Season season)
        {
            string firstEpisode = season.GetFirstEpisode();

            if (string.IsNullOrEmpty(firstEpisode))
            {
                return string.Empty;
            }

            string path = Path.GetDirectoryName(firstEpisode);
            string fileName = Path.GetFileNameWithoutExtension(firstEpisode);

            string checkPath = path + Path.DirectorySeparatorChar + fileName + ".jpg";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
示例#19
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Gets the season banner.
 /// </summary>
 /// <param name="season">The season.</param>
 /// <returns>
 /// Season banner path
 /// </returns>
 public string GetSeasonBanner(Season season)
 {
     return this.GetSeasonImage(season, "{0}.banner.jpg");
 }
示例#20
0
        /// <summary>
        /// Set current season by guid
        /// </summary>
        /// <param name="guid">
        /// The guid value
        /// </param>
        public static void SetCurrentSeason(string guid)
        {
            Season season =
                (from e in CurrentSeries.Seasons where e.Value.Guid == guid select e.Value).SingleOrDefault();

            if (season != null)
            {
                CurrentSeason = season;
                InvokeCurrentSeasonChanged(new EventArgs());
                InvokeCurrentEpisodeChanged(new EventArgs());
            }
        }
示例#21
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Gets the season poster.
 /// </summary>
 /// <param name="season">The season.</param>
 /// <returns>
 /// Season Poster path
 /// </returns>
 public string GetSeasonPoster(Season season)
 {
     return this.GetSeasonImage(season, "{0}.jpg");
 }
示例#22
0
        /// <summary>
        /// Update episode.
        /// </summary>
        /// <param name="season">
        /// The season to update
        /// </param>
        /// <param name="newEpisode">
        /// The new episode.
        /// </param>
        public static void UpdateEpisode(Season season, Episode newEpisode)
        {
            Episode episode =
                (from e in season.Episodes where e.EpisodeNumber == newEpisode.EpisodeNumber select e).SingleOrDefault();

            if (episode == null)
            {
                season.Episodes.Add(newEpisode);
                return;
            }

            if (!newEpisode.IsLocked && episode.Lastupdated != newEpisode.Lastupdated)
            {
                episode.AbsoluteNumber = newEpisode.AbsoluteNumber;
                episode.CombinedEpisodenumber = newEpisode.CombinedEpisodenumber;
                episode.CombinedSeason = newEpisode.CombinedSeason;
                episode.Director = newEpisode.Director;
                episode.DvdChapter = newEpisode.DvdChapter;
                episode.DvdDiscid = newEpisode.DvdDiscid;
                episode.DvdEpisodenumber = newEpisode.DvdEpisodenumber;
                episode.DvdSeason = newEpisode.DvdSeason;
                episode.EpisodeImgFlag = newEpisode.EpisodeImgFlag;
                episode.EpisodeName = newEpisode.EpisodeName;
                episode.EpisodeNumber = newEpisode.EpisodeNumber;
                episode.FirstAired = newEpisode.FirstAired;
                episode.GuestStars = newEpisode.GuestStars;
                episode.IMDBID = newEpisode.IMDBID;
                episode.Language = newEpisode.Language;
                episode.Overview = newEpisode.Overview;
                episode.ProductionCode = newEpisode.ProductionCode;
                episode.Rating = newEpisode.Rating;
                episode.SeasonNumber = newEpisode.SeasonNumber;
                episode.Writers = newEpisode.Writers;

                if (string.IsNullOrEmpty(episode.EpisodeScreenshotPath) &&
                    string.IsNullOrEmpty(episode.EpisodeScreenshotUrl))
                {
                    episode.EpisodeScreenshotUrl = newEpisode.EpisodeScreenshotUrl;
                }

                if (string.IsNullOrEmpty(episode.EpisodeScreenshotPath) &&
                    string.IsNullOrEmpty(episode.EpisodeScreenshotUrl))
                {
                    episode.EpisodeScreenshotUrl = newEpisode.EpisodeScreenshotUrl;
                }
            }
        }
示例#23
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Saves the season.
        /// </summary>
        /// <param name="season">The season.</param>
        /// <param name="type">The SeasonIOType type.</param>
        public void SaveSeason(Season season, SeasonIOType type)
        {
            if (season.HasEpisodeWithPath())
            {
                string posterTemplate;
                string fanartTemplate;
                string bannerTemplate;

                string firstEpisodePath = season.GetFirstEpisode();

                if (MovieNaming.IsBluRay(firstEpisodePath))
                {
                    posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeasonPosterTemplate;
                    fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeasonFanartTemplate;
                    bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeasonBannerTemplate;
                }
                else if (MovieNaming.IsDVD(firstEpisodePath))
                {
                    posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeasonPosterTemplate;
                    fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeasonFanartTemplate;
                    bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeasonBannerTemplate;
                }
                else
                {
                    posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeasonPosterTemplate;
                    fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeasonFanartTemplate;
                    bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeasonBannerTemplate;
                }

                // Poster
                if (type == SeasonIOType.All || type == SeasonIOType.Poster)
                {
                    if (!string.IsNullOrEmpty(season.PosterUrl) || string.IsNullOrEmpty(season.PosterPath))
                    {
                        string posterPathFrom;

                        if (!string.IsNullOrEmpty(season.PosterPath) && File.Exists(season.PosterPath))
                        {
                            posterPathFrom = season.PosterPath;
                        }
                        else
                        {
                            posterPathFrom = this.TvPathImageGet(season.PosterUrl);
                        }

                        string posterPathTo = GeneratePath.TvSeason(season, posterTemplate, posterPathFrom);

                        this.CopyFile(posterPathFrom, posterPathTo);
                        season.ChangedPoster = false;
                    }
                }

                // Fanart
                if (type == SeasonIOType.All || type == SeasonIOType.Fanart)
                {
                    if (!string.IsNullOrEmpty(season.FanartUrl) || !string.IsNullOrEmpty(season.FanartPath))
                    {
                        string fanartPathFrom;

                        if (!string.IsNullOrEmpty(season.FanartPath) && File.Exists(season.FanartPath))
                        {
                            fanartPathFrom = season.FanartPath;
                        }
                        else
                        {
                            fanartPathFrom = this.TvPathImageGet(season.FanartUrl);
                        }

                        string fanartPathTo = GeneratePath.TvSeason(season, fanartTemplate, fanartPathFrom);

                        this.CopyFile(fanartPathFrom, fanartPathTo);
                        season.ChangedFanart = false;
                    }
                }

                // Banner
                if (type == SeasonIOType.All || type == SeasonIOType.Banner)
                {
                    if (!string.IsNullOrEmpty(season.BannerUrl) || !string.IsNullOrEmpty(season.BannerPath))
                    {
                        string bannerPathFrom;

                        if (!string.IsNullOrEmpty(season.BannerPath) && File.Exists(season.BannerPath))
                        {
                            bannerPathFrom = season.BannerPath;
                        }
                        else
                        {
                            bannerPathFrom = this.TvPathImageGet(season.BannerUrl);
                        }

                        string bannerPathTo = GeneratePath.TvSeason(season, bannerTemplate, bannerPathFrom);

                        this.CopyFile(bannerPathFrom, bannerPathTo);
                        season.ChangedBanner = false;
                    }
                }
            }
        }
示例#24
0
        /// <summary>
        /// The update season.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="newSeason">
        /// The new season.
        /// </param>
        public static void UpdateSeason(Series series, Season newSeason)
        {
            if (!series.Seasons.ContainsKey(newSeason.SeasonNumber))
            {
                series.Seasons.Add(newSeason.SeasonNumber, newSeason);
                return;
            }

            Season season = series.Seasons[newSeason.SeasonNumber];

            if (!season.IsLocked)
            {
                if (string.IsNullOrEmpty(season.BannerPath) && string.IsNullOrEmpty(season.BannerUrl))
                {
                    season.BannerUrl = newSeason.BannerUrl;
                }

                if (string.IsNullOrEmpty(season.FanartPath) && string.IsNullOrEmpty(season.FanartUrl))
                {
                    season.BannerUrl = newSeason.FanartUrl;
                }

                if (string.IsNullOrEmpty(season.PosterPath) && string.IsNullOrEmpty(season.PosterUrl))
                {
                    season.BannerUrl = newSeason.PosterUrl;
                }
            }

            foreach (Episode episode in season.Episodes)
            {
                UpdateEpisode(season, episode);
            }
        }
示例#25
0
        /// <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];
                }

                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];
                }

                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;
                }

                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);
                }
            }
        }
示例#26
0
        public static Series GenerateSeries()
        {
            var series = new Series { SeriesName = NewSeriesModel.NewSeriesName };

            series.Seasons = new SortedList<int, Season>();

            foreach (var seasonText in NewSeriesModel.SeriesList)
            {
                var season = new Season { SeasonNumber = seasonText.GetNumber() };

                var seasonFiles = GetSeasonFiles(seasonText.GetNumber());

                foreach (var file in seasonFiles)
                {
                    var filePath = new MediaModel();

                    filePath.PathAndFilename = file.FilePath;

                    season.Episodes.Add(new Episode {FilePath = filePath, EpisodeNumber = file.EpisodeNumber, EpisodeName = Path.GetFileName(file.FilePath) });
                }

                series.Seasons.Add(seasonText.GetNumber(), season);
            }

            return series;
        }