sanitize wallpaper filename by including topic in the format

This commit is contained in:
sudacode 2025-05-05 13:42:03 -07:00
parent 5e1cb37c9b
commit 7b29eee1ff
Signed by: sudacode
SSH Key Fingerprint: SHA256:lT5C2bB398DcX6daCF/gYFNSTK3y+Du3oTGUnYzfTEw

View File

@ -132,7 +132,9 @@ func downloadRandomWallpaper(wallpaperPath string, r *rand.Rand, topics []string
// Select a random image from the results
randomIndex := r.Intn(len(wallhavenResp.Data))
wallpaperURL := wallhavenResp.Data[randomIndex].Path
filename := filepath.Base(wallpaperURL)
orig := filepath.Base(wallpaperURL)
sanitizedTopic := strings.ReplaceAll(strings.ToLower(displayName), " ", "-")
filename := fmt.Sprintf("%s-%s", sanitizedTopic, orig)
filepath := filepath.Join(wallpaperPath, filename)
fmt.Fprintf(os.Stderr, "Downloading: %s\n", filename)