/// <summary> /// Build a MediaPathFileModel /// </summary> /// <param name="path">The file path.</param> /// <param name="type">The MediaPathFileType type.</param> /// <param name="nameBy">The AddFolderType name by.</param> /// <param name="scraperGroup">The scraper Group.</param> /// <param name="defaultSource">The default Source.</param> /// <returns>MediaPathFileModel object</returns> public static MediaPathFileModel Add( string path, MediaPathFileType type, AddFolderType nameBy, string scraperGroup, string defaultSource) { var newMediaPathFileModel = new MediaPathFileModel { PathAndFileName = path, Type = type, MediaPathType = nameBy, ScraperGroup = scraperGroup, DefaultVideoSource = defaultSource }; return(newMediaPathFileModel); }
/// <summary> /// Get the movie name. /// </summary> /// <param name="path"> /// The file path. /// </param> /// <param name="type"> /// The AddFolderType type. /// </param> /// <returns> /// The movie name. /// </returns> public static string GetMovieName(string path, AddFolderType type) { if (path == string.Empty) { return string.Empty; } if (IsDVD(path)) { return GetDvdName(path); } if (IsBluRay(path)) { return GetBluRayName(path); } string movieName = string.Empty; if (type == AddFolderType.NameByFolder) { string[] split = Path.GetDirectoryName(path).Split('\\'); movieName = split[split.Length - 1]; } if (type == AddFolderType.NameByFile) { movieName = Path.GetFileNameWithoutExtension(path); } movieName = RemoveBrackets(movieName); var ignoreList = new List<string>(); ignoreList.AddRange(Get.Keywords.Tags); ignoreList.AddRange(Get.Keywords.IgnoreNames); ignoreList.AddRange(Get.Keywords.Codecs); ignoreList.AddRange(Get.Keywords.Resolutions); ignoreList.AddRange(Get.Keywords.GetSourcesAsList()); movieName = movieName.Replace('[', ' '); movieName = movieName.Replace(']', ' '); movieName = movieName.Replace('_', ' '); movieName = movieName.Replace('.', ' '); string input = movieName; foreach (string keyword in ignoreList) { if (input.ToLower().Contains(" " + keyword + "-")) { Match hmatch = Regex.Match(input, keyword + "-(.*)", RegexOptions.IgnoreCase); input = input.Replace(hmatch.Groups[0].Value, string.Empty); } input = Regex.Replace(input, " " + keyword + " ", " ", RegexOptions.IgnoreCase); if (input.EndsWith(" " + keyword, true, new CultureInfo("en-US"))) { input = input.Substring(0, input.Length - keyword.Length); } } movieName = input; movieName = Regex.Replace(movieName, @"\s{2,}", " "); if (movieName.Length >= 4) { if (movieName.Substring(0, 4) == GetMovieYear(movieName).ToString()) { string yearStore = movieName.Substring(0, 4); string theRest = movieName.Substring(4); string yearResult = GetMovieYear(theRest).ToString(); movieName = Regex.Replace(theRest, yearResult, " "); movieName = yearStore + movieName; } else { movieName = Regex.Replace(movieName, GetMovieYear(movieName).ToString(), string.Empty); movieName = movieName.Replace("()", string.Empty); } } return movieName.Trim(); }
/// <summary> /// Build a MediaPathFileModel /// </summary> /// <param name="path">The file path.</param> /// <param name="type">The MediaPathFileType type.</param> /// <param name="nameBy">The AddFolderType name by.</param> /// <param name="scraperGroup">The scraper Group.</param> /// <param name="defaultSource">The default Source.</param> /// <returns>MediaPathFileModel object</returns> public static MediaPathFileModel Add( string path, MediaPathFileType type, AddFolderType nameBy, string scraperGroup, string defaultSource) { var newMediaPathFileModel = new MediaPathFileModel { PathAndFileName = path, Type = type, MediaPathType = nameBy, ScraperGroup = scraperGroup, DefaultVideoSource = defaultSource }; return newMediaPathFileModel; }
/// <summary> /// Get the movie name. /// </summary> /// <param name="path"> /// The file path. /// </param> /// <param name="type"> /// The AddFolderType type. /// </param> /// <returns> /// The movie name. /// </returns> public static string GetMovieName(string path, AddFolderType type) { if (path == string.Empty) { return(string.Empty); } if (IsDVD(path)) { return(GetDvdName(path)); } if (IsBluRay(path)) { return(GetBluRayName(path)); } string movieName = string.Empty; if (type == AddFolderType.NameByFolder) { string[] split = Path.GetDirectoryName(path).Split('\\'); movieName = split[split.Length - 1]; } if (type == AddFolderType.NameByFile) { movieName = Path.GetFileNameWithoutExtension(path); } movieName = RemoveBrackets(movieName); var ignoreList = new List <string>(); ignoreList.AddRange(Get.Keywords.Tags); ignoreList.AddRange(Get.Keywords.IgnoreNames); ignoreList.AddRange(Get.Keywords.Codecs); ignoreList.AddRange(Get.Keywords.Resolutions); ignoreList.AddRange(Get.Keywords.GetSourcesAsList()); movieName = movieName.Replace('[', ' '); movieName = movieName.Replace(']', ' '); movieName = movieName.Replace('_', ' '); movieName = movieName.Replace('.', ' '); string input = movieName; foreach (string keyword in ignoreList) { if (input.ToLower().Contains(" " + keyword + "-")) { Match hmatch = Regex.Match(input, keyword + "-(.*)", RegexOptions.IgnoreCase); input = input.Replace(hmatch.Groups[0].Value, string.Empty); } input = Regex.Replace(input, " " + keyword + " ", " ", RegexOptions.IgnoreCase); if (input.EndsWith(" " + keyword, true, new CultureInfo("en-US"))) { input = input.Substring(0, input.Length - keyword.Length); } } movieName = input; movieName = Regex.Replace(movieName, @"\s{2,}", " "); if (movieName.Length >= 4) { if (movieName.Substring(0, 4) == GetMovieYear(movieName).ToString()) { string yearStore = movieName.Substring(0, 4); string theRest = movieName.Substring(4); string yearResult = GetMovieYear(theRest).ToString(); movieName = Regex.Replace(theRest, yearResult, " "); movieName = yearStore + movieName; } else { movieName = Regex.Replace(movieName, GetMovieYear(movieName).ToString(), string.Empty); movieName = movieName.Replace("()", string.Empty); } } return(movieName.Trim()); }