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

Function Start

src/preprocess/preprocess.go:83–326  ·  view source on GitHub ↗
(version string, spotifyBasePath string, extractedAppsPath string, flags Flag)

Source from the content-addressed store, hash-verified

81}
82
83func Start(version string, spotifyBasePath string, extractedAppsPath string, flags Flag) {
84 appPath := filepath.Join(extractedAppsPath, "xpui")
85 var cssTranslationMap = make(map[string]string)
86
87 if version != "Dev" {
88 fetchSpinner, _ := utils.Spinner.Start("Fetching remote CSS map")
89 tag, err := FetchLatestTagMatchingOrMain(version)
90 if err != nil {
91 fetchSpinner.Warning("Failed to fetch remote CSS map")
92 utils.PrintWarning(err.Error())
93 tag = version
94 }
95 if readRemoteCssMap(tag, &cssTranslationMap) != nil {
96 fetchSpinner.Warning("Failed to fetch remote CSS map")
97 utils.PrintInfo("Using local CSS map instead")
98 readLocalCssMap(&cssTranslationMap)
99 } else {
100 fetchSpinner.Success("Fetched remote CSS map")
101 }
102 } else {
103 utils.PrintInfo("Using local CSS map; in development environment")
104 readLocalCssMap(&cssTranslationMap)
105 }
106
107 cssMapPairs := make([]string, 0, len(cssTranslationMap)*4)
108 for k, v := range cssTranslationMap {
109 cssMapPairs = append(cssMapPairs, k+":", `"`+v+`":`)
110 cssMapPairs = append(cssMapPairs, k, v)
111 }
112 cssMapJSReplacer := strings.NewReplacer(cssMapPairs...)
113 cssMapBareKeySpaceRe := regexp.MustCompile(`\b[a-zA-Z0-9_]{16,21}[ \t]+:`)
114
115 verParts := strings.Split(flags.SpotifyVer, ".")
116 spotifyMajor, spotifyMinor, spotifyPatch := 0, 0, 0
117 if len(verParts) > 0 {
118 spotifyMajor, _ = strconv.Atoi(verParts[0])
119 }
120 if len(verParts) > 1 {
121 spotifyMinor, _ = strconv.Atoi(verParts[1])
122 }
123 if len(verParts) > 2 {
124 spotifyPatch, _ = strconv.Atoi(verParts[2])
125 }
126
127 var spotifyBinaryPath string
128 switch runtime.GOOS {
129 case "windows":
130 dllPath := filepath.Join(spotifyBasePath, "spotify.dll")
131 exePath := filepath.Join(spotifyBasePath, "spotify.exe")
132
133 if _, err := os.Stat(dllPath); err == nil {
134 spotifyBinaryPath = dllPath
135 } else if _, err := os.Stat(exePath); err == nil {
136 spotifyBinaryPath = exePath
137 } else {
138 utils.PrintError("Could not find spotify.dll or spotify.exe in Spotify installation directory")
139 utils.Fatal(errors.New("aborting the patching process due to missing Spotify binaries"))
140 }

Callers 1

BackupFunction · 0.92

Calls 15

PrintWarningFunction · 0.92
PrintInfoFunction · 0.92
PrintErrorFunction · 0.92
FatalFunction · 0.92
CreateFileFunction · 0.92
PrintSuccessFunction · 0.92
ModifyFileFunction · 0.92
ReplaceOnceFunction · 0.92
ReplaceFunction · 0.92
readRemoteCssMapFunction · 0.85

Tested by

no test coverage detected