Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
320 lines (272 loc) · 11.2 KB
/
Copy pathinstall.ps1
File metadata and controls
320 lines (272 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#Requires -Version 5.1
<#
.SYNOPSIS
Extendify Installer for Spotify
.DESCRIPTION
Downloads and installs the Extendify mod for Spotify on Windows.
#>
$C = @{
Reset = "`e[0m"
Bold = "`e[1m"
Dim = "`e[2m"
Green = "`e[92m"
Cyan = "`e[96m"
Yellow = "`e[93m"
Red = "`e[91m"
Magenta = "`e[95m"
White = "`e[97m"
BgGreen = "`e[42m"
BgBlue = "`e[44m"
}
if ((Get-Process -Id $PID).ProcessName -eq "powershell") {
foreach ($key in @($C.Keys)) { $C[$key] = "" }
}
function Write-Banner {
Write-Host ""
Write-Host " $($C.Magenta)$($C.Bold)███████╗██╗ ██╗████████╗███████╗███╗ ██╗██████╗ ██╗███████╗██╗ ██╗$($C.Reset)"
Write-Host " $($C.Magenta)$($C.Bold)██╔════╝╚██╗██╔╝╚══██╔══╝██╔════╝████╗ ██║██╔══██╗██║██╔════╝╚██╗ ██╔╝$($C.Reset)"
Write-Host " $($C.Magenta)$($C.Bold)█████╗ ╚███╔╝ ██║ █████╗ ██╔██╗ ██║██║ ██║██║█████╗ ╚████╔╝ $($C.Reset)"
Write-Host " $($C.Magenta)$($C.Bold)██╔══╝ ██╔██╗ ██║ ██╔══╝ ██║╚██╗██║██║ ██║██║██╔══╝ ╚██╔╝ $($C.Reset)"
Write-Host " $($C.Magenta)$($C.Bold)███████╗██╔╝ ██╗ ██║ ███████╗██║ ╚████║██████╔╝██║██║ ██║ $($C.Reset)"
Write-Host " $($C.Magenta)$($C.Bold)╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ ╚═╝╚═╝ ╚═╝ $($C.Reset)"
Write-Host ""
Write-Host " $($C.Dim)$($C.White)Spotify Mod Installer - github.com/extendify-mod/extendify$($C.Reset)"
Write-Host " $($C.Dim)────────────────────────────────────────────────$($C.Reset)"
Write-Host ""
}
function Write-Step {
param([int]$Num, [string]$Text)
Write-Host " $($C.Cyan)$($C.Bold)[$Num]$($C.Reset) $($C.White)$Text$($C.Reset)"
}
function Write-Info { param([string]$Msg) Write-Host " $($C.Dim)$($C.White)→ $Msg$($C.Reset)" }
function Write-Ok { param([string]$Msg) Write-Host " $($C.Green)✔ $Msg$($C.Reset)" }
function Write-Warn { param([string]$Msg) Write-Host " $($C.Yellow)⚠ $Msg$($C.Reset)" }
function Write-Err { param([string]$Msg) Write-Host " $($C.Red)✖ $Msg$($C.Reset)" }
function Write-ProgressBar {
param(
[int]$Percent,
[string]$Label = "",
[int]$Width = 40
)
$filled = [int]([Math]::Round($Percent / 100 * $Width))
$empty = $Width - $filled
$bar = ("█" * $filled) + ("░" * $empty)
$pct = "$Percent%".PadLeft(4)
Write-Host -NoNewline "`r $($C.Cyan)$bar$($C.Reset) $($C.Bold)$pct$($C.Reset) $($C.Dim)$Label$($C.Reset) "
}
function Write-FakeProgress {
param([string]$Label = "Working…", [int]$DurationMs = 2000, [int]$Steps = 50)
$delay = [int]($DurationMs / $Steps)
for ($i = 0; $i -le $Steps; $i++) {
Write-ProgressBar -Percent ([int]($i / $Steps * 100)) -Label $Label
Start-Sleep -Milliseconds $delay
}
Write-Host ""
}
function Write-DownloadProgress {
param([string]$Url, [string]$Dest, [string]$Label)
Write-Host ""
try {
$req = [System.Net.HttpWebRequest]::Create($Url)
$req.Method = "HEAD"
$req.AllowAutoRedirect = $true
$resp = $req.GetResponse()
$totalBytes = $resp.ContentLength
$resp.Close()
$req2 = [System.Net.HttpWebRequest]::Create($Url)
$req2.AllowAutoRedirect = $true
$resp2 = $req2.GetResponse()
$stream = $resp2.GetResponseStream()
$fs = [System.IO.File]::Create($Dest)
$buf = New-Object byte[] 8192
$received = 0
while ($true) {
$read = $stream.Read($buf, 0, $buf.Length)
if ($read -le 0) { break }
$fs.Write($buf, 0, $read)
$received += $read
if ($totalBytes -gt 0) {
$pct = [int]($received / $totalBytes * 100)
Write-ProgressBar -Percent $pct -Label $Label
}
}
$fs.Close()
$stream.Close()
$resp2.Close()
Write-ProgressBar -Percent 100 -Label $Label
Write-Host ""
}
catch {
Write-Host ""
throw $_
}
}
function Prompt-YesNo {
param([string]$Question)
while ($true) {
Write-Host -NoNewline " $($C.Yellow)$Question $($C.Dim)[y/n]$($C.Reset) "
$ans = (Read-Host).Trim().ToLower()
if ($ans -eq 'y') { return $true }
if ($ans -eq 'n') { return $false }
Write-Warn "Please type y or n."
}
}
function Get-Architecture {
$arch = (Get-CimInstance Win32_OperatingSystem).OSArchitecture
if ($arch -match "ARM") {
if ([Environment]::Is64BitOperatingSystem) { return "arm64" }
else { return "arm32" }
}
if ([Environment]::Is64BitOperatingSystem) { return "x64" }
return "x86"
}
# Start
Write-Banner
# 32 bit check
Write-Step 1 "Checking system architecture…"
$arch = Get-Architecture
Write-Info "Detected: $arch"
if ($arch -eq "x86") {
Write-Host ""
Write-Err "Extendify doesn't support 32-bit installations of Spotify."
Write-Host ""
Write-Host " $($C.Yellow)Our recommendation is to install an older 32-bit Spotify with Spicetify:$($C.Reset)"
Write-Host ""
Write-Host " $($C.Cyan)· Old Spotify builds (x86):$($C.Reset)"
Write-Host " $($C.White)https://loadspot.pages.dev/versions?os=win&arch=x86&sortVersion=desc$($C.Reset)"
Write-Host ""
Write-Host " $($C.Cyan)· Spicetify (mod loader):$($C.Reset)"
Write-Host " $($C.White)https://spicetify.app/$($C.Reset)"
Write-Host ""
exit 1
}
Write-Ok "Architecture OK ($arch)"
Write-Host ""
# MS store check
Write-Step 2 "Checking for Microsoft Store version of Spotify…"
try {
Import-Module Appx -UseWindowsPowerShell -WarningAction SilentlyContinue
}
catch {}
try {
$storeApp = Get-AppxPackage -Name "SpotifyAB.SpotifyMusic" -ErrorAction SilentlyContinue
if ($storeApp) {
Write-Warn "Found Spotify from the Microsoft Store (v$($storeApp.Version))."
Write-Host ""
$uninstall = Prompt-YesNo "Uninstall the Store version before continuing?"
if ($uninstall) {
Write-Info "Uninstalling Spotify from MS Store…"
Write-FakeProgress -Label "Removing package…" -DurationMs 2500
try {
$storeApp | Remove-AppxPackage -ErrorAction Stop
Write-Ok "Microsoft Store Spotify removed."
}
catch {
Write-Err "Could not remove Spotify automatically from MS Store."
Write-Info "Please uninstall it manually via Settings → Apps, then re-run this script."
Write-Host ""
exit 1
}
}
else {
Write-Warn "Skipping uninstall. You may end up with two Spotify installations."
Write-Warn "If anything breaks, remove the Store version and reinstall via this script."
}
}
else {
Write-Ok "No Microsoft Store Spotify found."
}
}
catch {
Write-Warn "Couldn't check Microsoft Store packages."
}
Write-Host ""
# Install spotify
Write-Step 3 "Downloading Spotify installer…"
$spotifySetup = Join-Path $env:TEMP "SpotifySetup.exe"
$spotifyUrl = "https://download.scdn.co/SpotifySetup.exe"
try {
Write-DownloadProgress -Url $spotifyUrl -Dest $spotifySetup -Label "SpotifySetup.exe"
Write-Ok "Download complete."
}
catch {
Write-Err "Failed to download Spotify: $_"
exit 1
}
Write-Host ""
Write-Info "Launching Spotify installer…"
Write-Host ""
try {
$proc = Start-Process -FilePath $spotifySetup -PassThru
Write-Info "Waiting for installer to finish…"
$spinner = @('⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏')
$i = 0
while (-not $proc.HasExited) {
Write-Host -NoNewline "`r $($C.Cyan)$($spinner[$i % $spinner.Count])$($C.Reset) $($C.Dim)Installer running…$($C.Reset) "
Start-Sleep -Milliseconds 120
$i++
}
Write-Host "`r $($C.Green)✔ Installer finished. $($C.Reset)"
Get-Process -Name "Spotify" -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Ok "Spotify closed."
}
catch {
Write-Err "Could not launch installer: $_"
exit 1
}
Write-Host ""
# Download native
Write-Step 4 "Downloading Extendify native library…"
$dllUrls = @{
"x64" = "https://github.com/extendify-mod/extendify/releases/download/native/windows_x86_64.dll"
"arm64" = "https://github.com/extendify-mod/extendify/releases/download/native/windows_aarch64.dll"
}
if (-not $dllUrls.ContainsKey($arch)) {
Write-Err "Unsupported architecture '$arch' — this shouldn't happen. Please open an issue."
exit 1
}
$dllUrl = $dllUrls[$arch]
$dllName = "profapi.dll"
$dllDest = Join-Path (Join-Path $env:AppData "Spotify") $dllName
$dllDir = Split-Path $dllDest
Write-Info "Architecture: $arch"
Write-Info "Destination: $dllDest"
if (-not (Test-Path $dllDir)) {
Write-Warn "Spotify folder not found at $dllDir"
Write-Info "Creating directory…"
New-Item -ItemType Directory -Path $dllDir -Force | Out-Null
}
# Older versions of Extendify used version.dll instead of profapi.dll.
# Remove any leftover copy so the two don't conflict.
$legacyDll = Join-Path $dllDir "version.dll"
if (Test-Path $legacyDll) {
Write-Info "Found leftover version.dll from an older install — removing it…"
try {
Remove-Item -Path $legacyDll -Force -ErrorAction Stop
Write-Ok "Removed legacy version.dll."
}
catch {
Write-Err "Failed to remove legacy version.dll: $_"
Write-Info "Close Spotify completely (check the system tray) and re-run this script."
exit 1
}
}
try {
Write-DownloadProgress -Url $dllUrl -Dest $dllDest -Label "$dllName ($arch)"
Write-Ok "Extendify DLL installed."
}
catch {
Write-Err "Failed to download Extendify DLL: $_"
exit 1
}
Remove-Item -Path $spotifySetup -Force -ErrorAction SilentlyContinue
Write-Host ""
# Done
Write-Host " $($C.Green)$($C.Bold)╔══════════════════════════════════════╗$($C.Reset)"
Write-Host " $($C.Green)$($C.Bold)║ ║$($C.Reset)"
Write-Host " $($C.Green)$($C.Bold)║ ✔ Success! Enjoy the mod :^] ║$($C.Reset)"
Write-Host " $($C.Green)$($C.Bold)║ ║$($C.Reset)"
Write-Host " $($C.Green)$($C.Bold)╚══════════════════════════════════════╝$($C.Reset)"
Write-Host ""
Write-Host " $($C.Dim)Launch Spotify and the mod will load automatically.$($C.Reset)"
Write-Host ""