示例#1
0
 /// <summary>
 /// The replace show.
 /// </summary>
 /// <param name="episode">The episode.</param>
 /// <param name="notCatagorized">The not catagorized.</param>
 private void ReplaceShow(Episode episode, ScanNotCatagorized notCatagorized)
 {
     episode.FilePath.PathAndFilename = notCatagorized.FilePath;
     ImportTvFactory.NotCatagorized.Remove(notCatagorized);
     this.grdViewEpisodes.RefreshData();
     this.lblStatus.Text = string.Format("{0} set to {1}", notCatagorized.FilePath, episode.EpisodeName);
 }
示例#2
0
        /// <summary>
        /// The save specific episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="type">The EpisodeIOType type.</param>
        /// <returns>
        /// Process succeeded
        /// </returns>
        public static bool SaveSpecificEpisode(Episode episode, EpisodeIOType type = EpisodeIOType.All)
        {
            try
            {
                if (Get.InOutCollection.IoType == NFOType.YAMJ)
                {
                    yamj.SaveEpisode(episode, type);
                }
                else if (Get.InOutCollection.IoType == NFOType.XBMC)
                {
                    xbmc.SaveEpisode(episode, type);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveSpecificEpisode", exception.Message);
                return false;
            }

            return true;
        }
示例#3
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Loads the episode.
 /// </summary>
 /// <param name="episode">The episode.</param>
 /// <returns>
 /// Episode Object
 /// </returns>
 public bool LoadEpisode(Episode episode)
 {
     throw new NotImplementedException();
 }
示例#4
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
 /// <summary>
 /// Gets the episode screenshot.
 /// </summary>
 /// <param name="episode">The episode.</param>
 /// <returns>
 /// Episode Screenshot path
 /// </returns>
 public string GetEpisodeScreenshot(Episode episode)
 {
     return this.GetEpisodeImage(episode, "{0}.videoimage.jpg");
 }
示例#5
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Generates the single episode output.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="writeDocumentTags">if set to <c>true</c> [write document tags].</param>
        /// <returns>
        /// Episode Output
        /// </returns>
        public string GenerateSingleEpisodeOutput(Episode episode, bool writeDocumentTags)
        {
            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    if (writeDocumentTags)
                    {
                        this.XmlWriterStart(xmlWriter);
                    }

                    xmlWriter.WriteStartElement("episodedetails");

                    // Season
                    int? sn = episode.SeasonNumber;
                    if (sn == null || sn < 0)
                        sn = 0;
                    XWrite.WriteEnclosedElement(xmlWriter, "season", sn);

                    // Episode
                    XWrite.WriteEnclosedElement(xmlWriter, "episode", episode.EpisodeNumber);

                    // Title
                    XWrite.WriteEnclosedElement(xmlWriter, "title", episode.EpisodeName);

                    // Plot
                    XWrite.WriteEnclosedElement(xmlWriter, "plot", episode.Overview);

                    XWrite.WriteEnclosedElement(xmlWriter, "aired", episode.FirstAired);

                    XWrite.WriteEnclosedElement(xmlWriter, "fileinfo", "template");

                    xmlWriter.WriteEndElement();

                    if (writeDocumentTags)
                    {
                        xmlWriter.WriteEndDocument();
                    }

                }

                return stringWriter.ToString().Replace("<fileinfo>template</fileinfo>", this.GetFileInfo(episode: episode));
            }
        }
示例#6
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();
        }
示例#7
0
        /// <summary>
        /// Get episode super tip.
        /// </summary>
        /// <param name="episode">
        /// The episode.
        /// </param>
        /// <returns>
        /// Return episode super tool tip
        /// </returns>
        public static SuperToolTip GetEpisodeSuperTip(Episode episode)
        {
            if (episode == null)
            {
                return new SuperToolTip();
            }

            var superTip = new SuperToolTip();

            superTip.Items.AddTitle(episode.EpisodeName);

            if (!string.IsNullOrEmpty(episode.EpisodeScreenshotUrl))
            {
                string url = GetImageUrl(episode.EpisodeScreenshotUrl);
                string urlCache = WebCache.GetPathFromUrl(url, Section.Tv);

                if (File.Exists(urlCache) && !Downloader.Downloading.Contains(url))
                {
                    try
                    {
                        Image episodePathImage = ImageHandler.LoadImage(urlCache);
                        var smallBanner = new ToolTipTitleItem
                            {
                               Image = ImageHandler.ResizeImage(episodePathImage, 150, 90) 
                            };

                        superTip.Items.Add(smallBanner);
                    }
                    catch
                    {
                        Log.WriteToLog(LogSeverity.Error, 0, "Could not load banner", urlCache);
                    }
                }
            }

            return superTip;
        }
示例#8
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;
                }
            }
        }
示例#9
0
 public static void UnlockEpisode(Episode episode)
 {
     episode.IsLocked = false;
 }
示例#10
0
 public static void LockEpisode(Episode episode)
 {
     episode.IsLocked = true;
 }
示例#11
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;
                }
            }
        }
示例#12
0
文件: XBMC.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Loads the episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <returns>
        /// Episode Object
        /// </returns>
        public bool LoadEpisode(Episode episode)
        {
            string episodeName = episode.EpisodeName;
            string episodePath = episode.FilePath.FolderPath;

            string nfo = Find.FindNFO(episodeName, episodePath);

            if (string.IsNullOrEmpty(nfo))
            {
                return false;
            }

            XmlDocument doc = XRead.OpenPath(nfo);

            episode.SeasonNumber = XRead.GetInt(doc, "season");
            episode.EpisodeNumber = XRead.GetInt(doc, "episode");
            episode.EpisodeName = XRead.GetString(doc, "title");
            episode.Rating = XRead.GetDouble(doc, "rating");
            episode.Overview = XRead.GetString(doc, "plot");
            //episode.PlayCount = XRead.GetInt(doc, "playcount");
            //episode.LastPlayed = XRead.GetString(doc, "lastplayed");
            //episode.Credits = XRead.GetString(doc, "credits");
            List<string> directorList = XRead.GetStrings(doc, "director");
            foreach (string director in directorList)
            {
                episode.Director.Add(new PersonModel(director));
            }
            episode.FirstAired = XRead.GetDateTime(doc, "aired");
            //episode.Premiered = XRead.GetString(doc, "premiered");
            //episode.Studio = XRead.GetString(doc, "studio");
            //episode.Mpaa = XRead.GetString(doc, "mpaa");
            //episode.DisplayEpisode = XRead.GetInt(doc, "displayepisode");


            // Actor
            if (doc.GetElementsByTagName("actor").Count > 0)
            {
                episode.GuestStars = 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);

                    episode.GuestStars.Add(personModel);
                }
            }

            // Load fileinfo

            return true;
        }
示例#13
0
文件: XBMC.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Generates the single episode output.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="writeDocumentTags">if set to <c>true</c> [write document tags].</param>
        /// <returns>
        /// Episode Output
        /// </returns>
        public string GenerateSingleEpisodeOutput(Episode episode, bool writeDocumentTags)
        {
            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    if (writeDocumentTags)
                    {
                        this.XmlWriterStart(xmlWriter);
                    }

                    xmlWriter.WriteStartElement("episodedetails");

                    // Season
                    int? sn = episode.SeasonNumber;
                    if (sn == null || sn < 0)
                        sn = 0;
                    XWrite.WriteEnclosedElement(xmlWriter, "season", sn);

                    // Episode
                    XWrite.WriteEnclosedElement(xmlWriter, "episode", episode.EpisodeNumber);

                    // Title
                    XWrite.WriteEnclosedElement(xmlWriter, "title", episode.EpisodeName);

                    // Rating
                    XWrite.WriteEnclosedElement(xmlWriter, "rating", episode.Rating);

                    // Plot
                    XWrite.WriteEnclosedElement(xmlWriter, "plot", episode.Overview);

                    // Thumb
                    
                    // Playcount
                    //XWrite.WriteEnclosedElement(xmlWriter, "playcount", episode.PlayCount);

                    // Lastplayed
                    //XWrite.WriteEnclosedElement(xmlWriter, "lastplayed", episode.LastPlayed);

                    // Credits
                    //XWrite.WriteEnclosedElement(xmlWriter, "credits", episode.Credits);

                    // Director
                    foreach (PersonModel director in episode.Director)
                    {
                        XWrite.WriteEnclosedElement(xmlWriter, "director", director.Name);
                    }

                    // Aired
                    XWrite.WriteEnclosedElement(xmlWriter, "aired", episode.FirstAired);

                    // Premiered
                    //XWrite.WriteEnclosedElement(xmlWriter, "premiered", episode.Premiered);
                    
                    // Studio
                    //XWrite.WriteEnclosedElement(xmlWriter, "studio", episode.Studio);

                    // Mpaa
                    //XWrite.WriteEnclosedElement(xmlWriter, "mpaa", episode.Mpaa);

                    // Displayepisode: For TV show specials, determines how the episode is sorted in the series
                    //XWrite.WriteEnclosedElement(xmlWriter, "displayepisode", episode.DisplayEpisode);

                    // Actor
                    int count = 1;
                    foreach (PersonModel actor in episode.GuestStars)
                    {
                        count++;

                        xmlWriter.WriteStartElement("actor");

                        string role = actor.Role;
                        if (Get.InOutCollection.CleanActorRoles)
                        {
                            role = Regex.Replace(actor.Role, @"\(as.*?\)", string.Empty).Trim();
                        }

                        XWrite.WriteEnclosedElement(xmlWriter, "name", actor.Name);
                        XWrite.WriteEnclosedElement(xmlWriter, "role", role);
                        XWrite.WriteEnclosedElement(xmlWriter, "thumb", actor.ImageUrl);

                        xmlWriter.WriteEndElement();

                        if (count == 10)
                        {
                            break;
                        }
                    }

                    // Fileinfo
                    XWrite.WriteEnclosedElement(xmlWriter, "fileinfo", "template");

                    xmlWriter.WriteEndElement();

                    if (writeDocumentTags)
                    {
                        xmlWriter.WriteEndDocument();
                    }

                }

                return stringWriter.ToString().Replace("<fileinfo>template</fileinfo>", this.GetFileInfo(episode: episode));
            }
        }
示例#14
0
 /// <summary>
 /// Finds the episodes containing the file in this episode.
 /// </summary>
 /// <param name="episode">The episode.</param>
 /// <returns>List of epides</returns>
 private static List<Episode> GetEpisodesContainingFile(Episode episode)
 {
     return (from e in episode.GetSeason().Episodes
             where e.FilePath.PathAndFilename == episode.FilePath.PathAndFilename
             orderby e.EpisodeNumber
             select e).ToList();
 }
示例#15
0
        /// <summary>
        /// Renames the episode.
        /// </summary>
        /// <param name="episode">
        /// The episode.
        /// </param>
        /// <returns>
        /// The rename episode.
        /// </returns>
        public static string RenameEpisode(Episode episode)
        {
            string seriesName = "";

            string season1 = string.Empty;
            string season2 = string.Empty;

            string episode1 = string.Empty;
            string episode2 = string.Empty;

            string episodeName = string.Empty;

            bool doRename;
            bool dummy = false;
            List<Episode> episodesContaining = new List<Episode>();

            if (episode != null && episode.ProductionCode == "dummy")
            {
                dummy = true;
                seriesName = "Star Trek: Deep Space Nine";
                episode = new Episode
                {
                    
                    EpisodeNumber = 5,
                    EpisodeName = "Cardassians",
                    SeasonNumber = 2
                };
                Episode ep2 = new Episode
                {
                    EpisodeNumber = 6,
                    EpisodeName = "Cardassians2",
                    SeasonNumber = 2
                }; 
                Episode ep3 = new Episode
                {
                    EpisodeNumber = 7,
                    EpisodeName = "Cardassians3",
                    SeasonNumber = 2
                };

                episodesContaining.Add(episode);
                episodesContaining.Add(ep2);
                episodesContaining.Add(ep3);
            }

            if (episode == null)
            {
                seriesName = "Star Trek: Deep Space Nine";

                season1 = "2";
                season2 = "02";
                episode1 = "5";
                episode2 = "05";

                episodeName = "Cardassians";
                doRename = false;
            }
            else
            {
                episode1 = string.Empty;
                episode2 = string.Empty;

                if (seriesName == "")
                {
                    seriesName = episode.GetSeriesName();
                }
                int? seasonNumber = episode.SeasonNumber;

                if (episodesContaining.Count == 0)
                {
                    episodesContaining = GetEpisodesContainingFile(episode);
                }

                season1 = seasonNumber.ToString();
                season2 = string.Format("{0:00}", seasonNumber);

                doRename = false;

                if (episodesContaining.Count == 1)
                {
                    episode1 = episode.EpisodeNumber.ToString();
                    episode2 = string.Format("{0:00}", episode.EpisodeNumber);
                    doRename = true;
                    episodeName = episode.EpisodeName;
                }
                else
                {
                    int count = 0;
                    string multiTemplate = Get.InOutCollection.EpisodeMultiTemplate;
                    multiTemplate = multiTemplate.Replace(EpisodeNumber1Template, "{0}");
                    multiTemplate = multiTemplate.Replace(EpisodeNumber2Template, "{0:00}");

                    foreach (Episode ep in episodesContaining)
                    {
                        if (ep.EpisodeNumber == episode.EpisodeNumber && count == 0)
                        {
                            doRename = true;
                        }

                        episode1 += string.Format(multiTemplate, ep.EpisodeNumber);
                        episode2 += string.Format(multiTemplate, ep.EpisodeNumber);

                        count++;
                    }
                    episodeName = episode.EpisodeName;
                    episodeName = episodeName.TrimEnd();
                }

            }

            string episodeTemplate = Get.InOutCollection.EpisodeNamingTemplate;

            episodeTemplate = episodeTemplate.Replace(SeriesNameTemplate, seriesName);

            episodeTemplate = episodeTemplate.Replace(SeasonNumber1Template, season1);
            episodeTemplate = episodeTemplate.Replace(SeasonNumber2Template, season2);

            if (episodesContaining.Count <= 1)
            {
                episodeTemplate = episodeTemplate.Replace(MultiEpisodeFileTemplate, EpisodeMultiTemplate);
                episodeTemplate = episodeTemplate.Replace(EpisodeNumber1Template, episode1);
                episodeTemplate = episodeTemplate.Replace(EpisodeNumber2Template, episode2);
            }
            else
            {
                if (EpisodeMultiTemplate.Contains(EpisodeNumber1Template))
                {
                    episodeTemplate = episodeTemplate.Replace(MultiEpisodeFileTemplate, episode1);
                }
                else
                {
                    episodeTemplate = episodeTemplate.Replace(MultiEpisodeFileTemplate, episode2);
                }
            }

            episodeTemplate = episodeTemplate.Replace(EpisodeNameTemplate, episodeName);

            if (episode != null)
            {
                if (doRename && !dummy)
                {
                    string newPath = DoRename(episode.FilePath.PathAndFilename, episodeTemplate);

                    if (!string.IsNullOrEmpty(newPath))
                    {
                        string pathAddition;

                        if (MovieNaming.IsBluRay(episode.FilePath.PathAndFilename))
                        {
                            pathAddition =
                                episode.FilePath.PathAndFilename.Replace(
                                    MovieNaming.GetBluRayPath(episode.FilePath.PathAndFilename) +
                                    MovieNaming.GetBluRayName(episode.FilePath.PathAndFilename), 
                                    string.Empty);

                            episode.FilePath.PathAndFilename = newPath + pathAddition;
                            DatabaseIOFactory.SetDatabaseDirty();
                        }
                        else if (MovieNaming.IsDVD(episode.FilePath.PathAndFilename))
                        {
                            pathAddition =
                                episode.FilePath.PathAndFilename.Replace(
                                    MovieNaming.GetDvdPath(episode.FilePath.PathAndFilename) +
                                    MovieNaming.GetDvdName(episode.FilePath.PathAndFilename), 
                                    string.Empty);

                            episode.FilePath.PathAndFilename = newPath + pathAddition;
                            DatabaseIOFactory.SetDatabaseDirty();
                        }
                        else
                        {
                            episode.FilePath.PathAndFilename = newPath;
                            DatabaseIOFactory.SetDatabaseDirty();
                        }
                    }
                }
            }

            return episodeTemplate;
        }
示例#16
0
        /// <summary>
        /// Set current episode by guid
        /// </summary>
        /// <param name="guid">
        /// The guid value
        /// </param>
        public static void SetCurrentEpisode(string guid)
        {
            Episode episode = (from e in CurrentSeason.Episodes where e.Guid == guid select e).SingleOrDefault();

            if (episode != null)
            {
                CurrentEpisode = episode;
                InvokeGalleryEpisodeChanged(new EventArgs());
            }
        }
示例#17
0
 public static void HideEpisode(Episode episode)
 {
     throw new NotImplementedException();
 }
示例#18
0
        /// <summary>
        /// The process episode to background.
        /// </summary>
        /// <param name="episode">
        /// The episode.
        /// </param>
        private static void ProcessEpisodeToBackground(Episode episode)
        {
            if (!string.IsNullOrEmpty(episode.CurrentFilenameAndPath))
            {
                var current = GenerateOutput.AccessCurrentIOHandler() as IoInterface;

                if (current == null)
                {
                    return;
                }

                string path = current.GetEpisodeScreenshot(episode);

                if (string.IsNullOrEmpty(path))
                {
                    var downloadItem = new DownloadItem
                        {
                            Url = TvDBFactory.GetImageUrl(episode.EpisodeScreenshotUrl), 
                            Type = DownloadType.Binary, 
                            Section = Section.Tv
                        };

                    Downloader.AddToBackgroundQue(downloadItem);
                }
                else
                {
                    episode.EpisodeScreenshotPath = path;
                }
            }
        }
示例#19
0
 public static void SetEpisodeWatched(Episode episode)
 {
     episode.Watched = true;
 }
示例#20
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>();
        }
示例#21
0
 public static void SetEpisodeUnwatched(Episode episode)
 {
     episode.Watched = false;
 }
示例#22
0
        public string GetEpisodeImage(Episode episode, string stringFormat)
        {
            if (string.IsNullOrEmpty(episode.FilePath.PathAndFilename))
            {
                return string.Empty;
            }

            return this.GetImageWithParse(episode.FilePath.FolderPath, episode.FilePath.FilenameWithOutExt, stringFormat);
        }
示例#23
0
 public static void OpenEpisodeFile(Episode episode)
 {
     if (File.Exists(episode.FilePath.PathAndFilename))
     {
         Process.Start(episode.FilePath.PathAndFilename);
     }
 }
示例#24
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Gets the episode NFO.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <returns>
        /// Episode NFO path
        /// </returns>
        public string GetEpisodeNFO(Episode episode)
        {
            string fullPath = episode.FilePath.PathAndFilename;

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

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

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

            return string.Empty;
        }
示例#25
0
        public static void OpenEpisodeFolder(Episode episode)
        {
            string argument = string.Format(
                @"/select,""{0}""",
                File.Exists(episode.FilePath.PathAndFilename)
                    ? episode.FilePath.PathAndFilename
                    : episode.FilePath.FolderPath);

            Process.Start("explorer.exe", argument);
        }
示例#26
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
        public string GetFileInfo(MovieModel movie = null, Episode episode = null)
        {
            FileInfoModel fileInfoModel;

            if (movie != null)
            {
                fileInfoModel = movie.FileInfo;
            }
            else if (episode != null)
            {
                fileInfoModel = episode.FileInfo;
            }
            else
            {
                return string.Empty;
            }

            string output;

            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (var xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    XWrite.WriteEnclosedElement(xmlWriter, "videooutput", Get.MediaInfo.DoReplace(fileInfoModel));

                }

                output = stringWriter.ToString() + Environment.NewLine;
            }

            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (var xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    xmlWriter.WriteStartElement("fileinfo");

                    xmlWriter.WriteStartElement("video");

                    // Codec
                    XWrite.WriteEnclosedElement(xmlWriter, "codec", fileInfoModel.Codec);

                    // Aspect
                    XWrite.WriteEnclosedElement(xmlWriter, "aspect", fileInfoModel.AspectRatio);

                    // Width
                    XWrite.WriteEnclosedElement(xmlWriter, "width", fileInfoModel.Width);

                    // Height
                    XWrite.WriteEnclosedElement(xmlWriter, "height", fileInfoModel.Height);

                    xmlWriter.WriteEndElement();

                    foreach (var audioStream in fileInfoModel.AudioStreams)
                    {
                        xmlWriter.WriteStartElement("audio");

                        // Codec
                        XWrite.WriteEnclosedElement(xmlWriter, "codec", audioStream.CodecID);

                        // Language
                        XWrite.WriteEnclosedElement(xmlWriter, "codec", audioStream.Language);

                        // Channels
                        XWrite.WriteEnclosedElement(xmlWriter, "channels", audioStream.Channels);

                        xmlWriter.WriteEndElement();
                    }

                    foreach (var subtitleStream in fileInfoModel.SubtitleStreams)
                    {
                        xmlWriter.WriteStartElement("subtitle");

                        // Codec
                        XWrite.WriteEnclosedElement(xmlWriter, "codec", subtitleStream.Language);

                        xmlWriter.WriteEndElement();
                    }


                    xmlWriter.WriteEndElement();
                }

                return Regex.Replace(output + stringWriter, @"\<\?xml.*?\>", string.Empty)
                    .Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine)
                    .Trim();
            }
        }
示例#27
0
        /// <summary>
        /// Generates the single episode output.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="writeDocumentTags">if set to <c>true</c> [write document tags].</param>
        /// <returns>
        /// Episode Output
        /// </returns>
        public string GenerateSingleEpisodeOutput(Episode episode, bool writeDocumentTags)
        {
            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    if (writeDocumentTags)
                    {
                        this.XmlWriterStart(xmlWriter);
                    }

                    xmlWriter.WriteStartElement("episodedetails");

                    // Season
                    XWrite.WriteEnclosedElement(xmlWriter, "season", episode.SeasonNumber);

                    // Episode
                    XWrite.WriteEnclosedElement(xmlWriter, "episode", episode.EpisodeNumber);

                    // Title
                    XWrite.WriteEnclosedElement(xmlWriter, "title", episode.EpisodeName);

                    // Plot
                    XWrite.WriteEnclosedElement(xmlWriter, "plot", episode.Overview);

                    xmlWriter.WriteEndElement();

                    if (writeDocumentTags)
                    {
                        xmlWriter.WriteEndDocument();
                    }
                }

                return stringWriter.ToString();
            }
        }
示例#28
0
文件: YAMJ.cs 项目: rsanch1/YANFOE.v2
        /// <summary>
        /// Saves the episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="type">The EpisodeIOType type.</param>
        public void SaveEpisode(Episode episode, EpisodeIOType type)
        {
            if (episode.Secondary)
            {
                return;
            }

            if (string.IsNullOrEmpty(episode.FilePath.PathAndFilename))
            {
                return;
            }

            string nfoTemplate;
            string screenshotTemplate;

            if (MovieNaming.IsDVD(episode.FilePath.PathAndFilename))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDEpisodeNFOTemplate;
                screenshotTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDEpisodeScreenshotTemplate;
            }
            else if (MovieNaming.IsBluRay(episode.FilePath.PathAndFilename))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.BlurayEpisodeNFOTemplate;
                screenshotTemplate = Get.InOutCollection.CurrentTvSaveSettings.BlurayEpisodeScreenshotTemplate;
            }
            else
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.EpisodeNFOTemplate;
                screenshotTemplate = Get.InOutCollection.CurrentTvSaveSettings.EpisodeScreenshotTemplate;
            }

            // Nfo
            if (type == EpisodeIOType.All || type == EpisodeIOType.Nfo)
            {
                string nfoPathTo = GeneratePath.TvEpisode(episode, nfoTemplate, string.Empty);

                this.WriteNFO(this.GenerateSingleEpisodeOutput(episode, true), nfoPathTo);
                episode.ChangedText = false;
            }

            // Screenshot
            if (type == EpisodeIOType.Screenshot || type == EpisodeIOType.All)
            {
                if (!string.IsNullOrEmpty(episode.FilePath.PathAndFilename))
                {
                    string screenshotPathFrom;

                    if (!string.IsNullOrEmpty(episode.EpisodeScreenshotPath) &&
                        File.Exists(episode.EpisodeScreenshotPath))
                    {
                        screenshotPathFrom = episode.EpisodeScreenshotPath;
                    }
                    else
                    {
                        screenshotPathFrom = this.TvPathImageGet(episode.EpisodeScreenshotUrl);
                    }

                    string screenshotPathTo = GeneratePath.TvEpisode(episode, screenshotTemplate, screenshotPathFrom);

                    this.CopyFile(screenshotPathFrom, screenshotPathTo);
                    episode.ChangedScreenshot = false;
                }
            }
        }
示例#29
0
        /// <summary>
        /// Gets the episode screenshot.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <returns>
        /// Episode Screenshot path
        /// </returns>
        public string GetEpisodeScreenshot(Episode episode)
        {
            string fullPath = episode.FilePath.FileNameAndPath;

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

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

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

            return string.Empty;
        }
示例#30
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);
                }
            }
        }
示例#31
0
        public static string TvEpisode(Episode episode, string replace, string fromFile, string altEpisode = null)
        {
            if (episode == null)
            {
                episode = new Episode();
                episode.FilePath = new MediaModel { PathAndFilename = @"c:\testshow\season 1\test show.s01e01.avi" };
            }

            string episodePath;
            string episodeFileName;

            if (altEpisode == null)
            {
                altEpisode = episode.CurrentFilenameAndPath;
            }

            if (altEpisode == string.Empty)
            {
                return string.Empty;
            }

            if (MovieNaming.IsDVD(altEpisode))
            {
                episodePath = MovieNaming.GetDvdPath(altEpisode);
                episodeFileName = MovieNaming.GetDvdName(altEpisode);
            }
            else if (MovieNaming.IsBluRay(altEpisode))
            {
                episodePath = MovieNaming.GetBluRayPath(altEpisode);
                episodeFileName = MovieNaming.GetBluRayName(altEpisode);
            }
            else
            {
                episodePath = Path.GetDirectoryName(altEpisode);
                episodeFileName = Path.GetFileNameWithoutExtension(altEpisode);
            }

            replace = replace.Replace(Settings.Get.InOutCollection.TvEpisodePath, episodePath);
            replace = replace.Replace(Settings.Get.InOutCollection.TvEpisodeFileName, episodeFileName);


            return replace + Path.GetExtension(fromFile);
        }