From: Arthur Taft Date: Tue, 27 May 2025 20:51:25 +0000 (-0600) Subject: Add windows auto updating and update gitignore X-Git-Url: https://gitweb.arthurtaft.net/yt-dlp-wrapper.git/commitdiff_plain/3673b239d1687dba61100bd63bc569b7c7ab1587?ds=inline Add windows auto updating and update gitignore --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..175161d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +windows/audio/ +windows/video/ +windows/work/ + +linux/audio/ +linux/video/ \ No newline at end of file diff --git a/windows/bin/ffmpeg.exe b/windows/bin/ffmpeg.exe index 35dd63d..8c61b92 100644 Binary files a/windows/bin/ffmpeg.exe and b/windows/bin/ffmpeg.exe differ diff --git a/windows/bin/yt-dlp.exe b/windows/bin/yt-dlp.exe index b4c8137..94b1bb7 100644 Binary files a/windows/bin/yt-dlp.exe and b/windows/bin/yt-dlp.exe differ diff --git a/windows/sig/SHA2-512SUMS b/windows/sig/SHA2-512SUMS new file mode 100644 index 0000000..f51cd87 --- /dev/null +++ b/windows/sig/SHA2-512SUMS @@ -0,0 +1 @@ +0fa23037b01c04990c8cdf97f0121424dc5ae8525be908f8299a7b8558d26047cc41c52c83cc7ba5a0151b53fe8cbff1edbb1fdcdf683800ab56fde4e2d671c7 \ No newline at end of file diff --git a/windows/sig/checksums.sha256 b/windows/sig/checksums.sha256 new file mode 100644 index 0000000..1548054 --- /dev/null +++ b/windows/sig/checksums.sha256 @@ -0,0 +1 @@ +2aed280d0175c55292bfedb54680cf00e8f36875cd9399c46607116924413f58 \ No newline at end of file diff --git a/windows/yt-dlp-wrapper.ps1 b/windows/yt-dlp-wrapper.ps1 index e0a96fc..515f4fc 100644 --- a/windows/yt-dlp-wrapper.ps1 +++ b/windows/yt-dlp-wrapper.ps1 @@ -1,27 +1,89 @@ # Set Variables $current_dir = Get-Location $exe_location = Join-Path -Path $current_dir -ChildPath '\bin\yt-dlp.exe' +$ffmpeg_location = Join-Path -Path $current_dir -ChildPath '\bin\ffmpeg.exe' $audio_dir = Join-Path -Path $current_dir -ChildPath '\audio' $video_dir = Join-Path -Path $current_dir -ChildPath '\video' +$work_dir = Join-Path -Path $current_dir -ChildPath '\work' +$ffmpeg_zip_work_location = Join-Path -Path $work_dir -ChildPath 'ffmpeg.zip' +$ffmpeg_work_location = Join-Path -Path $work_dir -ChildPath '\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe' $test_audio_dir = Test-Path -Path $audio_dir $test_video_dir = Test-Path -Path $video_dir $val = 0 $url = "" +$yt_sig_location = Join-Path -Path $current_dir -ChildPath '\sig\SHA2-512SUMS' +$yt_current_sig = certutil.exe -hashfile $exe_location SHA512 +$ffmpeg_sig_location = Join-Path -Path $current_dir -ChildPath '\sig\checksums.sha256' +$ffmpeg_current_sig = certutil.exe -hashfile $ffmpeg_location SHA256 +$yt_sig_eq_check = Select-String -Path $yt_sig_location -Pattern $yt_current_sig -SimpleMatch -Quiet +$ffmpeg_sig_eq_check = Select-String -Path $ffmpeg_sig_location -Pattern $ffmpeg_current_sig -SimpleMatch -Quiet -# Remove old executable -Remove-Item $exe_location +# Remove old ffmpeg signature +Remove-Item $ffmpeg_sig_location -# Download new executable -Invoke-WebRequest https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -OutFile $exe_location +# Remove old yt-dlp signature +Remove-Item $yt_sig_location + +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 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -OutFile $exe_location + + Write-Output "Done!" +} + +if($ffmpeg_sig_eq_check -ne $true) { + Write-Output "Old version ffmpeg found, updating now..." + + # Remove old executable + Remove-Item $ffmpeg_location + + # Create work directory to extract archive with new executable + New-Item -Path $current_dir -Name "work" -ItemType "directory" + + # Download new archive + Invoke-WebRequest https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip -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 $ffmpeg_location + + # Remove work directory + Remove-Item -Recurse -Force $work_dir + + Write-Output "Done!" +} # Check if audio output directory exists, if not, create it if($test_audio_dir -eq $false) { + Write-Output "Audio directory not found!" + Write-Output "Creating now..." New-Item -Path $current_dir -Name "audio" -ItemType "directory" + Write-Output "Done!" } # Check if video output directory exists, if not, create it if($test_video_dir -eq $false) { + Write-Output "Video directory not found!" + Write-Output "Creating now..." New-Item -Path $current_dir -Name "video" -ItemType "directory" + Write-Output "Done!" }