+ param (
+ $ffmpeg_link
+ )
+
+ # Create work directory to extract archive with new executable
+ New-Item -Path $current_dir -Name "work" -ItemType "directory"
+ Invoke-WebRequest $ffmpeg_link -OutFile $ffmpeg_zip_work_location
+ # Extract archive to work directory
+ Expand-Archive -Path $ffmpeg_zip_work_location -DestinationPath $work_dir
+
+ # Move new executable to correct location
+ Move-Item -Path $ffmpeg_work_location -Destination $bin_dir
+
+ # Remove work directory
+ Remove-Item -Recurse -Force $work_dir
+
+ Write-Output "Done!"
+
+}
+
+function Convert-BatchLink {
+
+ param (
+ $dl_val
+ )
+
+ while($dl_val -ne 1){
+ # Ask the user if they are downloading audio or video
+ $Format = Read-Host "Audio or Video?"
+
+ # Download audio
+ if($Format -eq "audio") {
+ Invoke-Expression "$exe_location -x -f 'ba' --audio-format mp3 --windows-filenames -o $audio_title -a $batch_dl_file"
+ $dl_val++
+ }
+ # Download video
+ elseif($Format -eq "video"){
+ Invoke-Expression "$exe_location -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' --windows-filenames --sponsorblock-remove sponsor,selfpromo,interaction -o $video_title -a $batch_dl_file"
+ $dl_val++
+ }
+ else {
+ Write-Output "Response must be 'Audio' or 'Video'!"
+ continue
+ }
+ }
+}
+
+function Convert-Link {
+
+ param (
+ $dl_val
+ )
+
+ while($dl_val -ne 1) {
+ # Ask the user if they are downloading audio or video
+ $Format = Read-Host "Audio or Video?"
+
+ # Download audio
+ if($Format -eq "audio") {
+ $url = Read-Host "Enter URL Here"
+ Invoke-Expression "$exe_location -x -f 'ba' --audio-format mp3 --windows-filenames -o $audio_title $url"
+ $dl_val++
+ }
+ # Download video
+ elseif($Format -eq "video"){
+ $url = Read-Host "Enter URL Here"
+ Invoke-Expression "$exe_location -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' --windows-filenames --sponsorblock-remove sponsor,selfpromo,interaction -o $video_title $url"
+ $dl_val++
+ }
+ else {
+ Write-Output "Response must be 'Audio' or 'Video'!"
+ continue
+ }
+ }
+}
+
+if($bin_test -ne $true) {
+ Write-Output "bin directory not found! Creating now!"
+ New-Item -Path $current_dir -Name "bin" -ItemType "directory"
+}
+
+if($sig_test -ne $true) {
+ Write-Output "sig directory not found! Creating now!"
+ New-Item -Path $current_dir -Name "sig" -ItemType "directory"
+}
+
+if($ffmpeg_test -eq $true){
+ # Remove old ffmpeg signature
+ Remove-Item $ffmpeg_sig_location
+} else {
+ Write-Output "ffmpeg executable not found! Downloading now..."
+ Get-FFmpeg($ffmpeg_link)
+}
+
+if($exe_test -eq $true) {
+ # Remove old yt-dlp signature
+ Remove-Item $yt_sig_location
+} else {
+ Write-Output "yt-dlp executable not found! Downloading now..."
+ Invoke-WebRequest $yt_dlp_link -OutFile $exe_location
+ Write-Output "Done!"
+}
+
+Write-Output "Updating ffmpeg signature..."
+# Download new ffmpeg signature
+Invoke-WebRequest https://github.com/arthur-taft/ffmpeg-latest-signatures/releases/latest/download/checksums.sha256 -OutFile $ffmpeg_sig_location
+Write-Output "Done!"
+
+Write-Output "Updating yt-dlp signature..."
+# Download new yt-dlp signature
+Invoke-WebRequest https://github.com/arthur-taft/yt-dlp-signatures/releases/latest/download/SHA2-512SUMS -OutFile $yt_sig_location
+Write-Output "Done!"
+
+if($yt_sig_eq_check -ne $true) {
+ Write-Output "Old version of yt-dlp found, updating now..."
+
+ # Remove old executable
+ Remove-Item $exe_location
+
+ # Download new executable
+ Invoke-WebRequest $yt_dlp_link -OutFile $exe_location
+
+ Write-Output "Done!"
+}
+
+if($ffmpeg_sig_eq_check -ne $true) {
+ Write-Output "Old version ffmpeg found, updating now..."
+
+ # Remove old executables
+ Remove-Item $ffmpeg_location
+ Remove-Item $ffprobe_location
+ Remove-Item $ffplay_location
+
+ # Remove old libraries
+ Remove-Item $ffmpeg_dll_location
+
+ Get-FFmpeg($ffmpeg_link)
+}