Exemplo n.º 1
0
        public void ProcessFiles()
        {
            var files = _folderInteractor.GetFilesForFolder(_folderToWatch).Shuffle();

            foreach (var file in files)
            {
                if (SupportedFileTypes.IsSupportedFileType(file))
                {
                    var filePath = file;
                    if (SupportedFileTypes.RequiresTranscoding(file))
                    {
                        var newFile = _transcoder.Transcode(filePath);
                        _folderInteractor.DeleteFile(filePath);
                        filePath = newFile;
                    }

                    var musicInfo = _musicInfoReader.GetInfoForFile(filePath);
                    var album     = string.IsNullOrEmpty(musicInfo.Album) ? UNKNOWN_ALBUM_NAME : musicInfo.Album;
                    var artist    = string.IsNullOrEmpty(musicInfo.Artist) ? UNKNOWN_ARTIST_NAME : musicInfo.Artist;

                    musicInfo.FullPath = MoveToLibraryFolder(filePath, artist, album);
                    _library.AddOrUpdateMusicInLibrary(musicInfo);
                }
            }
        }