Esempio n. 1
0
        public override void Call()
        {
            if (IsCanceled)
            {
                retag.Redo();
                return;
            }

            var tager = new Tager(new FileLoader());

            if (!tager.Load(Menu.GetUserInput("path:")))
            {
                throw new FileNotFoundException("File does not exist");
            }

            Menu.PrintHelp();
            Menu.PrintCurrentFile(tager.CurrentFile);

            var tags = GetTagsFromFileName(tager.CurrentFile);

            retag = new Retag();
            retag.Call(tags, tager);
            retag.Save();

            Menu.PrintSuccessMessage();
        }
Esempio n. 2
0
 public Analyzer(Tager tager)
 {
     _tager = tager;
     SynchronizedFiles = new List<IMp3File>();
     NotSynchronizedFiles = new Dictionary<IMp3File, string>();
     ErrorFiles = new Dictionary<string, string>();
 }
Esempio n. 3
0
 public Analyzer(Tager tager)
 {
     _tager               = tager;
     SynchronizedFiles    = new List <IMp3File>();
     NotSynchronizedFiles = new Dictionary <IMp3File, string>();
     ErrorFiles           = new Dictionary <string, string>();
 }
Esempio n. 4
0
        public override void Call()
        {
            if (IsCanceled)
            {
                _synchronizer.Redo();
                return;
            }

            var path = Menu.GetUserInput("path:"); //@"C:\Users\Alexandr\Desktop\TEST";
            var tager = new Tager(new FileLoader());
            var analyzer = new Analyzer(tager, s => Path.GetExtension(s).ToLower() == ".mp3");

            Menu.PrintHelp();

            var mask = new Mask(Menu.GetUserInput("mask:"));

            analyzer.Analyze(Directory.GetFiles(path), mask);

            _synchronizer = new Synchronizer(tager,Menu.SelectSyncRule());
            _synchronizer.Sync(analyzer.NotSynchronizedFiles.Keys, mask);

            Menu.PrintChanges(_synchronizer.ModifiedFiles);
            if (Menu.GetYesNoAnswer("Save changes?\nY/N:"))
            {
                _synchronizer.Save();
                Menu.PrintMessage("Successfully");
                Menu.PrintCollection(string.Format("with {0} errors", _synchronizer.ErrorFiles.Count), _synchronizer.ErrorFiles, ConsoleColor.Red);
                Menu.GetUserInput("Press enter...");
            }
        }
Esempio n. 5
0
        public override void Call()
        {
            if (IsCanceled)
            {
                _synchronizer.Redo();
                return;
            }

            var path = Menu.GetUserInput("Load your plan\npath:");
            var planLoader = new PlanProvider();
            var tager = new Tager(new FileLoader());

            _synchronizer = new Synchronizer(tager);
            _synchronizer.Sync(planLoader.Load(path));

            Menu.PrintChanges(_synchronizer.ModifiedFiles);

            if (Menu.GetYesNoAnswer("Save changes?\nY/N:"))
            {
                _synchronizer.Save();

                Menu.PrintMessage("Successfully");
                Menu.PrintCollection(string.Format("with {0} errors", _synchronizer.ErrorFiles.Count), _synchronizer.ErrorFiles, ConsoleColor.Red);
                Menu.GetUserInput("Press enter...");
            }
        }
 public void Init()
 {
     _testMask=new Mask("{artist} {title}");
     _testTager=new Tager(new TestFileLoader());
     _synchronizer=new Synchronizer(_testTager);
     _fileWithBadName=new TestMp3File(){Path = "Artist",Tags = new Mp3Tags(){Artist = "Artist",Title = "Title"}};
     _fileWithBadTags = new TestMp3File() { Path = "Artist Title", Tags = new Mp3Tags() { Artist = "Artist", Title = "" } };
     _fileWithBadTagsAndBadName = new TestMp3File() { Path = "Artist", Tags = new Mp3Tags() { Artist = "Artist", Title = "" } };
 }
Esempio n. 7
0
        public override void Call()
        {
            if (IsCanceled)
            {

                synchronizer.Redo();
                return;
            }

            var path = Menu.GetUserInput("path:");      //@"C:\Users\Alexandr\Desktop\TEST\New folder";
            var tager = new Tager(new FileLoader());
            var analyzer = new Analyzer(tager, s => Path.GetExtension(s).ToLower() == ".mp3");

            Menu.PrintHelp();

            var mask = new Mask(Menu.GetUserInput("mask:"));

            analyzer.Analyze(Directory.GetFiles(path), mask);

            synchronizer = new Synchronizer(tager);

            foreach (var notSynchronizedFile in analyzer.NotSynchronizedFiles)
            {
                Console.Clear();
                Menu.PrintMessage(notSynchronizedFile.Key.Name+" with "+notSynchronizedFile.Value);

                synchronizer.Sync(notSynchronizedFile.Key,mask,Menu.SelectSyncRule());
                Menu.PrintChanges(notSynchronizedFile.Key);

                if (Menu.GetYesNoAnswer("Save changes?\nY/N:"))
                {
                    try
                    {
                        synchronizer.SaveLast();
                        Menu.PrintMessage("Successfully");
                        Menu.GetUserInput("Press enter...");
                    }
                    catch
                    {
                        Menu.PrintError("Can't save file");
                    }

                }
                else
                {
                    synchronizer.RestoreLast();
                }
            }
        }
Esempio n. 8
0
        public override void Call()
        {
            if (IsCanceled)
            {
                rename.Redo();
                return;
            }

            var tager = new Tager(new FileLoader());
                                                           // _tager.Load(@"C:\Users\Alexandr\Desktop\TEST\песня.mp3");
            if (!tager.Load(Menu.GetUserInput("path:")))
            {
                throw new FileNotFoundException("File does not exist");
            }

            Menu.PrintHelp();

            rename = new Rename();
            rename.Call(new Mask(Menu.GetUserInput("mask:")), tager,tager.CurrentFile);
            rename.Save();

            Menu.PrintSuccessMessage();
        }
Esempio n. 9
0
 public Analyzer(Tager tager,Func<string, bool> filter)
     : this(tager)
 {
     _filter = filter;
 }
Esempio n. 10
0
 public void Init()
 {
     _fileLoader = new TestFileLoader();
     _testTager = new Tager(_fileLoader);
     _tesTags = new Mp3Tags() { Album = "Album", Artist = "Artist", Comment = "Comment", Genre = "Genre", Title = "Title", Year = 2015, Track = 1 };
 }
Esempio n. 11
0
 public Analyzer(Tager tager, Func <string, bool> filter) : this(tager)
 {
     _filter = filter;
 }