Better thumbnail extension extraction

This commit is contained in:
Sebastiaan de Schaetzen 2025-02-07 08:14:15 +01:00
parent e84bc20086
commit 9936a57200

View File

@ -8,6 +8,7 @@ import (
"io" "io"
"log" "log"
"net/http" "net/http"
"net/url"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -109,7 +110,11 @@ func DownloadAllVideos(db *sql.DB) error {
} }
// Write thumbnail // Write thumbnail
thumbnailExt := filepath.Ext(thumbnailUrl) parsedThumbnailUrl, err := url.Parse(thumbnailUrl)
if err != nil {
return fmt.Errorf("error parsing thumbnail url: %w", err)
}
thumbnailExt := filepath.Ext(parsedThumbnailUrl.Path)
thumbnailFile, err := os.Create(filepath.Join(destinationDir, baseFileName+"-thumb"+thumbnailExt)) thumbnailFile, err := os.Create(filepath.Join(destinationDir, baseFileName+"-thumb"+thumbnailExt))
if err != nil { if err != nil {
return fmt.Errorf("error creating thumbnail: %w", err) return fmt.Errorf("error creating thumbnail: %w", err)