예제 #1
0
        public static void Main(string[] args)
        {
            //You can user arguments if youd like to
            if (args.Length != 0)
            {
                Console.WriteLine("Loading settings...");

                var dictionary = args.Select(a => a.Split('=')).ToDictionary(a => a[0].ToLower(), a => a.Length == 2 ? a[1].ToLower() : null);

                string apiKey              = dictionary.ContainsKey("apikey") ? dictionary["apiKey"] : Settings.apiKey;
                string directory           = dictionary.ContainsKey("directory") ? dictionary["directory"] : Settings.directory;
                bool   ignoreFilesWithTags = dictionary.ContainsKey("ignorefileswithtags") ? Convert.ToBoolean(dictionary["ignorefileswithtags"]) : Settings.ignoreFilesWithTags;
                int    sleepTime           = dictionary.ContainsKey("sleeptime") ? Convert.ToInt32(dictionary["sleeptime"]) : Settings.sleepTime;

                Settings.Initialize(apiKey, directory, ignoreFilesWithTags, sleepTime);

                LastFMClient fMClient = new LastFMClient(Settings.apiKey);

                var files = Mp3Editor.GetMp3Files(Settings.directory);

                Console.WriteLine($"Searching file in directory: {Settings.directory}");
                Console.WriteLine($"Files found: {files.Count()}");

                var result = Task.Run(() => Mp3Editor.FillTags(fMClient, files));
            }
            else
            {
                Console.WriteLine("args are empty");
            }
        }
예제 #2
0
 public static async Task FillTags(LastFMClient fMClient, IEnumerable <Mp3File> files)
 {
     foreach (var file in files)
     {
         Mp3Tag foundTag = fMClient.GetTrackInfo(file.FilePath);
         SetFileTags(file, foundTag);
         await Task.Delay(Settings.sleepTime);
     }
 }