FlareSolverr-фолбэк для загрузки по ссылке; -ReleaseUrl в predict.ps1

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Sonnet 5.5 committed 2026-10-27 17:29:58 +07:00
1 parent bc9ff36e61
commit dce219aeee
6 files changed
+150 -10

No files matched your search

+20 -2
View File
@@ -3,6 +3,8 @@
# Примеры (из корня проекта):
# powershell -NoProfile -ExecutionPolicy Bypass -File examples\powershell\predict.ps1 -Text "Перевод: Дублированный | MovieDalen"
# powershell -NoProfile -ExecutionPolicy Bypass -File examples\powershell\predict.ps1 -HtmlFile page.html
# powershell -NoProfile -ExecutionPolicy Bypass -File examples\powershell\predict.ps1 -ReleaseUrl "https://rutracker.org/forum/viewtopic.php?t=123"
# (kinozal: добавьте -Cookie "uid=..; pass=..")
# pwsh -File examples\powershell\predict.ps1 -Text "..." -Url http://host:8000
#
# Тело запроса отправляется UTF-8 байтами — это одинаково работает и в
@@ -14,7 +16,11 @@ param(
[Parameter(Mandatory = $true, ParameterSetName = 'Text')]
[string]$Text,
[Parameter(Mandatory = $true, ParameterSetName = 'Html')]
[string]$HtmlFile
[string]$HtmlFile,
[Parameter(Mandatory = $true, ParameterSetName = 'Release')]
[string]$ReleaseUrl,
[Parameter(ParameterSetName = 'Release')]
[string]$Cookie
)
$ErrorActionPreference = 'Stop'
@@ -29,6 +35,9 @@ if ($HtmlFile) {
$html = [IO.File]::ReadAllText($path, [Text.Encoding]::GetEncoding(1251))
}
$payload = @{ html = $html }
} elseif ($ReleaseUrl) {
$payload = @{ url = $ReleaseUrl }
if ($Cookie) { $payload.cookie = $Cookie }
} else {
$payload = @{ text = $Text }
}
@@ -40,10 +49,19 @@ try {
$r = Invoke-RestMethod -Uri "$Url/predict" -Method Post `
-ContentType 'application/json' -Body $bytes
} catch {
Write-Error "Сервис недоступен ($Url). Запуск: python -m src.service`n$_"
if ($_.Exception.Response) {
# сервис ответил ошибкой (например, трекер вернул 403) — показываем его текст
$detail = $_.ErrorDetails.Message
Write-Error "Сервис вернул ошибку: $detail"
} else {
Write-Error "Сервис недоступен ($Url). Запуск: python -m src.service`n$_"
}
exit 1
}
if ($r.studios) {
"18+ релиза: $($r.is_18plus) типы: $($r.translation_types -join ', ')"
}
if ($r.tracks) {
$r.tracks | Format-Table translation_type, studio, is_18plus,
type_confidence -AutoSize