Вот готовый скрипт специально для обычной Windows + PowerShell (без WSL).
Код:
# Search-RuTracker.ps1
# Поиск по XML-дампу RuTracker в PowerShell
param (
[Parameter(Mandatory = $true, HelpMessage = "Ключевые слова для поиска")]
[string]$Query
)
# ====================== НАСТРОЙКА ======================
# Укажи полный путь к своему XML-файлу
$XmlPath = "C:\Users\ВашеИмя\Downloads\rutracker.xml"
# =======================================================
if (-not (Test-Path $XmlPath)) {
Write-Host "❌ Файл не найден: $XmlPath" -ForegroundColor Red
Write-Host "Открой скрипт и укажи правильный путь к XML." -ForegroundColor Yellow
exit 1
}
Write-Host "🔍 Ищем: `"$Query`"" -ForegroundColor Cyan
Write-Host ("=" * 70)
$words = $Query -split '\s+' | Where-Object { $_ -ne "" }
$reader = [System.IO.StreamReader]::new($XmlPath, [System.Text.Encoding]::UTF8)
$buffer = ""
$foundCount = 0
try {
while ($null -ne ($line = $reader.ReadLine())) {
$buffer += $line + "`n"
# Когда встретили конец раздачи
if ($line -match '</torrent>') {
# Проверяем, есть ли все слова из запроса
$allFound = $true
foreach ($word in $words) {
if ($buffer -notmatch [regex]::Escape($word)) {
$allFound = $false
break
}
}
if ($allFound) {
# Извлекаем название
$title = $null
if ($buffer -match '<title>([^<]+)</title>') {
$title = $Matches[1].Trim()
}
# Извлекаем хеш
$hash = $null
if ($buffer -match 'hash="([A-Fa-f0-9]{40})"') {
$hash = $Matches[1]
}
if ($title -and $hash) {
$foundCount++
Write-Host "📁 Название: $title" -ForegroundColor Green
Write-Host "🔑 Хеш: $hash"
Write-Host "🧲 Magnet: magnet:?xt=urn:btih:$hash" -ForegroundColor Yellow
Write-Host ("-" * 70)
}
}
# Очищаем буфер после обработки блока
$buffer = ""
}
}
}
finally {
$reader.Close()
}
if ($foundCount -eq 0) {
Write-Host "`nНичего не найдено." -ForegroundColor DarkGray
} else {
Write-Host "`nНайдено раздач: $foundCount" -ForegroundColor Cyan
}
Как пользоваться:
1 Открой Блокнот (или VS Code / Notepad++).
2 Вставь код выше.
3 Измени путь в строке:
powershell
$XmlPath = "C:\Users\ВашеИмя\Downloads\rutracker.xml"
4 Сохрани файл как Search-RuTracker.ps1 (важно именно с расширением .ps1).
5 Открой PowerShell и перейди в папку со скриптом:
powershell
cd C:\Users\ВашеИмя\Desktop
6 Запусти (первый раз может попросить разрешение) : powershell
.\Search-RuTracker.ps1 "matrix 1999"
Если PowerShell ругается на политику выполнения:Выполни один раз (от имени администратора не обязательно):
powershell
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned