MCPcopy
hub / github.com/spicetify/cli / EnableDevTools

Function EnableDevTools

src/cmd/devtools.go:35–97  ·  view source on GitHub ↗

EnableDevTools enables the developer tools in the Spotify client

()

Source from the content-addressed store, hash-verified

33
34// EnableDevTools enables the developer tools in the Spotify client
35func EnableDevTools() {
36 var filePath string
37
38 switch runtime.GOOS {
39 case "windows":
40 appFilePath := os.Getenv("LOCALAPPDATA") + "\\Spotify\\offline.bnk"
41 if _, err := os.Stat(appFilePath); err == nil {
42 filePath = appFilePath
43 } else if len(utils.WinXApp()) != 0 && len(utils.WinXPrefs()) != 0 {
44 dir, _ := filepath.Split(utils.WinXPrefs())
45 filePath = filepath.Join(dir, "offline.bnk")
46 }
47 case "linux":
48 {
49 homePath := os.Getenv("HOME")
50 snapSpotifyHome := homePath + "/snap/spotify/common"
51 if _, err := os.Stat(snapSpotifyHome); err == nil {
52 homePath = snapSpotifyHome
53 }
54
55 flatpakHome := homePath + "/.var/app/com.spotify.Client"
56 if _, err := os.Stat(flatpakHome); err == nil {
57 homePath = flatpakHome
58 filePath = homePath + "/cache/spotify/offline.bnk"
59 } else {
60 cacheHome := os.Getenv("XDG_CACHE_HOME")
61 if cacheHome == "" {
62 cacheHome = homePath + "/.cache"
63 }
64
65 filePath = cacheHome + "/spotify/offline.bnk"
66 }
67
68 }
69 case "darwin":
70 filePath = os.Getenv("HOME") + "/Library/Application Support/Spotify/PersistentCache/offline.bnk"
71 }
72
73 if _, err := os.Stat(filePath); os.IsNotExist(err) {
74 utils.PrintError("Can't find \"offline.bnk\". Try running spotify first.")
75 os.Exit(1)
76 }
77
78 file, err := os.OpenFile(filePath, os.O_RDWR, 0644)
79
80 if err != nil {
81 log.Fatal(err)
82 }
83 defer file.Close()
84
85 buf := new(bytes.Buffer)
86 buf.ReadFrom(file)
87 content := buf.String()
88 firstPatchLocation, secondPatchLocation, err := findOfflineBnkDeveloperFlagOffsets(content)
89 if err != nil {
90 utils.PrintError(err.Error())
91 os.Exit(1)
92 }

Callers 3

mainFunction · 0.92
SpotifyStartFunction · 0.85
startDebuggerFunction · 0.85

Calls 5

WinXAppFunction · 0.92
WinXPrefsFunction · 0.92
PrintErrorFunction · 0.92
PrintSuccessFunction · 0.92

Tested by

no test coverage detected