Релиз v1.0.0

This commit is contained in:
2026-08-09 11:43:39 +03:00
commit 0c214ef9bd
8 changed files with 734 additions and 0 deletions
+123
View File
@@ -0,0 +1,123 @@
#requires -Version 5.1
$ErrorActionPreference = "Stop"
# Корень проекта определяется независимо от текущей папки PowerShell.
$ProjectRoot = Split-Path -Parent $PSScriptRoot
$ToolsDir = Join-Path $ProjectRoot "tools"
$OutputDir = Join-Path $ProjectRoot "output"
if (-not (Test-Path $OutputDir)) {
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
}
function Find-Tool {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[string[]]$LocalNames = @()
)
foreach ($localName in $LocalNames) {
$localPath = Join-Path $ToolsDir $localName
if (Test-Path $localPath -PathType Leaf) {
return (Resolve-Path $localPath).Path
}
}
$command = Get-Command $Name -ErrorAction SilentlyContinue
if ($command) {
return $command.Source
}
return $null
}
function Require-Tool {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[string[]]$LocalNames = @(),
[string]$InstallHint = ""
)
$tool = Find-Tool -Name $Name -LocalNames $LocalNames
if (-not $tool) {
Write-Host ""
Write-Host "ОШИБКА: не найдена зависимость '$Name'." -ForegroundColor Red
Write-Host "Проверены:"
Write-Host " 1. Папка: $ToolsDir"
Write-Host " 2. Системная переменная PATH"
if ($InstallHint) {
Write-Host ""
Write-Host $InstallHint
}
Write-Host ""
Read-Host "Нажмите Enter для выхода"
exit 1
}
return $tool
}
$YtDlp = Require-Tool `
-Name "yt-dlp" `
-LocalNames @("yt-dlp.exe", "yt-dlp.cmd", "yt-dlp.ps1") `
-InstallHint "Скачать yt-dlp: https://github.com/yt-dlp/yt-dlp/releases/latest"
$Ffmpeg = Require-Tool `
-Name "ffmpeg" `
-LocalNames @("ffmpeg.exe") `
-InstallHint "Скачать FFmpeg: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z"
$FfmpegDir = Split-Path -Parent $Ffmpeg
Write-Host ""
Write-Host "============================================================"
Write-Host " СКАЧИВАНИЕ АУДИО С YOUTUBE"
Write-Host "============================================================"
Write-Host "Результат: $OutputDir"
Write-Host ""
$Url = Read-Host "Введите URL видео с YouTube"
if ([string]::IsNullOrWhiteSpace($Url)) {
Write-Host ""
Write-Host "ОШИБКА: ссылка не введена." -ForegroundColor Red
Read-Host "Нажмите Enter для выхода"
exit 1
}
$OutputTemplate = Join-Path $OutputDir "%(title)s.%(ext)s"
Write-Host ""
Write-Host "Скачивание и конвертация аудио в FLAC..."
Write-Host ""
& $YtDlp `
"-f" "ba" `
"--extract-audio" `
"--audio-format" "flac" `
"--audio-quality" "0" `
"--ffmpeg-location" $FfmpegDir `
"-o" $OutputTemplate `
$Url
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "ОШИБКА: yt-dlp завершил работу с кодом $LASTEXITCODE." -ForegroundColor Red
Read-Host "Нажмите Enter для выхода"
exit $LASTEXITCODE
}
Write-Host ""
Write-Host "Готово." -ForegroundColor Green
Write-Host "Файл сохранён в: $OutputDir"
Write-Host ""
Read-Host "Нажмите Enter для выхода"