{
    "version": "7.3.7",
    "description": "Framerate monitoring, On-Screen Display and high-performance video capture service provider for other graphics card utilities.",
    "homepage": "https://www.guru3d.com/page/rivatuner-rtss-homepage/",
    "license": "Freeware",
    "suggest": {
        "vcredist": "extras/vcredist2022",
        "MSI Afterburner": "extras/msiafterburner"
    },
    "url": "https://ftp.nluug.nl/pub/games/PC/guru3d/afterburner/%5BGuru3D%5D-RTSSSetup737Build28314.zip",
    "hash": "9b084a8cb3e53ec1a673894d0b66e22b16c9fd8785636b020b2d422f3f2a820e",
    "pre_install": [
        "Expand-7zipArchive \"$dir\\*RTSSSetup*.exe\" -Removal",
        "Remove-Item \"$dir\\`$*\", \"$dir\\*Guru3D.com*\", \"$dir\\Uninstall*\", \"$dir\\Redist\" -Recurse",
        "Move-Item \"$dir\\RTSSHooks.dll.copy\" \"$dir\\RTSSHooks.dll\"",
        "Move-Item \"$dir\\RTSSHooks64.dll.copy\" \"$dir\\RTSSHooks64.dll\"",
        "# configs",
        "Copy-Item \"$persist_dir\\Plugins\\Client\\*.cfg\" \"$dir\\Plugins\\Client\" -ErrorAction SilentlyContinue"
    ],
    "post_install": [
        "$rtssProfiles = \"$persist_dir\\..\\msiafterburner\\RTSS_Profiles\"",
        "if (Test-Path \"$rtssProfiles\") {",
        "    warn 'Migrating RTSS profiles...'",
        "    Move-Item -Path \"$rtssProfiles\\*\" -Destination \"$persist_dir\\Profiles\"",
        "    Remove-Item \"$rtssProfiles\" -Recurse",
        "}"
    ],
    "bin": "RTSS.exe",
    "shortcuts": [
        [
            "RTSS.exe",
            "RivaTuner Statistics Server"
        ]
    ],
    "persist": [
        "Plugins\\Client\\Overlays",
        "Profiles"
    ],
    "pre_uninstall": [
        "# persist configs",
        "Copy-Item \"$dir\\Plugins\\Client\\*.cfg\" \"$persist_dir\\Plugins\\Client\" -Force -ErrorAction SilentlyContinue"
    ],
    "checkver": {
        "url": "https://www.guru3d.com/download/rtss-rivatuner-statistics-server-download/",
        "script": [
            "$page -match 'aform.*?value=\"(?<aform>[0-9a-f]+)\".*?Download Version (?<version>[\\d.]+)'",
            "$version = $Matches.version",
            "$body = @{ aform = $Matches.aform }",
            "$response = Invoke-WebRequest -Uri $url -Method Post -Body $body",
            "$response.Content -match 'location=\"(?<redirect_url>https://www.guru3d.com/getdownload/[0-9a-f]+)\"'",
            "$response = if ($PSVersionTable.PSVersion.Major -lt 7.0) {",
            "    Invoke-WebRequest -Uri $Matches.redirect_url -MaximumRedirection 0 -ErrorAction SilentlyContinue",
            "} else {",
            "    Invoke-WebRequest -Uri $Matches.redirect_url -MaximumRedirection 0 -ErrorAction SilentlyContinue -SkipHttpErrorCheck",
            "}",
            "[string]($response.Headers.Location) -match 'https://ftp\\.nluug\\.nl/pub/games/PC/guru3d/(?<file_path>[^/]+?)/(?<file_name>.+)'",
            "Write-Output \"$version $($Matches.file_path)/$([System.Net.WebUtility]::UrlEncode($Matches.file_name))\""
        ],
        "regex": "(?<version>[\\d.]+) (?<file>.+)"
    },
    "autoupdate": {
        "url": "https://ftp.nluug.nl/pub/games/PC/guru3d/$matchFile"
    }
}
