diff --git a/find_and_transcode_files.go b/find_and_transcode_files.go index 17f8316..58cf4b3 100644 --- a/find_and_transcode_files.go +++ b/find_and_transcode_files.go @@ -32,7 +32,7 @@ func findFiles(sourceDir, destinationDir string) error { for _, file := range filesThatNeedToBeRendered { sourcePath := filepath.Join(sourceDir, file.sourcePath) - if strings.HasSuffix(sourcePath, ".m4a") { + if strings.HasSuffix(sourcePath, ".m4a") || strings.HasSuffix(sourcePath, ".aif") { // TODO: Extract to transcodeFileAtPath with sourcePath and destinationDir destinationPath := filepath.Join(destinationDir, strings.TrimSuffix(file.sourcePath, filepath.Ext(file.sourcePath))+".mp3") err := transcodeFileAtPath(sourcePath, destinationPath) @@ -164,7 +164,7 @@ func getExclusiveFiles(filesA, filesB []string) []FileToRender { if strings.HasSuffix(file, ".mp3") { // Copy .mp3 files over verbatim destinationFilename = file - } else if strings.HasSuffix(file, ".m4a") { + } else if strings.HasSuffix(file, ".m4a") || strings.HasSuffix(file, ".aif") { // Other files need to be transcoded to .mp3 destinationFilename = strings.TrimSuffix(file, filepath.Ext(file)) + ".mp3" } else { diff --git a/find_and_transcode_files_test.go b/find_and_transcode_files_test.go index d967102..4ad1c68 100644 --- a/find_and_transcode_files_test.go +++ b/find_and_transcode_files_test.go @@ -55,6 +55,12 @@ func TestGetExclusiveFiles(t *testing.T) { DestinationList: []string{"file4.m4a", "file5.mp3", "file6.mp3"}, ExpectedOutput: []string{"file1.m4a", "file2.m4a", "file3.m4a"}, }, + { + Name: "Destination contains aif files which should be transcoded", + SourceList: []string{"file1.m4a", "file2.aif"}, + DestinationList: []string{}, + ExpectedOutput: []string{"file1.m4a", "file2.aif"}, + }, { Name: "Ignore non-music files", SourceList: []string{".DS_Store"}, diff --git a/sync_and_transcode_music_files_test.go b/sync_and_transcode_music_files_test.go index 79ff357..d7effed 100644 --- a/sync_and_transcode_music_files_test.go +++ b/sync_and_transcode_music_files_test.go @@ -50,6 +50,7 @@ func setupFixtureFilesInDirectory(tempDir string, numberOfFiles int) error { "source/a-band/file5.m4a", "source/Whitespace Band/file6.m4a", "source/the-band/file7.mp3", + "source/file8.aif", "source/.DS_Store", } for _, file := range testFiles[0:numberOfFiles] { @@ -91,6 +92,8 @@ func TestFindFiles(t *testing.T) { "destination/a-band/file5.mp3", "destination/Whitespace Band/file6.mp3", "destination/the-band/file7.mp3", + "destination/file8.mp3", + // TODO: Maybe needs to include blank spot for missing .DS_Store } tempDir, err := setup(t, len(transcodedFiles))