Skip to content

Commit 24acdc0

Browse files
committed
feat: Add deprecation warnings for castsponsorskip envs
1 parent b19f79f commit 24acdc0

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

internal/config/intervals.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package config
22

33
import (
4+
"fmt"
5+
"log/slog"
46
"os"
57
"strconv"
68
"time"
@@ -24,7 +26,9 @@ func (c *Config) RegisterDiscoverInterval(cmd *cobra.Command) {
2426
if env := os.Getenv("SBCSCANINTERVAL"); env != "" {
2527
parsed, err := strconv.Atoi(env)
2628
if err == nil {
27-
viper.SetDefault(key, (time.Duration(parsed) * time.Second).String())
29+
val := (time.Duration(parsed) * time.Second).String()
30+
slog.Warn(fmt.Sprintf(`SBCSCANINTERVAL is deprecated. Please set %q instead.`, "CSS_DISCOVER_INTERVAL="+val))
31+
viper.SetDefault(key, val)
2832
}
2933
}
3034
}
@@ -57,7 +61,9 @@ func (c *Config) RegisterPlayingInterval(cmd *cobra.Command) {
5761
if env := os.Getenv("SBCPOLLINTERVAL"); env != "" {
5862
parsed, err := strconv.Atoi(env)
5963
if err == nil {
60-
viper.SetDefault(key, (time.Duration(parsed) * time.Second).String())
64+
val := (time.Duration(parsed) * time.Second).String()
65+
slog.Warn(fmt.Sprintf(`SBCPOLLINTERVAL is deprecated. Please set %q instead.`, "CSS_PLAYING_INTERVAL="+val))
66+
viper.SetDefault(key, val)
6167
}
6268
}
6369
}

internal/config/sponsorblock.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package config
22

33
import (
44
"encoding/json"
5+
"fmt"
6+
"log/slog"
57
"net/http"
68
"os"
79
"strings"
@@ -21,8 +23,9 @@ func (c *Config) RegisterCategories(cmd *cobra.Command) {
2123
}
2224

2325
if env := os.Getenv("SBCCATEGORIES"); env != "" {
24-
env := strings.Split(env, " ")
25-
viper.SetDefault(key, env)
26+
val := strings.Split(env, " ")
27+
slog.Warn(fmt.Sprintf(`SBCCATEGORIES is deprecated. Please set %q instead.`, "CSS_CATEGORIES="+strings.Join(val, ",")))
28+
viper.SetDefault(key, val)
2629
}
2730
}
2831

internal/config/youtube.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package config
22

33
import (
4+
"fmt"
5+
"log/slog"
46
"os"
57

68
"github.com/spf13/cobra"
@@ -15,6 +17,7 @@ func (c *Config) RegisterYouTubeAPIKey(cmd *cobra.Command) {
1517
}
1618

1719
if env := os.Getenv("SBCYOUTUBEAPIKEY"); env != "" {
20+
slog.Warn(fmt.Sprintf(`SBCYOUTUBEAPIKEY is deprecated. Please set %q instead.`, "CSS_YOUTUBE_API_KEY="+env))
1821
viper.SetDefault(key, env)
1922
}
2023
}

0 commit comments

Comments
 (0)