Beispiel #1
0
        public FileDifferences[] GetDifferences()
        {
            var list = new List <FileDifferences>();

            foreach (var mp3 in _files)
            {
                var mp3Data = mp3.GetId3Data();

                var extracter = new DataExtracter(_mask);
                var tags      = extracter.GetTags();
                var prefixes  = extracter.FindAllPrefixes(tags);
                var diffs     = new FileDifferences(mp3);
                var data      = extracter.GetFullDataFromString(prefixes, Path.GetFileNameWithoutExtension(mp3.FilePath), tags);

                var differenceItems = data.Where(item => mp3Data[item.Key] != item.Value).ToArray();

                if (!differenceItems.Any())
                {
                    continue;
                }

                foreach (var item in differenceItems)
                {
                    diffs.Add(item.Key, new Diff {
                        FileNameValue = item.Value, TagValue = mp3Data[item.Key]
                    });
                }

                list.Add(diffs);
            }

            return(list.ToArray());
        }
Beispiel #2
0
        public static void main(string setting, string extractTo)
        {
            Startup.setting = setting;

            Console.WriteLine("setting: " + setting);
            Console.WriteLine("extract to: " + extractTo);
            Console.WriteLine("");

            DataSource.Init(setting);

            var data_extracter = new DataExtracter("");

            //var aaa = DataProvider.get_data_by_path("Map/Map/Map0/000000000");
            //DataProvider.get_identities("Map/Obj/GachaponHousingTW");

            //return;

            Program.MIXIN_OLD_DATA = false;

            try
            {
                data_extracter.extractAll(extractTo);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            Console.WriteLine("end");
        }
Beispiel #3
0
        public FileDifferences[] GetDifferences()
        {
            var list = new List<FileDifferences>();
            foreach (var mp3 in _files)
            {
                var mp3Data = mp3.GetId3Data();

                var extracter = new DataExtracter(_mask);
                var tags = extracter.GetTags();
                var prefixes = extracter.FindAllPrefixes(tags);
                var diffs = new FileDifferences(mp3);
                var data = extracter.GetFullDataFromString(prefixes, Path.GetFileNameWithoutExtension(mp3.FilePath), tags);

                var differenceItems = data.Where(item => mp3Data[item.Key] != item.Value).ToArray();

                if (!differenceItems.Any()) continue;

                foreach (var item in differenceItems)
                {
                    diffs.Add(item.Key, new Diff { FileNameValue = item.Value, TagValue = mp3Data[item.Key] });
                }

                list.Add(diffs);
            }

            return list.ToArray();
        }
Beispiel #4
0
        public void Test_GetFullDataFromString_DelimiterExpected()
        {
            var extracter = new DataExtracter("{id}{artist} - {title}");
            var tags      = extracter.GetTags();
            var prefixes  = extracter.FindAllPrefixes(tags);

            var data = extracter.GetFullDataFromString(prefixes, "10. test artist - test song name", tags);
        }
Beispiel #5
0
        public Mp3TagChanger(IMp3File mp3File, string mask, ISaver backuper)
        {
            Mp3 = mp3File;

            Backuper = backuper;
            _mask = mask;

            Mp3RealName = Path.GetFileNameWithoutExtension(mp3File.FilePath);
            _dataExtracter = new DataExtracter(_mask);
        }
Beispiel #6
0
        public Mp3TagChanger(IMp3File mp3File, string mask, ISaver backuper)
        {
            Mp3 = mp3File;

            Backuper = backuper;
            _mask    = mask;

            Mp3RealName    = Path.GetFileNameWithoutExtension(mp3File.FilePath);
            _dataExtracter = new DataExtracter(_mask);
        }
        public Mp3FileNameChanger(IMp3File file, string mask, ISaver saver, bool fastChanges = false)
        {
            _mp3File = file;
            Id3Data = new Dictionary<TagType, string>();

            _dataExtracter = new DataExtracter(mask);

            _fastChanges = fastChanges;

            _saver = saver;
            _mask = mask;
        }
Beispiel #8
0
        public Mp3FileNameChanger(IMp3File file, string mask, ISaver saver, bool fastChanges = false)
        {
            _mp3File = file;
            Id3Data  = new Dictionary <TagType, string>();

            _dataExtracter = new DataExtracter(mask);

            _fastChanges = fastChanges;

            _saver = saver;
            _mask  = mask;
        }
Beispiel #9
0
        public void Test_FindAllPrefixes()
        {
            var extracter = new DataExtracter("-this-is-{artist}-prefix-{title}");
            var prefixes  = extracter.FindAllPrefixes(extracter.GetTags());

            var expected = new Queue <string>();

            expected.Enqueue("-this-is-");
            expected.Enqueue("-prefix-");

            CollectionAssert.AreEqual(expected, prefixes);
        }
Beispiel #10
0
        public void Test_NotEnoughData()
        {
            var extracter = new DataExtracter("{id} {artist} - {title}");
            var tags      = extracter.GetTags();
            var prefixes  = extracter.FindAllPrefixes(tags);
            var data      = extracter.GetFullDataFromString(prefixes, "10 art", tags);

            var expected = new Dictionary <TagType, string> {
                { TagType.Id, "10" }, { TagType.Artist, "" }, { TagType.Title, "" }
            };

            CollectionAssert.AreEqual(expected, data);
        }
Beispiel #11
0
        public void Test_FirstPrefix()
        {
            var extracter = new DataExtracter("[{id}] {artist}");
            var tags      = extracter.GetTags();
            var prefixes  = extracter.FindAllPrefixes(tags);
            var data      = extracter.GetFullDataFromString(prefixes, "[10] test artist", tags);

            var expected = new Dictionary <TagType, string> {
                { TagType.Id, "10" }, { TagType.Artist, "test artist" }
            };

            CollectionAssert.AreEqual(expected, data);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("init");
            DataSource.Init(args.Length > 1 ? args[1] : "../../setting.ini");

            var data_extracter = new DataExtracter("");

            Console.WriteLine(DataSource.archives.location);
            Console.WriteLine(DataSource.archives.version);

            Console.WriteLine("start");
            data_extracter.extractAll(args.Length > 0 ? args[0] : "./data");

            Console.WriteLine("end");
        }
Beispiel #13
0
        public void Test_GetTags()
        {
            var extracter = new DataExtracter("{artist}{id}{title}{year}");

            var expected = new Queue <TagType>();

            expected.Enqueue(TagType.Artist);
            expected.Enqueue(TagType.Id);
            expected.Enqueue(TagType.Title);
            expected.Enqueue(TagType.Year);
            var actual = extracter.GetTags();

            Assert.AreEqual(actual.Count, expected.Count);
            for (var i = 0; i < actual.Count; i++)
            {
                var act = actual.Dequeue();
                var exp = expected.Dequeue();
                Assert.AreEqual(act, exp);
            }
        }