{
    "version": "24846885360",
    "description": "Free and reliable P2P Bittorent client.",
    "homepage": "https://github.com/qbittorrent/qBittorrent",
    "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\""
    ],
    "suggest": {
        "vcredist": "extras/vcredist2022"
    },
    "architecture": {
        "64bit": {
            "url": "https://nightly.link/qbittorrent/qBittorrent/workflows/ci_windows.yaml/master/qBittorrent-CI_Windows-x64_libtorrent-2.0.11.zip",
            "hash": "06560e0ac8a375c39e483b86d39ce8c53a8ed50a167ea617c5cf55eceb99c913",
            "extract_dir": "qBittorrent"
        }
    },
    "pre_install": [
        "Remove-Item \"$dir/qbittorrent.pdb\"",
        "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\\$app\\$_.reg\") {",
        "        $qbitPath = \"$dir\".Replace('\\', '\\\\')",
        "        $content = (Get-Content \"$bucketsdir\\$bucket\\scripts\\$app\\$_.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": {
        "github": "https://api.github.com/repos/qbittorrent/qBittorrent/actions/workflows/ci_windows.yaml/runs?branch=master&status=success",
        "script": [
            "$ci_workflows = $page | ConvertFrom-Json",
            "$ci_file = Invoke-RestMethod https://raw.githubusercontent.com/qbittorrent/qBittorrent/master/.github/workflows/ci_windows.yaml",
            "$libtorrent_version = ( $ci_file | Select-String 'libtorrent:\\n.*version:\\s*\"(\\d+(?:\\.\\d+){2})\"').matches.groups[1].value",
            "$ci_workflows.workflow_runs[0].id, $libtorrent_version -join ' '"
        ],
        "regex": "\\A(\\d+) (?<libtorrent>[\\d.]+)\\Z"
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://nightly.link/qbittorrent/qBittorrent/workflows/ci_windows.yaml/master/qBittorrent-CI_Windows-x64_libtorrent-$matchLibtorrent.zip"
            }
        }
    }
}
