Beispiel #1
0
        /// <summary>
        /// Do series replace.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The do series replace.
        /// </returns>
        public string DoSeriesReplace(Series series, string value)
        {
            string firstEpisodeFileNamePath = series.GetFirstEpisode();
            string firstEpisodePath = Path.GetDirectoryName(firstEpisodeFileNamePath);
            string firstEpisodeFileNameNoExt = Path.GetFileNameWithoutExtension(firstEpisodeFileNamePath);

            string seriesName = FileSystemCharChange.To(series.SeriesName);

            value = value.Replace("<firstEpisodePath>", firstEpisodePath);
            value = value.Replace("<seriesName>", seriesName);
            value = value.Replace(
                "<firstEpisodeOfSeason>", firstEpisodePath + Path.DirectorySeparatorChar + firstEpisodeFileNameNoExt);

            return value;
        }
Beispiel #2
0
        /// <summary>
        /// Gets the series NFO.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series NFO path
        /// </returns>
        public string GetSeriesNFO(Series series)
        {
            string firstEpisode = series.GetFirstEpisode();

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

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

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

            return string.Empty;
        }
Beispiel #3
0
        public string GetSeriesImage(Series series, string stringFormat)
        {
            string firstEpisode = series.GetFirstEpisode();

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

            var path = Path.GetDirectoryName(firstEpisode);
            var fileName = series.SeriesName.Trim();

            return this.GetImageWithParse(path, fileName, stringFormat);
        }
Beispiel #4
0
        /// <summary>
        /// Saves the series.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <param name="type">The SeriesIOType type.</param>
        public void SaveSeries(Series series, SeriesIOType type)
        {
            string path = series.GetSeriesPath();
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            string nfoTemplate;
            string posterTemplate;
            string fanartTemplate;
            string bannerTemplate;

            string firstEpisodePath = series.GetFirstEpisode();

            if (Get.InOutCollection.RenameTV)
            {
                TvRenamerFactory.RenameSeries(series);
            }

            if (MovieNaming.IsBluRay(firstEpisodePath))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesBannerTemplate;
            }
            else if (MovieNaming.IsDVD(firstEpisodePath))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesBannerTemplate;
            }
            else
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesBannerTemplate;
            }

            if (type == SeriesIOType.All || type == SeriesIOType.Nfo)
            {
                // Nfo
                string nfoPathTo = GeneratePath.TvSeries(series, nfoTemplate, string.Empty);

                this.WriteNFO(this.GenerateSeriesOutput(series), nfoPathTo);
                series.ChangedText = false;
            }

            // Poster
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Poster)
            {
                if (!string.IsNullOrEmpty(series.PosterUrl) || !string.IsNullOrEmpty(series.PosterPath))
                {
                    string posterPathFrom;

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

                    string posterPathTo = GeneratePath.TvSeries(series, posterTemplate, posterPathFrom);

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

            // Fanart
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Fanart)
            {
                if (!string.IsNullOrEmpty(series.FanartUrl) || !string.IsNullOrEmpty(series.FanartPath))
                {
                    string fanartPathFrom;

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

                    string fanartPathTo = GeneratePath.TvSeries(series, fanartTemplate, fanartPathFrom);

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

            // Banner
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Banner)
            {
                if (!string.IsNullOrEmpty(series.SeriesBannerUrl) || !string.IsNullOrEmpty(series.SeriesBannerPath))
                {
                    string bannerPathFrom;

                    if (!string.IsNullOrEmpty(series.SeriesBannerPath) && File.Exists(series.SeriesBannerPath))
                    {
                        bannerPathFrom = series.SeriesBannerPath;
                    }
                    else
                    {
                        bannerPathFrom = this.TvPathImageGet(series.SeriesBannerUrl);
                    }

                    string bannerPathTo = GeneratePath.TvSeries(series, bannerTemplate, bannerPathFrom);

                    this.CopyFile(bannerPathFrom, bannerPathTo);
                    series.ChangedBanner = false;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets the series poster.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series poster path
        /// </returns>
        public string GetSeriesPoster(Series series)
        {
            string firstEpisode = series.GetFirstEpisode();

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

            string path = Path.GetDirectoryName(firstEpisode);
            string seriesName = string.Format("Set_{0}_1", series.SeriesName.Trim());

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

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

            return string.Empty;
        }