Skip to content
Merged

Fixes #182

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ echo "[setup] Web UI available at http://localhost:${WEB_ADDR##*:}"

echo "[setup] Initializing cron jobs..."

# Start with a clean crontab
: > /etc/crontabs/root

# Load *_SCHEDULE and *_FLAGS from .env if not already set in the environment.
# This allows the web UI to configure schedules by writing to the .env file.
_cfg="${WEB_ENV_PATH:-/opt/explo/.env}"
Expand Down
1 change: 1 addition & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Flags struct {
CfgPath string
CfgSet bool
Playlist string
PlaylistSet bool
DownloadMode string
ExcludeLocal bool
Persist bool
Expand Down
2 changes: 2 additions & 0 deletions src/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (cfg *Config) GetFlags() error {
}
persistSet := flag.Lookup("persist").Changed
cfgSet := flag.Lookup("config").Changed
playlistSet := flag.Lookup("playlist").Changed



Expand All @@ -59,6 +60,7 @@ func (cfg *Config) GetFlags() error {
cfg.Flags.CfgPath = configPath
cfg.Flags.CfgSet = cfgSet
cfg.Flags.Playlist = playlist
cfg.Flags.PlaylistSet = playlistSet
cfg.Flags.DownloadMode = downloadMode
cfg.Flags.ExcludeLocal = excludeLocal
cfg.Flags.Persist = persist
Expand Down
2 changes: 1 addition & 1 deletion src/downloader/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *DownloadClient) MonitorDownloads(tracks []*models.Track, m Monitor) err
track.File, path = parsePath(track.File)
if monCfg.MigrateDownload {
if err = c.MoveDownload(monCfg.FromDir, monCfg.ToDir, path, track); err != nil {
return fmt.Errorf("error while moving file: %w", err)
slog.Error("error while moving file", "err", err.Error())
} else {
slog.Info("track moved successfully", "service", monCfg.Service)
}
Expand Down
7 changes: 6 additions & 1 deletion src/downloader/slskd.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,19 @@ func parsePath(p string) (string, string) { // parse filepath to downloaded form
}

func wildcardArtist(artist string) string {
prefix := ""
if len(artist) >= 4 && strings.EqualFold(artist[:4], "the ") {
prefix = artist[:4]
artist = strings.TrimSpace(artist[4:])
}
r := []rune(strings.TrimSpace(artist))

if len(r) < 3 {
return artist
}

r[0] = '*'
return string(r)
return prefix + string(r)
}

// different failure states slskd has (format is "Completed,Rejected", "Errored,Cancelled" etc..)
Expand Down
20 changes: 10 additions & 10 deletions src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,22 @@ func main() {
return
}

if cfg.Flags.RefreshOnly {
if err := client.TriggerRefresh(&cfg); err != nil {
slog.Error("refresh-only failed", "err", err.Error())
os.Exit(1)
}
slog.Info("library refresh triggered")
return
}

slog.Info("Starting Explo...")

if err := os.MkdirAll(cfg.DownloadCfg.Youtube.CoversDir, 0755); err != nil {
slog.Error("failed making directory", "msg", err.Error())
}

if cfg.ServerCfg.Enabled {
if cfg.ServerCfg.Enabled || !cfg.Flags.PlaylistSet {

exploPath, err := os.Executable()
if err != nil {
Expand All @@ -156,15 +165,6 @@ func main() {
log.Fatal(srv.Start())
}

if cfg.Flags.RefreshOnly {
if err := client.TriggerRefresh(&cfg); err != nil {
slog.Error("refresh-only failed", "err", err.Error())
os.Exit(1)
}
slog.Info("library refresh triggered")
return
}

var tracks []*models.Track
var err error
if strings.HasPrefix(cfg.Flags.Playlist, "custom-") {
Expand Down
2 changes: 1 addition & 1 deletion src/web/backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ func formatEnvValue(v string) string {
return v
}

if strings.ContainsAny(v, `"$#?' `) {
if strings.ContainsAny(v, `"$#?'`) {
// escape single quotes inside value
v = strings.ReplaceAll(v, `'`, `'\''`)
return fmt.Sprintf(`'%s'`, v)
Expand Down
Loading