private static void RenameAndMoveFile(FileInfo file, TvShowFile tvShowFile) { if (file == null) { throw new ArgumentNullException("file"); } if (tvShowFile == null) { throw new ArgumentNullException("tvShowFile"); } try { string dir = FindDestinationFolder(tvShowFile); if (string.IsNullOrWhiteSpace(dir)) { s_Logger.Error("\tFailed - unable to find destionation folder '{0}'", dir); return; } File.Move(file.FullName, string.Format("{0}{1}{2}", dir, Path.DirectorySeparatorChar, tvShowFile.Filename)); } catch (Exception e) { s_Logger.LogException(LogLevel.Error, "", e); return; } s_Logger.Info("\tcleaned and moved"); }
public static TvShowFile Sanitize(string filename) { if (!string.IsNullOrWhiteSpace(filename)) { var show = new TvShowFile { Title = FindTitle(filename) }; if (!string.IsNullOrWhiteSpace(show.Title)) { var info = FindSeasonAndEpisode(filename); if (info == null) { return(null); } show.Season = info.Item1; show.Episode = info.Item2; if (!string.IsNullOrWhiteSpace(show.Info)) { return(show); } } } return(null); }
private static string FindDestinationFolder(TvShowFile show) { if (show != null && !string.IsNullOrWhiteSpace(show.FolderName) && show.Season > 0) { try { string path = Path.Combine(s_destination, show.FolderName); CreatePath(path); string subFolderPath = Path.Combine(path, string.Format("Season {0}", show.Season)); CreatePath(subFolderPath); return(subFolderPath); } catch (Exception e) { s_Logger.LogException(LogLevel.Error, "", e); } } return(null); }
public static TvShowFile Sanitize(string filename) { if (!string.IsNullOrWhiteSpace (filename)) { var show = new TvShowFile { Title = FindTitle (filename) }; if (!string.IsNullOrWhiteSpace (show.Title)) { var info = FindSeasonAndEpisode (filename); if (info == null) return null; show.Season = info.Item1; show.Episode = info.Item2; if (!string.IsNullOrWhiteSpace(show.Info)) { return show; } } } return null; }
private static void DustFile(FileInfo file) { if (file == null) { throw new ArgumentNullException("file"); } s_Logger.Info("Dusting {0}", file.Name); TvShowFile tvShowFile = FileSanitizer.Sanitize(file.Name); if (tvShowFile != null) { tvShowFile.Extension = file.Extension; if (file.Name == tvShowFile.Filename) { s_Logger.Info("\talready clean"); } else { s_Logger.Info("\t{0}", tvShowFile.Filename); } if (s_mode == ExMode.Preview) { s_Logger.Info("\t..."); } else { s_parsedCount++; RenameAndMoveFile(file, tvShowFile); } } else { s_skipCount++; s_Logger.Info("*** Skipping: unable to sanitize"); } }
private static void RenameAndMoveFile(FileInfo file, TvShowFile tvShowFile) { if (file == null) { throw new ArgumentNullException("file"); } if (tvShowFile == null) { throw new ArgumentNullException("tvShowFile"); } try { string dir = FindDestinationFolder(tvShowFile); if (string.IsNullOrWhiteSpace(dir)) { s_Logger.Error("\tFailed - unable to find destionation folder '{0}'", dir); return; } File.Move(file.FullName, string.Format("{0}{1}{2}", dir, Path.DirectorySeparatorChar, tvShowFile.Filename)); } catch (Exception e) { s_Logger.LogException(LogLevel.Error,"",e); return; } s_Logger.Info("\tcleaned and moved"); }
private static string FindDestinationFolder(TvShowFile show) { if (show != null && !string.IsNullOrWhiteSpace(show.FolderName) && show.Season > 0) { try { string path = Path.Combine(s_destination, show.FolderName); CreatePath(path); string subFolderPath = Path.Combine(path, string.Format("Season {0}", show.Season)); CreatePath(subFolderPath); return subFolderPath; } catch (Exception e) { s_Logger.LogException(LogLevel.Error, "", e); } } return null; }