Fix ffmpeg download (#2416)

This commit is contained in:
bnkai 2022-03-24 02:06:17 +02:00 committed by GitHub
parent 627c1e9c60
commit ba41133745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -124,10 +124,16 @@ func downloadSingle(ctx context.Context, configDirectory, url string) error {
if err != nil { if err != nil {
return err return err
} }
logger.Info("Downloading complete") logger.Info("Downloading complete")
if resp.Header.Get("Content-Type") == "application/zip" { mime := resp.Header.Get("Content-Type")
if mime != "application/zip" { // try detecting MIME type since some servers don't return the correct one
data := make([]byte, 500) // http.DetectContentType only reads up to 500 bytes
_, _ = out.ReadAt(data, 0)
mime = http.DetectContentType(data)
}
if mime == "application/zip" {
logger.Infof("Unzipping %s...", archivePath) logger.Infof("Unzipping %s...", archivePath)
if err := unzip(archivePath, configDirectory); err != nil { if err := unzip(archivePath, configDirectory); err != nil {
return err return err