2 $current_dir = Get-Location
3 $exe_location = Join-Path -Path $current_dir -ChildPath '\bin\yt-dlp.exe'
4 $audio_dir = Join-Path -Path $current_dir -ChildPath '\audio'
5 $video_dir = Join-Path -Path $current_dir -ChildPath '\video'
6 $test_audio_dir = Test-Path -Path $audio_dir
7 $test_video_dir = Test-Path -Path $video_dir
11 # Remove old executable
12 Remove-Item $exe_location
14 # Download new executable
15 Invoke-WebRequest https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -OutFile $exe_location
17 # Check if audio output directory exists, if not, create it
18 if($test_audio_dir -eq $false) {
19 New-Item -Path $current_dir -Name "audio" -ItemType "directory"
22 # Check if video output directory exists, if not, create it
23 if($test_video_dir -eq $false) {
24 New-Item -Path $current_dir -Name "video" -ItemType "directory"
29 # Ask the user if they are downloading audio or video
30 $Type = Read-Host "Audio or Video?"
33 if($Type -eq "audio") {
34 $url = Read-Host "Enter URL Here"
35 Invoke-Expression "$exe_location -x -f 'ba' --audio-format mp3 -o $audio_dir'\%(title)s.%(ext)s' $url"
39 elseif($Type -eq "video"){
40 $url = Read-Host "Enter URL Here"
41 Invoke-Expression "$exe_location -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' -o $video_dir'\%(title)s.%(ext)s' $url"
45 Write-Output "Response must be 'Audio' or 'Video'!"