Skip to content

Commit

Permalink
[bugfix] Advertise audio/mpeg as supported
Browse files Browse the repository at this point in the history
This will be either an mp1, mp2 or mp3 file. In practice it'll probably
be mp3, but this handles mp1 too for good measure. We don't advertise
audio/mp1 as a supported media type since best I can tell that was never
a MIME type that's been used.

This also changes the returned MIME-type for mp2 and mp3 to audio/mpeg,
to match what's expected and supported by most things nowadays.

Fixes: #3531
  • Loading branch information
daenney committed Dec 27, 2024
1 parent 0784aa3 commit be8b25f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions internal/api/client/instance/instancepatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -254,6 +255,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -395,6 +397,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -587,6 +590,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -750,6 +754,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -932,6 +937,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down
7 changes: 5 additions & 2 deletions internal/media/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,15 @@ func (res *result) GetFileType() (gtsmodel.FileType, string, string) {
case "mp3":
if len(res.audio) > 0 {
switch res.audio[0].codec {
case "mp1":
return gtsmodel.FileTypeAudio,
"audio/mpeg", "mp1"
case "mp2":
return gtsmodel.FileTypeAudio,
"audio/mp2", "mp2"
"audio/mpeg", "mp2"
case "mp3":
return gtsmodel.FileTypeAudio,
"audio/mp3", "mp3"
"audio/mpeg", "mp3"
}
}
case "asf":
Expand Down
5 changes: 3 additions & 2 deletions internal/media/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ var SupportedMIMETypes = []string{
"image/gif", // .gif
"image/webp", // .webp

"audio/mp2", // .mp2
"audio/mp3", // .mp3
"audio/mp2", // .mp2
"audio/mp3", // .mp3
"audio/mpeg", // .mp1, .mp2, .mp3

"video/x-msvideo", // .avi

Expand Down
2 changes: 2 additions & 0 deletions internal/typeutils/internaltofrontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down Expand Up @@ -2105,6 +2106,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
"image/webp",
"audio/mp2",
"audio/mp3",
"audio/mpeg",
"video/x-msvideo",
"audio/flac",
"audio/x-flac",
Expand Down

0 comments on commit be8b25f

Please sign in to comment.