{
    "version": "1.2.88.483.g8aa8628e",
    "description": "A digital music service that gives you access to millions of songs.",
    "homepage": "https://www.spotify.com/",
    "license": {
        "identifier": "Freeware",
        "url": "https://www.spotify.com/legal/end-user-agreement/"
    },
    "architecture": {
        "64bit": {
            "url": "https://download.scdn.co/SpotifyFullSetupX64.exe",
            "hash": "23fc64ee41702118248a21b87d14097259efb528f68e96d0d2153bf41305d100"
        },
        "arm64": {
            "url": "https://download.scdn.co/SpotifyFullSetupARM64.exe",
            "hash": "d4efafced8a42d251daa35a7c196a3419cde5f6fcec47f45c7a26bcd802484fa"
        }
    },
    "installer": {
        "script": [
            "Start-Process -Wait \"$dir\\$fname\" -ArgumentList '/extract', \"`\"$dir`\"\"",
            "Remove-Item \"$dir\\$fname\", \"$dir\\SpotifyMigrator.exe\" -ErrorAction SilentlyContinue",
            "",
            "## Steps to block the built-in autoupdater ##",
            "    $updateFile = \"$env:LOCALAPPDATA\\Spotify\\Update\"",
            "# Delete any remnant file or directory called Update (including modify-protected), unless it is readonly or hidden",
            "    Remove-Item -Path \"$updateFile\" -Recurse -ErrorAction SilentlyContinue | Out-Null",
            "# Delete any remnant file or directory called Update (including readonly), unless it is modify-protected",
            "    Remove-Item -Path \"$updateFile\" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null",
            "# Exit if there already exists an autoupdate-blocking file called Update",
            "    if (Test-Path -Path \"$updateFile\") { return }",
            "# Create a file called Update",
            "    New-Item -Path \"$updateFile\" -ItemType File -Value \"Created by Scoop to block the built-in autoupdater.\" -Force -ErrorAction SilentlyContinue | Out-Null",
            "# Make the file readonly",
            "    Set-ItemProperty -Path \"$updateFile\" -Name IsReadOnly -Value $true -ErrorAction SilentlyContinue | Out-Null",
            "# Make the file modify-protected from self",
            "    $Ace = New-Object System.Security.AccessControl.FileSystemAccessRule(\"${env:username}\", \"Modify\", \"Deny\")",
            "    $Acl = New-Object System.Security.AccessControl.FileSecurity",
            "    $Acl.AddAccessRule($Ace)",
            "    Set-Acl -Path \"$updateFile\" -AclObject $Acl -ErrorAction SilentlyContinue | Out-Null"
        ]
    },
    "shortcuts": [
        [
            "Spotify.exe",
            "Spotify"
        ]
    ],
    "uninstaller": {
        "script": [
            "if ($cmd -ne 'uninstall') { return }",
            "",
            "## Undoing the steps to block the built-in autoupdater ##",
            "    $updateFile = \"$env:LOCALAPPDATA\\Spotify\\Update\"",
            "# Remove modify-protection for the Update file",
            "    $Ace = New-Object System.Security.AccessControl.FileSystemAccessRule(\"${env:username}\", \"Modify\", \"Deny\")",
            "    $Acl = New-Object System.Security.AccessControl.FileSecurity",
            "    $Acl.RemoveAccessRule($Ace)",
            "    Set-Acl -Path \"$updateFile\" -AclObject $Acl -ErrorAction SilentlyContinue | Out-Null",
            "# Delete the Update file",
            "    Remove-Item -Path \"$updateFile\" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null",
            "",
            "Start-Process -Wait \"$dir\\Spotify.exe\" -ArgumentList '/Uninstall', '/Silent'"
        ]
    },
    "checkver": {
        "script": [
            "$dl_url = 'https://download.scdn.co/SpotifyFullSetupX64.exe'",
            "$dl = cache_path 'spotify' 'unknown' $dl_url",
            "Invoke-WebRequest $dl_url -OutFile $dl",
            "$ver = (Get-Item $dl).VersionInfo.ProductVersion",
            "Move-Item -Force $dl (cache_path 'spotify' $ver $dl_url)",
            "$ver"
        ],
        "regex": "(\\S+)"
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://download.scdn.co/SpotifyFullSetupX64.exe"
            },
            "arm64": {
                "url": "https://download.scdn.co/SpotifyFullSetupARM64.exe"
            }
        }
    }
}
