Last active
May 19, 2025 08:19
-
-
Save JySzE/0d6417c84deceda8326e38804d31015b to your computer and use it in GitHub Desktop.
SoM MPV BUILDER
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
COLOR 1F | |
set PATH=%SystemRoot%\System32;%PATH% | |
cd /d "%~dp0" | |
echo ========================================================== | |
echo SoM MPV Builder | |
echo ========================================================== | |
echo Version 1.9c | |
echo 03/27/25 | |
echo ========================================================== | |
set /a num=%random% %%100 | |
set "MPV_old_RandomNumber=MPV_old_%random%" | |
IF EXIST "%CD%\MPV" ( | |
echo The "MPV" folder exists, Renamed to "%MPV_old_RandomNumber%". | |
echo ========================================================== | |
ren "%CD%\MPV" "%MPV_old_RandomNumber%" | |
) ELSE ( | |
goto :continue | |
) | |
:continue | |
echo Parsing MPV RSS feed for download links. | |
echo ========================================================== | |
set "MPVRSSFeedURL=https://api.github.com/repos/zhongfly/mpv-winbuild/releases/latest" | |
powershell -Command "$release_data = Invoke-RestMethod -Uri '%MPVRSSFeedURL%'; $latestV3Build = $release_data.assets | Where-Object { $_.browser_download_url -match 'mpv-x86_64-v3-.*-git-.*\.7z$' } | Select-Object -First 1; $latestNonV3Build = $release_data.assets | Where-Object { $_.browser_download_url -match 'mpv-x86_64-.*-git-.*\.7z$' -and $_.browser_download_url -notmatch '-v3-' } | Select-Object -First 1; [System.IO.File]::WriteAllText('%CD%\mpv_temp_v3.txt', $latestV3Build.browser_download_url); [System.IO.File]::WriteAllText('%CD%\mpv_temp.txt', $latestNonV3Build.browser_download_url);" | |
set /p LatestV3BuildLink=<"%CD%\mpv_temp_v3.txt" | |
set /p LatestNonV3BuildLink=<"%CD%\mpv_temp.txt" | |
echo Downloading 7zr. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://www.7-zip.org/a/7zr.exe" -o "%CD%\7zr.exe" >nul | |
echo Downloading Coreinfo. | |
echo ========================================================== | |
curl --noproxy "*" -s https://download.sysinternals.com/files/Coreinfo.zip -o "%CD%\Coreinfo.zip" | |
powershell -command "Expand-Archive -Path "%CD%\Coreinfo.zip" -DestinationPath "%CD%\Coreinfo"" | |
echo Parsing CPU instructions with Coreinfo. | |
echo ========================================================== | |
set "AVX2Support=false" | |
for /f "tokens=2*" %%a in ('"".\Coreinfo\Coreinfo.exe" /accepteula | findstr /C:"AVX2""') do ( | |
if "%%a"=="*" ( | |
set "AVX2Support=true" | |
) else if "%%a"=="-" ( | |
set "AVX2Support=false" | |
) | |
) | |
if "%AVX2Support%"=="true" ( | |
echo CPU is x86_64-v3 or newer. | |
echo ========================================================== | |
echo Downloading latest x86_64-v3 MPV build... | |
curl -s --noproxy "*" -L "%LatestV3BuildLink%" -o "%CD%\mpv_v3.7z" | |
echo ========================================================== | |
mkdir "%CD%\MPV" | |
"%CD%\7zr.exe" x "mpv_v3.7z" -o"%CD%\MPV" >nul | |
echo MPV_x86_64-v3 extracted to \MPV\. | |
echo ========================================================== | |
) else ( | |
echo CPU is x86_64-v2 or older. | |
echo ========================================================== | |
echo Downloading latest non-v3 MPV build... | |
curl -s --noproxy "*" -L "%LatestNonV3BuildLink%" -o "%CD%\mpv_non_v3.7z" | |
echo ========================================================== | |
mkdir "%CD%\MPV" | |
"%CD%\7zr.exe" x "mpv_non_v3.7z" -o"%CD%\MPV" >nul | |
echo MPV_x86_64 extracted to \MPV\. | |
echo ========================================================== | |
) | |
mkdir "%CD%\MPV\portable_config\scripts" | |
echo Downloading mpv.conf and input.conf. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://gist.githubusercontent.com/JySzE/db4149cad726b3b6955dca8d47a19721/raw" -o "%CD%\MPV\portable_config\mpv.conf" | |
curl --noproxy "*" -s "https://gist.githubusercontent.com/JySzE/ced7f506629c32f44adf4fe43a341189/raw" -o "%CD%\MPV\portable_config\input.conf" | |
echo Downloading mpv_conf_updater.bat. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://gist.githubusercontent.com/JySzE/94686099207e3d260d17a6c02ed0623a/raw" -o "%CD%\MPV\mpv_conf_updater.bat" | |
echo Downloading mpv-menu-plugin by tsl0922. | |
echo ========================================================== | |
REM Cant directly download github artifacts without tokens. | |
REM https://github.com/tsl0922/mpv-menu-plugin/actions/runs/12788258235/artifacts/2434275375 | |
curl --noproxy "*" -s -L "https://files.catbox.moe/xwqfyx.zip" -o "%CD%\menu.zip" | |
powershell -command "Expand-Archive -Path "%CD%\menu.zip" -DestinationPath "%CD%"" | |
move "%CD%\menu\*.*" "%CD%\MPV\portable_config\scripts" >nul | |
echo Downloading autoload.lua. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://raw.githubusercontent.com/mpv-player/mpv/master/TOOLS/lua/autoload.lua" -o "%CD%\MPV\portable_config\scripts\autoload.lua" | |
echo Downloading persist-properties.lua. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://gist.githubusercontent.com/JySzE/90a3f57ce05e3abeadf07af6fa1f680e/raw" -o "%CD%\MPV\portable_config\scripts\persist-properties.lua" | |
echo Downloading Gandhi Sans Font. | |
echo ========================================================== | |
mkdir "%CD%\MPV\portable_config\fonts" | |
REM Font site is constantly offline > https://www.tipografiagandhi.com/ | |
REM Archive if it never comes back > https://web.archive.org/web/20221123192054/www.tipografiagandhi.com/common/zip/gandhi_sans_and_serif.zip | |
curl --noproxy "*" -L -sk "https://files.catbox.moe/ftcqlt.zip" -o "%CD%\gandhi_sans_and_serif.zip" | |
powershell -command "Expand-Archive -Path "%CD%\gandhi_sans_and_serif.zip" -DestinationPath "%CD%"" | |
move "%CD%\TipografiaGandhi\GandhiSans-*.*" "%CD%\MPV\portable_config\fonts\" >nul | |
echo Downloading warn.js to \MPV\portable_config\scripts\. | |
echo ========================================================== | |
curl --noproxy "*" -s "https://gist.githubusercontent.com/JySzE/f310a2a7a313f47ac50aa6126acf7f30/raw" -o "%CD%\MPV\portable_config\scripts\warn.js" | |
echo Deleting temp files. | |
echo ========================================================== | |
move "%CD%\MPV\mpv\fonts.conf" "%CD%\MPV\portable_config\fonts.conf" >nul 2>&1 | |
for %%F in ( | |
"%CD%\mpv_temp*.txt" | |
"%CD%\Coreinfo.zip" | |
"%CD%\mpv_*.7z" | |
"%CD%\menu.zip" | |
"%CD%\gandhi_sans_and_serif.zip" | |
"%CD%\7z*.exe" | |
) do del /F /Q "%%F" | |
for %%D in ( | |
"%CD%\MPV\mpv" | |
"%CD%\Coreinfo" | |
"%CD%\MPV\doc" | |
"%CD%\menu" | |
"%CD%\TipografiaGandhi" | |
) do rd /S /Q "%%D" | |
echo Checking for APPDATA MPV folder... | |
set "folder=%APPDATA%\mpv" | |
set "backup_folder=mpv_bak" | |
set "backup_suffix=1" | |
IF EXIST "%folder%\" ( | |
echo ========================================================== | |
echo The APPDATA MPV folder exists. | |
echo ========================================================== | |
echo Renaming APPDATA "mpv" folder to "mpv_bak" | |
:check_backup_folder | |
if exist "%APPDATA%\%backup_folder%_%backup_suffix%" ( | |
set /a "backup_suffix+=1" | |
goto :check_backup_folder | |
) | |
move "%APPDATA%\mpv" "%APPDATA%\%backup_folder%_%backup_suffix%" >nul | |
) ELSE ( | |
echo ========================================================== | |
echo The APPDATA MPV folder does not exist. This is good. | |
) | |
COLOR 2F | |
echo ========================================================== | |
echo All done enjoy! | |
echo ========================================================== | |
powershell -Command "Write-Host 'Notice: Thumbfast removed due to bugs.' -ForegroundColor DarkBlue" | |
echo ========================================================== | |
powershell -Command "Write-Host 'Notice: Screenshot warning added until MPV fixes bug.' -ForegroundColor DarkBlue" | |
echo ========================================================== | |
pause | |
(goto) 2>nul & del "%~dp0\SoM_MPV_Builder.bat" |
Comments are disabled for this gist.