shithub: hell

Download patch

ref: 0070c9b1d0e4b8d62901c4c44f76747af93dd59c
parent: 9ee49331d43f82cee5b90397f6d18dfc2be469ad
author: penny <penny@limitedideas.org>
date: Tue Sep 30 09:13:22 EDT 2025

Downloads location is saved in preferences

--- a/config.go
+++ b/config.go
@@ -6,6 +6,7 @@
 	"io/ioutil"
 	"os"
 	"time"
+	"strings"
 )
 
 const configFileName = "config.json"
@@ -12,6 +13,7 @@
 
 type Hellprefs struct {
 	Apidelay float32 `json:"apidelay"`
+	Save_Location string `json:"save_location"`
 }
 
 type account struct {
@@ -38,6 +40,10 @@
 		prefs.Apidelay = defaultprefs.Apidelay
 		fixed = true
 	}
+	if prefs.Save_Location == "" {
+		prefs.Save_Location = defaultprefs.Save_Location
+		fixed = true
+	}
 	return prefs, fixed
 }
 
@@ -44,6 +50,7 @@
 func initPrefs() Hellprefs {
 	prefs := &Hellprefs{
 		Apidelay: 2,
+		Save_Location: "~/Downloads",
 	}
 	return *prefs
 }
@@ -98,5 +105,11 @@
 			return nil, fmt.Errorf("error writing config file: %w", err)
 		}
 	}
+	config.Preferences.Save_Location = expandDir(config.Preferences.Save_Location)
 	return config, nil
 }
+
+func expandDir(dir string) string {
+	dir = strings.ReplaceAll(dir, "~", "$HOME")
+	return os.ExpandEnv(dir)
+}
\ No newline at end of file
--- a/main.go
+++ b/main.go
@@ -281,7 +281,7 @@
 				}
 				return
 			case "download":
-				savePostImages(postItem, "/Users/penny/Downloads/")
+				savePostImages(postItem, hc.preferences.Save_Location)
 				return
 			case "rt":
 				rtStatus, err := client.Reblog(context.Background(), postItem.ID)
--