Skip to content

Commit

Permalink
fixed ffmpeg download bug + added winver compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sprinter05 committed Apr 19, 2023
1 parent 2780e60 commit 319afc3
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 80 deletions.
159 changes: 82 additions & 77 deletions setup.bat
Original file line number Diff line number Diff line change
@@ -1,78 +1,83 @@
@echo off
echo PLEASE READ CAREFULLY BEFORE CHOOSING

::Ask user for the parameters
echo:
echo Would you like the standalone yt-dlp binary [1] or the x86 binary [2]? (Use the x86 binary ONLY if you have issues with the standalone one) [1/2] (default is 1)
set /p DFSET="> "
if "%DFSET%"=="2" (
set STDBINARY=0
) else (
set STDBINARY=1
)
echo:
echo Are you using Windows 10/11 [1] or an older version [2]? [1/2] (default is 1)
set /p WINV="> "
if "%WINV%"=="2" (
set STARTFILE=0
) else (
set STARTFILE=1
)

::Download yt-dlp win binary
echo:
echo Downloading yt-dlp.exe from https://github.com/yt-dlp/yt-dlp...
MKDIR "./ytdlp-handler"
if %STDBINARY%==1 (
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -o ./ytdlp-handler/yt-dlp.exe
) else (
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_x86.exe -o ./ytdlp-handler/yt-dlp.exe
)

::Download ffmpeg binaries
echo:
echo Downloading ffmpeg.exe and ffprobe.exe from https://github.com/BtbN/FFmpeg-Builds/releases...
curl -L https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-win64-gpl.zip -o ./ytdlp-handler/ffmpeg.zip
powershell -command "Expand-Archive -Force '.\ytdlp-handler\ffmpeg.zip' '.\ytdlp-handler\ffmpeg\'"
move ".\ytdlp-handler\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" ".\ytdlp-handler\"
move ".\ytdlp-handler\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" ".\ytdlp-handler\"
RMDIR /s /q ".\ytdlp-handler\ffmpeg"
del ".\ytdlp-handler\ffmpeg.zip"

::FFMPEG Licenses stuff
echo:
echo Downloading ffmpeg licenses from https://github.com/FFmpeg/FFmpeg...
mkdir ".\ytdlp-handler\ffmpeg_licenses"
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.GPLv2 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.GPLv2
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.GPLv3 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.GPLv3
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.LGPLv2.1 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.LGPLv2.1
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.LGPLv3 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.LGPLv3

::Download main files from project repo
echo:
echo Downloading main files from ttps://github.com/Sprinter05/ytdlp-handler/releases/latest...
curl -L https://github.com/Sprinter05/ytdlp-handler/releases/latest/download/ytdlp-handler_win_x86.zip -o ./ytdlp-handler/ytdlp-handler_win_x86.zip
powershell -command "Expand-Archive -Force '.\ytdlp-handler\ytdlp-handler_win_x86.zip' '.\ytdlp-handler\temp\'"
move ".\ytdlp-handler\temp\update.bat" ".\ytdlp-handler\"
move ".\ytdlp-handler\temp\settings.ini" ".\ytdlp-handler\"
move ".\ytdlp-handler\temp\changelog.txt" ".\ytdlp-handler\"
if %STARTFILE%==1 (
move ".\ytdlp-handler\temp\start.cmd" ".\ytdlp-handler\"
) else (
move ".\ytdlp-handler\temp\start_win.cmd" ".\ytdlp-handler\"
ren ".\ytdlp-handler\start_win.cmd" "start.cmd"
)
RMDIR /s /q ".\ytdlp-handler\temp"
del ".\ytdlp-handler\ytdlp-handler_win_x86.zip"

::License moment
curl -L https://raw.githubusercontent.com/Sprinter05/ytdlp-handler/main/LICENSE -o .\ytdlp-handler\LICENSE

::Kill program
cls
echo:
echo Open the start.cmd file inside the ytdlp-handler folder to run the program!
pause
del ".\setup.bat"
exit \b
@echo off
echo PLEASE READ CAREFULLY BEFORE CHOOSING

::Check and save Windows version
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j

::Ask user for the parameters
echo:
echo Would you like the standalone yt-dlp binary [1] or the x86 binary [2]? (Use the x86 binary ONLY if you have issues with the standalone one) [1/2] (default is 1)
set /p DFSET="> "
if "%DFSET%"=="2" (
set STDBINARY=0
) else (
set STDBINARY=1
)

::Download yt-dlp win binary
echo:
echo Downloading yt-dlp.exe from https://github.com/yt-dlp/yt-dlp...
MKDIR "./ytdlp-handler"
if %STDBINARY%==1 (
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -o ./ytdlp-handler/yt-dlp.exe
) else (
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_x86.exe -o ./ytdlp-handler/yt-dlp.exe
)

::Download ffmpeg binaries
echo:
echo Downloading ffmpeg.exe and ffprobe.exe from https://github.com/BtbN/FFmpeg-Builds/releases...
curl -L https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-win64-gpl.zip -o ./ytdlp-handler/ffmpeg.zip
powershell -command "Expand-Archive -ErrorAction Stop -Force '.\ytdlp-handler\ffmpeg.zip' '.\ytdlp-handler\ffmpeg\'"
set ffmpegdlfail=0
if ERRORLEVEL 1 set ffmpegdlfail=1
move ".\ytdlp-handler\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" ".\ytdlp-handler\"
move ".\ytdlp-handler\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" ".\ytdlp-handler\"
RMDIR /s /q ".\ytdlp-handler\ffmpeg"
del ".\ytdlp-handler\ffmpeg.zip"

::FFMPEG Licenses stuff
echo:
echo Downloading ffmpeg licenses from https://github.com/FFmpeg/FFmpeg...
mkdir ".\ytdlp-handler\ffmpeg_licenses"
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.GPLv2 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.GPLv2
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.GPLv3 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.GPLv3
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.LGPLv2.1 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.LGPLv2.1
curl -L https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/COPYING.LGPLv3 -o .\ytdlp-handler\ffmpeg_licenses\COPYING.LGPLv3

::Download main files from project repo
echo:
echo Downloading main files from ttps://github.com/Sprinter05/ytdlp-handler/releases/latest...
curl -L https://github.com/Sprinter05/ytdlp-handler/releases/latest/download/ytdlp-handler_win_x86.zip -o ./ytdlp-handler/ytdlp-handler_win_x86.zip
powershell -command "Expand-Archive -Force '.\ytdlp-handler\ytdlp-handler_win_x86.zip' '.\ytdlp-handler\temp\'"
move ".\ytdlp-handler\temp\update.bat" ".\ytdlp-handler\"
move ".\ytdlp-handler\temp\settings.ini" ".\ytdlp-handler\"
move ".\ytdlp-handler\temp\changelog.txt" ".\ytdlp-handler\"
if "%version%" == "10.0" (
move ".\ytdlp-handler\temp\start.cmd" ".\ytdlp-handler\"
) else (
move ".\ytdlp-handler\temp\start_win.cmd" ".\ytdlp-handler\"
ren ".\ytdlp-handler\start_win.cmd" "start.cmd"
)
RMDIR /s /q ".\ytdlp-handler\temp"
del ".\ytdlp-handler\ytdlp-handler_win_x86.zip"

::License moment
curl -L https://raw.githubusercontent.com/Sprinter05/ytdlp-handler/main/LICENSE -o .\ytdlp-handler\LICENSE

::Kill program and inform of any errors during installation
cls
echo:
if %ffmpegdlfail%==1 (
goto :FFmpegDLError
) else (
goto :Normal
)
:FFmpegDLError
echo The ffmpeg binaries could not be downloaded at the moment, please try again later through the update.bat file.
:Normal
echo Open the start.cmd file inside the ytdlp-handler folder to run the program!
pause
del ".\setup.bat"
exit \b
:::Code by Sprinter05
26 changes: 23 additions & 3 deletions update.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@echo off

::Check and save Windows version
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j

::Fix name problems
if exist update_new.bat (
echo Update completed! Remember to run start.cmd to start the program.
Expand Down Expand Up @@ -62,7 +65,9 @@ if %FFBINARY%==1 (
del "ffprobe.exe"
)
curl -L https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-win64-gpl.zip -o ./ffmpeg.zip
powershell -command "Expand-Archive -Force '.\ffmpeg.zip' '.\ffmpeg\'"
powershell -command "Expand-Archive -ErrorAction Stop -Force '.\ffmpeg.zip' '.\ffmpeg\'"
set ffmpegdlfail=0
if ERRORLEVEL 1 set ffmpegdlfail=1
move ".\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" ".\"
move ".\ffmpeg\ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" ".\"
RMDIR /s /q ".\ffmpeg"
Expand Down Expand Up @@ -108,8 +113,12 @@ if exist changelog.txt (
)
ren ".\temp\update.bat" "update_new.bat"
move ".\temp\update_new.bat" ".\"
move ".\temp\start.cmd" ".\"
move ".\temp\start_win.cmd" ".\"
if "%version%" == "10.0" (
move ".\temp\start.cmd" ".\"
) else (
move ".\temp\start_win.cmd" ".\"
ren ".\start_win.cmd" "start.cmd"
)
move ".\temp\changelog.txt" ".\"

::License moment
Expand All @@ -129,8 +138,19 @@ if %RESETSET%==1 (
)
RMDIR /s /q ".\temp"
del ".\ytdlp-handler_win_x86.zip"
echo Done

::The End
if %ffmpegdlfail%==1 (
goto :FFmpegDLError
) else (
goto :Normal
)
:FFmpegDLError
echo:
echo The ffmpeg binaries could not be downloaded at the moment, please try again later.
pause
:Normal
cls
call "update_new.bat"
exit \b
Expand Down

0 comments on commit 319afc3

Please sign in to comment.