From 9936a57200100d386b69c3707a618a0cc7a21d7e Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 7 Feb 2025 08:14:15 +0100 Subject: [PATCH] Better thumbnail extension extraction --- downloader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/downloader.go b/downloader.go index 6cf266c..6974b8c 100644 --- a/downloader.go +++ b/downloader.go @@ -8,6 +8,7 @@ import ( "io" "log" "net/http" + "net/url" "os" "os/exec" "path/filepath" @@ -109,7 +110,11 @@ func DownloadAllVideos(db *sql.DB) error { } // 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)) if err != nil { return fmt.Errorf("error creating thumbnail: %w", err)