Пример #1
0
        public void ExportSong(Executer fileAccess, string folderPath, string format = "%ARTIST% - %TITLE%")
        {
            #if DEBUG
            #else
            try
            {
            #endif
            var beatmap = this.Beatmap;
            var copiedFilePath = Path.Combine(folderPath, beatmap.FormattedOutputFilename(format).AsValidPath());
            fileAccess.AddAction(() => File.Copy(Path.Combine(this.path, beatmap.FileName), copiedFilePath, true), "Copying file : " + copiedFilePath);
            using (var copiedFile = fileAccess.AddFunc(() => TagLib.File.Create(copiedFilePath), "Creating taggable file from : " + copiedFilePath))
            {
                copiedFile.RemoveTags(TagLib.TagTypes.Id3v2);
                copiedFile.Tag.Title = beatmap.Title;
                copiedFile.Tag.Performers = new string[] { beatmap.Artist };
                var artworkPath = this.ArtworkPath;
                if (artworkPath != null)
                {
                    copiedFile.Tag.Pictures = new[] { new TagLib.Picture(artworkPath) };
                }
                fileAccess.AddAction(() => copiedFile.Save(), "Saving tagged file : " + copiedFilePath);
            }

            #if DEBUG
            #else
            }
            catch (Exception ex)
            {
                ExportLogger.GetInstance().LogError(ex, "put info");
            }
            #endif
        }