]> Arthur Taft Gitweb - yt-dlp-wrapper.git/blob - windows/yt-dlp-wrapper.ps1
e0a96fcc6ebb52d675a0b6dd787ce8667c3c01e3
[yt-dlp-wrapper.git] / windows / yt-dlp-wrapper.ps1
1 # Set Variables
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
8 $val = 0
9 $url = ""
10
11 # Remove old executable
12 Remove-Item $exe_location
13
14 # Download new executable
15 Invoke-WebRequest https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -OutFile $exe_location
16
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"
20 }
21
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"
25 }
26
27
28 while($val -ne 1) {
29     # Ask the user if they are downloading audio or video
30     $Type = Read-Host "Audio or Video?"
31
32     # Download audio
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"
36         $val++
37     }
38     # Download video
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"
42         $val++
43     }
44     else {
45         Write-Output "Response must be 'Audio' or 'Video'!"
46         continue
47     }
48 }