From c635080a0bfc7efd8519adfa527b012115cb0208 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sun, 21 Jul 2024 13:42:51 +0100 Subject: [PATCH] [feature] add flac support (#3121) * add flac support to the ffprobe format/stream -> filetype parser * also add audio/flac for flac (not just x-flac) * update tests --------- Co-authored-by: tobi --- internal/api/client/instance/instancepatch_test.go | 12 ++++++++++++ internal/media/ffmpeg.go | 2 ++ internal/media/manager.go | 3 +++ internal/typeutils/internaltofrontend_test.go | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index e68508fc2..095e2e543 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -109,6 +109,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -243,6 +245,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -377,6 +381,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -562,6 +568,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -718,6 +726,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -893,6 +903,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", diff --git a/internal/media/ffmpeg.go b/internal/media/ffmpeg.go index 6d4c9ac87..ce90028af 100644 --- a/internal/media/ffmpeg.go +++ b/internal/media/ffmpeg.go @@ -335,6 +335,8 @@ func (res *result) GetFileType() (gtsmodel.FileType, string) { } case "avi": return gtsmodel.FileTypeVideo, "avi" + case "flac": + return gtsmodel.FileTypeAudio, "flac" } return gtsmodel.FileTypeUnknown, res.format } diff --git a/internal/media/manager.go b/internal/media/manager.go index 13bcebe79..0099dfe07 100644 --- a/internal/media/manager.go +++ b/internal/media/manager.go @@ -43,6 +43,9 @@ "video/x-msvideo", // .avi + "audio/flac", // .flac + "audio/x-flac", // .flac + // png types "image/png", // .png "image/apng", // .apng diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index 3599e7b56..faae22e65 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -1432,6 +1432,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg", @@ -1570,6 +1572,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() { "audio/mp2", "audio/mp3", "video/x-msvideo", + "audio/flac", + "audio/x-flac", "image/png", "image/apng", "audio/ogg",