Ejemplo n.º 1
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);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveSpecificEpisode", exception.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The save all selected episode details.
        /// </summary>
        /// <param name="type">The EpisodeIOType type.</param>
        /// <returns>
        /// Process succeeded
        /// </returns>
        public static bool SaveAllSelectedEpisodeDetails(EpisodeIOType type = EpisodeIOType.All)
        {
            try
            {
                foreach (var episode in TvDBFactory.CurrentSelectedEpisode)
                {
                    SaveSpecificEpisode(episode, type);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveAllSelectedEpisodeDetails", exception.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <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.FileNameAndPath))
            {
                return;
            }

            string nfoTemplate;
            string screenshotTemplate;

            if (MovieNaming.IsDVD(episode.FilePath.FileNameAndPath))
            {
                nfoTemplate        = Get.InOutCollection.CurrentTvSaveSettings.DVDEpisodeNFOTemplate;
                screenshotTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDEpisodeScreenshotTemplate;
            }
            else if (MovieNaming.IsBluRay(episode.FilePath.FileNameAndPath))
            {
                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);

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

            // Screenshot
            if (type == EpisodeIOType.Screenshot || type == EpisodeIOType.All)
            {
                if (!string.IsNullOrEmpty(episode.FilePath.FileNameAndPath))
                {
                    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);

                    this.CopyFile(screenshotPathFrom, screenshotPathTo + ".jpg");
                    episode.ChangedScreenshot = false;
                }
            }
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// The save all selected episode details.
        /// </summary>
        /// <param name="type">The EpisodeIOType type.</param>
        /// <returns>
        /// Process succeeded
        /// </returns>
        public static bool SaveAllSelectedEpisodeDetails(EpisodeIOType type = EpisodeIOType.All)
        {
            try
            {
                foreach (var episode in TvDBFactory.CurrentSelectedEpisode)
                {
                    SaveSpecificEpisode(episode, type);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveAllSelectedEpisodeDetails", exception.Message);
                return false;
            }

            return true;
        }
Ejemplo n.º 6
0
        /// <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;
                }
            }
        }