示例#1
0
        /// <summary>
        /// Process a file rename
        /// </summary>
        /// <param name="pathFrom">
        /// Path from.
        /// </param>
        /// <param name="renameTo">
        /// Rename too.
        /// </param>
        /// <returns>
        /// The remained path.
        /// </returns>
        public static string DoRename(string pathFrom, string renameTo)
        {
            renameTo = FileSystemCharChange.To(renameTo);

            if (MovieNaming.IsBluRay(pathFrom))
            {
                string folderPathFrom = MovieNaming.GetBluRayPath(pathFrom) + MovieNaming.GetBluRayName(pathFrom);
                string folderPathTo   = MovieNaming.GetBluRayPath(pathFrom) + renameTo;

                if (folderPathFrom != folderPathTo)
                {
                    try
                    {
                        Directory.Move(folderPathFrom, folderPathTo);
                        return(folderPathTo);
                    }
                    catch
                    {
                        return(string.Empty);
                    }
                }

                return(folderPathFrom);
            }

            if (MovieNaming.IsDVD(pathFrom))
            {
                string folderPathFrom = MovieNaming.GetDvdPath(pathFrom) + MovieNaming.GetDvdName(pathFrom);
                string folderPathTo   = MovieNaming.GetDvdPath(pathFrom) + renameTo;

                if (folderPathFrom != folderPathTo)
                {
                    try
                    {
                        Directory.Move(folderPathFrom, folderPathTo);
                        return(folderPathTo);
                    }
                    catch
                    {
                        return(string.Empty);
                    }
                }

                return(folderPathFrom);
            }

            string pathTo = Path.GetDirectoryName(pathFrom) + Path.DirectorySeparatorChar + renameTo +
                            Path.GetExtension(pathFrom);

            try
            {
                File.Move(pathFrom, pathTo);
            }
            catch
            {
                return(pathFrom);
            }

            return(pathTo);
        }
示例#2
0
        /// <summary>
        /// Finds the season NFO.
        /// </summary>
        /// <param name="seriesName">Name of the season.</param>
        /// <param name="seasonPath">The season path.</param>
        /// <param name="fileList">The file list.</param>
        /// <returns>
        /// The found nfo.
        /// </returns>
        public static string FindNFO(string seriesName, string seasonPath, string[] fileList = null)
        {
            var find = FindCore(
                seriesName, seasonPath, Get.InOutCollection.NFOTypes, Get.InOutCollection.NfoExtentions, fileList);

            if (!string.IsNullOrEmpty(find))
            {
                return(find);
            }

            seriesName = FileSystemCharChange.To(seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Hex);
            find       = FindCore(seriesName, seasonPath, Get.InOutCollection.NFOTypes, Get.InOutCollection.NfoExtentions, fileList);

            if (!string.IsNullOrEmpty(find))
            {
                return(find);
            }

            seriesName = FileSystemCharChange.To(seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Char);
            find       = FindCore(seriesName, seasonPath, Get.InOutCollection.NFOTypes, Get.InOutCollection.NfoExtentions, fileList);

            if (!string.IsNullOrEmpty(find))
            {
                return(find);
            }

            return(string.Empty);
        }
示例#3
0
        private string GetImageWithParse(string path, string fileName, string stringFormat)
        {
            string hex = FileSystemCharChange.To(
                fileName,
                FileSystemCharChange.ConvertArea.Tv,
                FileSystemCharChange.ConvertType.Hex);

            string schar = FileSystemCharChange.To(
                fileName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Char);

            string seriesNamePlain = string.Format(stringFormat, fileName);
            string seriesNameHex   = string.Format(stringFormat, hex);
            string seriesNameChar  = string.Format(stringFormat, schar);

            string checkPathPlain = Path.Combine(path, seriesNamePlain);
            string checkPathHex   = Path.Combine(path, seriesNameHex);
            string checkPathChar  = Path.Combine(path, seriesNameChar);

            if (File.Exists(checkPathPlain))
            {
                return(checkPathPlain);
            }
            else if (File.Exists(checkPathHex))
            {
                return(checkPathHex);
            }
            else if (File.Exists(checkPathChar))
            {
                return(checkPathChar);
            }

            return(string.Empty);
        }
示例#4
0
        /// <summary>
        /// The change current set poster.
        /// </summary>
        /// <param name="path">The path to process the poster change</param>
        public static void ChangeCurrentSetPoster(string path)
        {
            var newPath = Get.FileSystemPaths.PathMoviesSets + "poster." + FileSystemCharChange.To(GetCurrentSet.SetName, FileSystemCharChange.ConvertArea.Movie) +
                          Path.GetExtension(path);

            File.Copy(path, newPath, true);

            GetCurrentSet.PosterUrl = newPath;

            SetAllMoviesChangedInCurrentSet();
        }
示例#5
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);
        }
示例#6
0
        /// <summary>
        /// Process a file rename
        /// </summary>
        /// <param name="pathFrom">
        /// Path from.
        /// </param>
        /// <param name="renameTo">
        /// Rename too.
        /// </param>
        /// <returns>
        /// The remained path.
        /// </returns>
        public static string DoRename(string pathFrom, string renameTo)
        {
            renameTo = FileSystemCharChange.To(renameTo, FileSystemCharChange.ConvertArea.Tv);

            var fileName = Path.GetFileNameWithoutExtension(pathFrom);
            var filePath = Path.GetDirectoryName(pathFrom);

            // Bluray))
            if (MovieNaming.IsBluRay(pathFrom))
            {
                string folderPathFrom = MovieNaming.GetBluRayPath(pathFrom) + MovieNaming.GetBluRayName(pathFrom);
                string folderPathTo   = MovieNaming.GetBluRayPath(pathFrom) + renameTo;

                if (folderPathFrom != folderPathTo)
                {
                    try
                    {
                        Directory.Move(folderPathFrom, folderPathTo);
                        MasterMediaDBFactory.ChangeTvFileName(folderPathFrom, folderPathTo);
                        return(folderPathTo);
                    }
                    catch
                    {
                        return(string.Empty);
                    }
                }

                return(folderPathFrom);
            }

            // DVD
            if (MovieNaming.IsDVD(pathFrom))
            {
                string folderPathFrom = MovieNaming.GetDvdPath(pathFrom) + MovieNaming.GetDvdName(pathFrom);
                string folderPathTo   = MovieNaming.GetDvdPath(pathFrom) + renameTo;

                if (folderPathFrom != folderPathTo)
                {
                    try
                    {
                        Directory.Move(folderPathFrom, folderPathTo);
                        MasterMediaDBFactory.ChangeTvFileName(folderPathFrom, folderPathTo);
                        return(folderPathTo);
                    }
                    catch
                    {
                        return(string.Empty);
                    }
                }

                return(folderPathFrom);
            }


            // File
            string pathTo = Path.GetDirectoryName(pathFrom) + Path.DirectorySeparatorChar + renameTo +
                            Path.GetExtension(pathFrom);

            foreach (var subExt in Get.InOutCollection.SubtitleExtentions)
            {
                var possibleFileName = filePath + Path.DirectorySeparatorChar + fileName + "." + subExt;

                if (File.Exists(possibleFileName))
                {
                    try
                    {
                        File.Move(possibleFileName, filePath + Path.DirectorySeparatorChar + renameTo + "." + subExt);
                    }
                    catch
                    {
                        Log.WriteToLog(LogSeverity.Error, 0, "Could not rename", possibleFileName + " -> " + filePath + Path.DirectorySeparatorChar + renameTo + subExt);
                    }
                }
            }

            try
            {
                File.Move(pathFrom, pathTo);
                MasterMediaDBFactory.ChangeTvFileName(pathFrom, pathTo);
            }
            catch
            {
                return(pathFrom);
            }

            return(pathTo);
        }
示例#7
0
        /// <summary>
        /// The scan for set images.
        /// </summary>
        public static void ScanForSetImages()
        {
            foreach (MovieSetModel set in database)
            {
                bool posterFound = false;
                bool fanartFound = false;

                foreach (MovieSetObjectModel movie in set.Movies)
                {
                    if (movie.GetMovieModel() != null)
                    {
                        string posterPath = movie.GetMovieModel().GetBaseFilePath + "Set_" + FileSystemCharChange.To(set.SetName, FileSystemCharChange.ConvertArea.Movie) + "_1.jpg";

                        string fanartPath = movie.GetMovieModel().GetBaseFilePath + "Set_" + FileSystemCharChange.To(set.SetName, FileSystemCharChange.ConvertArea.Movie) +
                                            "_1.fanart.jpg";

                        if (File.Exists(posterPath))
                        {
                            string newPosterPath = Get.FileSystemPaths.PathMoviesSets + "poster." + FileSystemCharChange.To(set.SetName, FileSystemCharChange.ConvertArea.Movie) +
                                                   Path.GetExtension(posterPath);
                            File.Copy(posterPath, newPosterPath, true);
                            set.PosterUrl = newPosterPath;
                            posterFound   = true;
                        }

                        if (File.Exists(fanartPath))
                        {
                            string newFanartPath = Get.FileSystemPaths.PathMoviesSets + "fanart." + FileSystemCharChange.To(set.SetName, FileSystemCharChange.ConvertArea.Movie) +
                                                   Path.GetExtension(fanartPath);
                            File.Copy(fanartPath, newFanartPath, true);
                            set.FanartUrl = newFanartPath;
                            fanartFound   = true;
                        }

                        if (posterFound && fanartFound)
                        {
                            break;
                        }
                    }
                }
            }

            InvokeCurrentSetChanged(new EventArgs());
        }
示例#8
0
        /// <summary>
        /// Gets the episode details.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <returns>The episode details.</returns>
        public static EpisodeDetails GetEpisodeDetails(string filePath)
        {
            string logCategory = "ImportTvFactory > GetEpisodeDetails";

            var episodeDetails = new EpisodeDetails
            {
                FilePath = filePath
            };

            string series;

            if (MovieNaming.IsDVD(filePath))
            {
                series = MovieNaming.GetDvdName(filePath);
            }
            else if (MovieNaming.IsBluRay(filePath))
            {
                series = MovieNaming.GetBluRayName(filePath);
            }
            else
            {
                series = Path.GetFileNameWithoutExtension(filePath);
            }

            InternalApps.Logs.Log.WriteToLog(
                LogSeverity.Debug, 0, string.Format("Getting episode details for: {0}", series), logCategory);

            // Check if dir structure is <root>/<series>/<season>/<episodes>
            string dir         = Directory.GetParent(filePath).Name;
            string seriesGuess = string.Empty;

            if (dir.StartsWith("season", true, System.Globalization.CultureInfo.CurrentCulture))
            {
                // Looks like it. Qualified series guess
                seriesGuess = Directory.GetParent(filePath).Parent.Name;
            }

            InternalApps.Logs.Log.WriteToLog(
                LogSeverity.Debug,
                0,
                string.Format("Qualified series name guess, based on folder: {0}", seriesGuess),
                logCategory);

            var regex = Regex.Match(
                series,
                "(?<seriesName>.*?)" + DefaultRegex.Tv,
                RegexOptions.IgnoreCase);

            string rawSeriesName;

            if (regex.Success)
            {
                rawSeriesName = regex.Groups["seriesName"].Value.Trim();
                InternalApps.Logs.Log.WriteToLog(
                    LogSeverity.Debug, 0, string.Format("Series name from file: {0}", rawSeriesName), logCategory);

                var result = (from r in ScanSeriesPicks where r.SearchString == rawSeriesName select r)
                             .SingleOrDefault();

                string rawSeriesGuess = rawSeriesName.Replace(new string[] { ".", "_", "-" }, " ").Trim();

                if (seriesGuess != string.Empty)
                {
                    if (rawSeriesName == string.Empty)
                    {
                        // Anything's better than nothing
                        rawSeriesName = seriesGuess;
                    }
                    else if (rawSeriesName.StartsWith(seriesGuess))
                    {
                        // Regex might've picked up some random crap between series name and s01e01
                        rawSeriesName = seriesGuess;
                    }
                    else if (rawSeriesName.Length > 0 && (rawSeriesName.Substring(0, 1) == seriesGuess.Substring(0, 1) ||
                                                          rawSeriesGuess.ToLower().Replace("and", "&") == seriesGuess.ToLower().Replace("and", "&")))
                    {
                        // Regex might've picked up an acronym for the series
                        // TGaaG = Two Guys and a Girl
                        if (result == null)
                        {
                            rawSeriesName = seriesGuess;
                        }
                    }
                }
                else
                {
                    rawSeriesName = rawSeriesGuess;
                }

                InternalApps.Logs.Log.WriteToLog(
                    LogSeverity.Debug, 0, string.Format("Best series guess: {0}", rawSeriesName), logCategory);

                episodeDetails.SeriesName = result != null ? result.SeriesName : rawSeriesName;

                episodeDetails.SeriesName = FileSystemCharChange.From(episodeDetails.SeriesName, FileSystemCharChange.ConvertArea.Tv);
            }

            var seasonMatch = Regex.Match(series, DefaultRegex.TvSeason, RegexOptions.IgnoreCase);

            if (seasonMatch.Success)
            {
                episodeDetails.SeasonNumber = seasonMatch.Groups[1].Value.GetNumber();
            }

            InternalApps.Logs.Log.WriteToLog(
                LogSeverity.Debug,
                0,
                string.Format("Extracted season number: {0}", episodeDetails.SeasonNumber),
                logCategory);

            var episodeMatch = Regex.Matches(series, DefaultRegex.TvEpisode, RegexOptions.IgnoreCase);

            if (episodeMatch.Count > 0)
            {
                episodeDetails.TvMatchSuccess = true;
                if (episodeMatch.Count > 1)
                {
                    bool first = true;
                    foreach (Match match in episodeMatch)
                    {
                        if (first)
                        {
                            episodeDetails.EpisodeNumber = match.Value.GetNumber();
                            first = false;
                        }
                        else
                        {
                            episodeDetails.SecondaryNumbers.Add(match.Value.GetNumber());
                        }
                    }

                    InternalApps.Logs.Log.WriteToLog(
                        LogSeverity.Debug,
                        0,
                        string.Format(
                            "Extracted episode numbers ({0}): {1}",
                            episodeDetails.SecondaryNumbers.Count,
                            string.Join(", ", episodeDetails.SecondaryNumbers)),
                        logCategory);
                }
                else
                {
                    var episodeMatch2 = Regex.Match(series, DefaultRegex.TvEpisode, RegexOptions.IgnoreCase);
                    episodeDetails.EpisodeNumber = episodeMatch2.Groups[1].Value.GetNumber();

                    InternalApps.Logs.Log.WriteToLog(
                        LogSeverity.Debug,
                        0,
                        string.Format("Extracted episode number: {0}", episodeDetails.EpisodeNumber),
                        logCategory);
                }
            }

            episodeDetails.SeriesName = episodeDetails.SeriesName.Replace(".", string.Empty).Trim();
            if (episodeDetails.SeriesName.EndsWith("-"))
            {
                episodeDetails.SeriesName = episodeDetails.SeriesName.TrimEnd('-').Trim();
            }

            var check =
                (from s in ScanSeriesPicks where s.SearchString == episodeDetails.SeriesName select s).SingleOrDefault();

            if (check != null)
            {
                episodeDetails.SeriesName = check.SeriesName;
            }

            InternalApps.Logs.Log.WriteToLog(
                LogSeverity.Debug, 0, string.Format("Final series name: {0}", episodeDetails.SeriesName), logCategory);

            return(episodeDetails);
        }
示例#9
0
        /// <summary>
        /// Saves the movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        public void SaveMovie(MovieModel movieModel)
        {
            string actualTrailerFileName    = string.Empty;
            string actualTrailerFileNameExt = string.Empty;
            string actualFilePath           = movieModel.AssociatedFiles.Media[0].FolderPath + "\\";
            string actualFileName           = movieModel.AssociatedFiles.Media[0].FilenameWithOutExt;
            string currentTrailerUrl        = movieModel.CurrentTrailerUrl;

            MovieSaveSettings movieSaveSettings = Get.InOutCollection.CurrentMovieSaveSettings;

            string nfoPath = string.IsNullOrEmpty(movieSaveSettings.NfoPath)
                                 ? actualFilePath
                                 : movieSaveSettings.NfoPath;

            var posterPathFrom = string.Empty;

            posterPathFrom = string.IsNullOrEmpty(movieModel.PosterPathOnDisk)
                             ? Downloader.ProcessDownload(
                movieModel.CurrentPosterImageUrl, DownloadType.Binary, Section.Movies)
                             : movieModel.PosterPathOnDisk;

            string fanartPathFrom = string.Empty;

            fanartPathFrom = string.IsNullOrEmpty(movieModel.FanartPathOnDisk)
                                 ? Downloader.ProcessDownload(
                movieModel.CurrentFanartImageUrl, DownloadType.Binary, Section.Movies)
                                 : movieModel.FanartPathOnDisk;

            string trailerPathFrom = Downloader.ProcessDownload(
                movieModel.CurrentTrailerUrl, DownloadType.AppleBinary, Section.Movies);

            string nfoXml = GenerateOutput.GenerateMovieOutput(movieModel);

            string nfoTemplate;
            string posterTemplate;
            string fanartTemplate;
            string trailerTemplate;
            string setPosterTemplate;
            string setFanartTemplate;

            if (MovieNaming.IsDVD(movieModel.GetBaseFilePath))
            {
                actualFilePath = MovieNaming.GetDvdPath(movieModel.GetBaseFilePath);
                actualFileName = MovieNaming.GetDvdName(movieModel.GetBaseFilePath);

                nfoTemplate       = movieSaveSettings.DvdNfoNameTemplate;
                posterTemplate    = movieSaveSettings.DvdPosterNameTemplate;
                fanartTemplate    = movieSaveSettings.DvdFanartNameTemplate;
                trailerTemplate   = movieSaveSettings.DvdTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.DvdSetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.DvdSetFanartNameTemplate;
            }
            else if (MovieNaming.IsBluRay(movieModel.GetBaseFilePath))
            {
                actualFilePath = MovieNaming.GetBluRayPath(movieModel.GetBaseFilePath);
                actualFileName = MovieNaming.GetBluRayName(movieModel.GetBaseFilePath);

                nfoTemplate       = movieSaveSettings.BlurayNfoNameTemplate;
                posterTemplate    = movieSaveSettings.BlurayPosterNameTemplate;
                fanartTemplate    = movieSaveSettings.BlurayFanartNameTemplate;
                trailerTemplate   = movieSaveSettings.BlurayTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.BluraySetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.BluraySetFanartNameTemplate;
            }
            else
            {
                nfoTemplate       = movieSaveSettings.NormalNfoNameTemplate;
                posterTemplate    = movieSaveSettings.NormalPosterNameTemplate;
                fanartTemplate    = movieSaveSettings.NormalFanartNameTemplate;
                trailerTemplate   = movieSaveSettings.NormalTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.NormalSetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.NormalSetFanartNameTemplate;
            }

            if (!string.IsNullOrEmpty(currentTrailerUrl))
            {
                actualTrailerFileName = currentTrailerUrl.Substring(
                    currentTrailerUrl.LastIndexOf('/') + 1,
                    currentTrailerUrl.LastIndexOf('.') - currentTrailerUrl.LastIndexOf('/') - 1);

                actualTrailerFileNameExt = currentTrailerUrl.Substring(currentTrailerUrl.LastIndexOf('.') + 1);
            }

            string nfoOutputName = nfoTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName);

            string posterOutputName =
                posterTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<ext>", "jpg");

            string fanartOutputName =
                fanartTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<ext>", "jpg");

            string trailerOutputName =
                trailerTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<trailername>", actualTrailerFileName).Replace("<ext>", actualTrailerFileNameExt);

            string setPosterOutputPath = setPosterTemplate.Replace("<path>", actualFilePath).Replace(
                "<filename>", actualFileName);

            string setFanartOutputPath = setFanartTemplate.Replace("<path>", actualFilePath).Replace(
                "<filename>", actualFileName);

            // Handle Set Images
            List <string> sets = MovieSetManager.GetSetsContainingMovie(movieModel);

            if (sets.Count > 0)
            {
                foreach (string setName in sets)
                {
                    MovieSetModel set = MovieSetManager.GetSet(setName);

                    MovieSetObjectModel setObjectModel =
                        (from s in set.Movies where s.MovieUniqueId == movieModel.MovieUniqueId select s).
                        SingleOrDefault();

                    string currentSetPosterPath = setPosterOutputPath.Replace("<setname>", FileSystemCharChange.To(setName, FileSystemCharChange.ConvertArea.Movie)).Replace(
                        "<ext>", "jpg");

                    string currentSetFanartPath = setFanartOutputPath.Replace("<setname>", FileSystemCharChange.To(setName, FileSystemCharChange.ConvertArea.Movie)).Replace(
                        "<ext>", "jpg");

                    if (setObjectModel.Order == 1)
                    {
                        if (File.Exists(set.PosterUrl))
                        {
                            File.Copy(set.PosterUrl, currentSetPosterPath, true);
                        }

                        if (File.Exists(set.FanartUrl))
                        {
                            File.Copy(set.FanartUrl, currentSetFanartPath, true);
                        }
                    }
                    else
                    {
                        if (File.Exists(set.PosterUrl) && File.Exists(currentSetPosterPath))
                        {
                            File.Delete(currentSetPosterPath);
                        }

                        if (File.Exists(set.FanartUrl) && File.Exists(currentSetFanartPath))
                        {
                            File.Delete(currentSetFanartPath);
                        }
                    }
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Nfo)
            {
                try
                {
                    this.WriteNFO(nfoXml, nfoOutputName);
                    movieModel.ChangedText = false;
                    Log.WriteToLog(
                        LogSeverity.Info, 0, "NFO Saved To Disk for " + movieModel.Title, nfoPath + nfoOutputName);
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving NFO Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Poster ||
                movieSaveSettings.IoType == MovieIOType.Images)
            {
                try
                {
                    if (!string.IsNullOrEmpty(posterPathFrom))
                    {
                        this.CopyFile(posterPathFrom, posterOutputName);
                        movieModel.ChangedPoster = false;
                        Log.WriteToLog(
                            LogSeverity.Info,
                            0,
                            "Poster Saved To Disk for " + movieModel.Title,
                            posterPathFrom + " -> " + posterOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Poster Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Fanart ||
                movieSaveSettings.IoType == MovieIOType.Images)
            {
                try
                {
                    if (!string.IsNullOrEmpty(fanartPathFrom))
                    {
                        this.CopyFile(fanartPathFrom, fanartOutputName);
                        movieModel.ChangedFanart = false;
                        Log.WriteToLog(
                            LogSeverity.Info,
                            0,
                            "Fanart Saved To Disk for " + movieModel.Title,
                            fanartPathFrom + " -> " + fanartOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Fanart Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Trailer)
            {
                try
                {
                    if (!string.IsNullOrEmpty(movieModel.CurrentTrailerUrl))
                    {
                        this.CopyFile(trailerPathFrom, trailerOutputName);
                        movieModel.ChangedTrailer = false;
                        Log.WriteToLog(
                            LogSeverity.Info,
                            0,
                            "Trailer Saved To Disk for " + movieModel.Title,
                            trailerPathFrom + " -> " + trailerOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Trailer Failed for " + movieModel.Title, ex.Message);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Loads the series.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <returns>
        /// Loaded succeeded
        /// </returns>
        public bool LoadSeries(Series series)
        {
            string seriesName = series.SeriesName;
            string seriesPath = series.GetSeriesPath();

            if (!string.IsNullOrEmpty(seriesName) || !string.IsNullOrEmpty(seriesPath))
            {
                var seriesNameHex = "Set_"
                                    +
                                    FileSystemCharChange.To(
                    seriesName,
                    FileSystemCharChange.ConvertArea.Tv,
                    FileSystemCharChange.ConvertType.Hex) + "_1";

                var seriesNameChar = "Set_"
                                     +
                                     FileSystemCharChange.To(
                    seriesName,
                    FileSystemCharChange.ConvertArea.Tv,
                    FileSystemCharChange.ConvertType.Char) + "_1";

                string nfo = Find.FindNFO("Set_" + seriesName + "_1", seriesPath);

                if (string.IsNullOrEmpty(nfo))
                {
                    nfo = Find.FindNFO(seriesNameHex, seriesPath);

                    if (string.IsNullOrEmpty(nfo))
                    {
                        nfo = Find.FindNFO(seriesNameChar, seriesPath);

                        if (!string.IsNullOrEmpty(nfo))
                        {
                            XmlDocument doc = XRead.OpenPath(nfo);

                            series.SeriesName    = XRead.GetString(doc, "title");
                            series.SeriesID      = XRead.GetUInt(doc, "id");
                            series.Rating        = XRead.GetDouble(doc, "rating");
                            series.Overview      = XRead.GetString(doc, "plot");
                            series.ContentRating = XRead.GetString(doc, "certification");
                            series.Genre         = XRead.GetStrings(doc, "genre").ToBindingList();
                            series.FirstAired    = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd");
                            series.Network       = XRead.GetString(doc, "country");

                            if (doc.GetElementsByTagName("actor").Count > 0)
                            {
                                series.Actors = 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, imageurl, role);

                                    series.Actors.Add(personModel);
                                }
                            }
                        }
                    }
                }
            }

            foreach (var season in series.Seasons)
            {
                foreach (var episode in season.Value.Episodes)
                {
                    if (File.Exists(episode.FilePath.PathAndFilename))
                    {
                        var nfoPath = Path.Combine(
                            episode.FilePath.FolderPath, episode.FilePath.FilenameWithOutExt + ".nfo");

                        if (File.Exists(nfoPath))
                        {
                            var doc = XRead.OpenPath(nfoPath);

                            episode.SeasonNumber  = XRead.GetInt(doc, "season");
                            episode.EpisodeNumber = XRead.GetInt(doc, "episode");
                            episode.EpisodeName   = XRead.GetString(doc, "title");
                            episode.Overview      = XRead.GetString(doc, "plot");
                            episode.FirstAired    = XRead.GetDateTime(doc, "aired");
                        }
                    }
                }
            }

            return(true);
        }