-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(subsonic): send valid content-type with http.ServeStream
- Loading branch information
Showing
8 changed files
with
51 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
//nolint:gochecknoglobals | ||
package mime | ||
|
||
func FromExtension(ext string) string { | ||
switch ext { | ||
case "mp3": | ||
return "audio/mpeg" | ||
case "flac": | ||
return "audio/x-flac" | ||
case "aac": | ||
return "audio/x-aac" | ||
case "m4a": | ||
return "audio/m4a" | ||
case "m4b": | ||
return "audio/m4b" | ||
case "ogg": | ||
return "audio/ogg" | ||
case "opus": | ||
return "audio/ogg" | ||
case "wma": | ||
return "audio/x-ms-wma" | ||
default: | ||
import ( | ||
"log" | ||
stdmime "mime" | ||
) | ||
|
||
var supportedAudioTypes = map[string]string{ | ||
".mp3": "audio/mpeg", | ||
".flac": "audio/x-flac", | ||
".aac": "audio/x-aac", | ||
".m4a": "audio/m4a", | ||
".m4b": "audio/m4b", | ||
".ogg": "audio/ogg", | ||
".opus": "audio/ogg", | ||
".wma": "audio/x-ms-wma", | ||
} | ||
|
||
//nolint:gochecknoinits | ||
func init() { | ||
for ext, mime := range supportedAudioTypes { | ||
if err := stdmime.AddExtensionType(ext, mime); err != nil { | ||
log.Fatalf("adding audio type mime for ext %q: %v", ext, err) | ||
} | ||
} | ||
} | ||
|
||
var TypeByExtension = stdmime.TypeByExtension | ||
var ParseMediaType = stdmime.ParseMediaType | ||
var FormatMediaType = stdmime.FormatMediaType | ||
|
||
func TypeByAudioExtension(ext string) string { | ||
if _, ok := supportedAudioTypes[ext]; !ok { | ||
return "" | ||
} | ||
return stdmime.TypeByExtension(ext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters