{
    "version": "5.2.0",
    "description": "Free and reliable P2P Bittorent client.",
    "homepage": "https://www.qbittorrent.org/",
    "license": {
        "identifier": "GPL-2.0-only",
        "url": "https://github.com/qbittorrent/qBittorrent/blob/master/COPYING"
    },
    "notes": [
        "For file associations, run:",
        "reg import \"$dir\\install-associations.reg\""
    ],
    "architecture": {
        "64bit": {
            "url": "https://downloads.sourceforge.net/project/qbittorrent/qbittorrent-win32/qbittorrent-5.2.0/qbittorrent_5.2.0_x64_setup.exe#/dl.7z",
            "hash": "sha1:ae6754be9c41305770f5835f33e2b52087d47fe9"
        }
    },
    "pre_install": [
        "Remove-Item \"$dir\\`$PLUGINSDIR\", \"$dir\\uninst.exe\" -Force -Recurse -ErrorAction SilentlyContinue",
        "if ((!(Test-Path \"$persist_dir\\profile\")) -and ((Test-Path \"$persist_dir\\..\\qbittorrent-portable\\profile\") -or (Test-Path \"$env:APPDATA\\qBittorrent\"))) {",
        "    Write-Host \"Scoop is migrating qbittorrent to use portable mode by default.\" -ForegroundColor Yellow",
        "    Write-Host \"For details, see: https://github.com/ScoopInstaller/Extras/issues/5845\" -ForegroundColor Yellow",
        "    if ((Test-Path \"$persist_dir\\..\\qbittorrent-portable\\profile\") -and (Test-Path \"$env:APPDATA\\qBittorrent\")) {",
        "        Write-Host \"Both portable and non-portable qBittorrent profile exist.\" -ForegroundColor Yellow",
        "        Write-Host \"Scoop will prioritize and import the non-portable one.\" -ForegroundColor Yellow",
        "    }",
        "    New-Item \"$persist_dir\\profile\" -ItemType Directory | Out-Null",
        "    if (Test-Path \"$env:APPDATA\\qBittorrent\") {",
        "        Write-Host \"Copying non-portable profile's config and data to Scoop persist directory...\" -ForegroundColor Yellow",
        "        Copy-Item \"$env:APPDATA\\qBittorrent\" \"$persist_dir\\profile\\qBittorrent\\config\" -Recurse | Out-Null",
        "        Copy-Item \"$env:LOCALAPPDATA\\qBittorrent\" \"$persist_dir\\profile\\qBittorrent\\data\" -Recurse | Out-Null",
        "    } else {",
        "        Write-Host \"Copying portable profile's config and data to Scoop persist directory...\" -ForegroundColor Yellow",
        "        Write-Host \"If you haven't setup an absolute download path before torrenting, please manually migrate affected torrents, as they use relative path by default for storaging.\" -ForegroundColor Yellow",
        "        Write-Host \"Or you can move them to an absolute download path in qbittorrent-portable and cleanly (re)install qbittorrent to let migration script to take care of them.\" -ForegroundColor Yellow",
        "        Copy-Item \"$persist_dir\\..\\qbittorrent-portable\\profile\\qBittorrent\\config\" \"$persist_dir\\profile\\qBittorrent\\config\" -Recurse | Out-Null",
        "        Copy-Item \"$persist_dir\\..\\qbittorrent-portable\\profile\\qBittorrent\\data\" \"$persist_dir\\profile\\qBittorrent\\data\" -Recurse | Out-Null",
        "    }",
        "}"
    ],
    "post_install": [
        "'install-associations', 'uninstall-associations' | ForEach-Object {",
        "    if (Test-Path \"$bucketsdir\\$bucket\\scripts\\qbittorrent\\$_.reg\") {",
        "        $qbitPath = \"$dir\".Replace('\\', '\\\\')",
        "        $content = (Get-Content \"$bucketsdir\\$bucket\\scripts\\qbittorrent\\$_.reg\").Replace('$qbit', $qbitPath)",
        "        if ($global) { $content = $content.Replace('HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE') }",
        "        Set-Content \"$dir\\$_.reg\" $content -Encoding Ascii -Force",
        "    }",
        "}"
    ],
    "bin": "qbittorrent.exe",
    "shortcuts": [
        [
            "qbittorrent.exe",
            "qBittorrent"
        ]
    ],
    "persist": "profile",
    "uninstaller": {
        "script": "if ($cmd -eq 'uninstall') { reg import \"$dir\\uninstall-associations.reg\" }"
    },
    "checkver": {
        "sourceforge": "qbittorrent/qbittorrent-win32",
        "regex": "qbittorrent_([\\d.]+)_x64_setup\\.exe"
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://downloads.sourceforge.net/project/qbittorrent/qbittorrent-win32/qbittorrent-$version/qbittorrent_$version_x64_setup.exe#/dl.7z"
            }
        }
    }
}
