コード例 #1
0
ファイル: Duster.cs プロジェクト: terenced/SharpDuster
        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");
        }
コード例 #2
0
ファイル: FileSanitizer.cs プロジェクト: terenced/SharpDuster
        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);
        }
コード例 #3
0
ファイル: Duster.cs プロジェクト: terenced/SharpDuster
 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);
 }
コード例 #4
0
ファイル: FileSanitizer.cs プロジェクト: terenced/SharpDuster
        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;
        }
コード例 #5
0
ファイル: Duster.cs プロジェクト: terenced/SharpDuster
        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");
            }
        }
コード例 #6
0
ファイル: Duster.cs プロジェクト: terenced/SharpDuster
        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");
        }
コード例 #7
0
ファイル: Duster.cs プロジェクト: terenced/SharpDuster
 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;
 }